本文整理汇总了Python中source.Source类的典型用法代码示例。如果您正苦于以下问题:Python Source类的具体用法?Python Source怎么用?Python Source使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Source类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_add_rsvps_to_event
def test_add_rsvps_to_event(self):
event = copy.deepcopy(EVENT)
Source.add_rsvps_to_event(event, [])
self.assert_equals(EVENT, event)
Source.add_rsvps_to_event(event, RSVPS)
self.assert_equals(EVENT_WITH_RSVPS, event)
示例2: __init__
class Remote:
def __init__(self,addr,**kwargs):
self.ssrc = kwargs['ssrc']
self.control_address = addr
self.data_address = None
self.period = kwargs['expect_period']
self.packet_size = kwargs['expect_size']
self.tv_recv = time_now()
self.source = Source()
def onPeriod(self):
pass
def update(self,downstream):
pass
def onSenderReport(self,report):
pass
def onReceiverReport(self,report):
pass
def onPacket(self,packet):
seq = packet.get('seq')
if seq is None:
return
self.tv_recv = time_now()
self.source.update_seq(seq)
示例3: __init__
def __init__(self, config=None):
"""
Initialization of NIST scraper
:param config: configuration variables for this scraper, must contain
'reliability' key.
"""
Source.__init__(self, config)
self.ignore_list = set()
示例4: transactionalCreateTree
def transactionalCreateTree(dataForPointTree, user):
outlineRoot = OutlineRoot()
outlineRoot.put()
# ITERATE THE FIRST TIME AND CREATE ALL POINT ROOTS WITH BACKLINKS
for p in dataForPointTree:
pointRoot = PointRoot(parent=outlineRoot.key)
pointRoot.url = p['url']
pointRoot.numCopies = 0
pointRoot.editorsPick = False
pointRoot.viewCount = 1
if 'parentIndex' in p:
parentPointRoot = dataForPointTree[p['parentIndex']]['pointRoot']
pointRoot.pointsSupportedByMe = [parentPointRoot.key]
pointRoot.put()
p['pointRoot'] = pointRoot
point = Point(parent=pointRoot.key)
point.title = p['title']
point.url = pointRoot.url
point.content = p['furtherInfo']
point.current = True
point.authorName = user.name
point.authorURL = user.url
point.put()
user.addVote(point, voteValue=1, updatePoint=False)
user.recordCreatedPoint(pointRoot.key)
p['point'] = point
p['pointRoot'].current = p['point'].key
pointRoot.put()
point.addToSearchIndexNew()
# ITERATE THE SECOND TIME ADD SUPPORTING POINTS
for p in dataForPointTree:
if 'parentIndex' in p:
linkP = dataForPointTree[p['parentIndex']]['point']
linkP.supportingPointsRoots = linkP.supportingPointsRoots + [p['pointRoot'].key] \
if linkP.supportingPointsRoots else [p['pointRoot'].key]
linkP.supportingPointsLastChange = linkP.supportingPointsLastChange + [p['point'].key] \
if linkP.supportingPointsRoots else [p['point'].key]
# ITERATE THE THIRD TIME AND WRITE POINTS WITH ALL SUPPORTING POINTS AND SOURCE KEYS
for p in dataForPointTree:
if p['sources']:
sourceKeys = []
for s in p['sources']:
source = Source(parent=p['point'].key)
source.url = s['sourceURL']
source.name = s['sourceTitle']
source.put()
sourceKeys = sourceKeys + [source.key]
p['point'].sources = sourceKeys
p['point'].put()
return dataForPointTree[0]['point'], dataForPointTree[0]['pointRoot']
示例5: MainWindow
class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
def __init__(self, database, admin):
QtGui.QMainWindow.__init__(self)
Ui_MainWindow.__init__(self)
self.setupUi(self)
self.show()
# parameters
self.admin = admin
self.database = database
# menu action signals
self.actionOpen.triggered.connect(self.open_file)
self.actionOpen_Camera.triggered.connect(\
self.open_camera)
self.actionQuit.triggered.connect(self.quit)
self.actionAbout.triggered.connect(self.about)
# objects
self.source = Source(self, database, admin)
# init settings
init_main(self)
# keyboard shortcuts
shortcuts(self)
# admin
self.admin_window = AdminWindow(self.source, self)
# notification object here
self.notification = Notification(self.source, self)
# report tab
self.report = Report(self.source, self)
# menu action
def open_file(self):
print("Clicked open file in menu")
self.source.open("file")
def open_camera(self):
print("Clicked open camera in menu")
self.source.open("camera")
def about(self):
print("Opening about window")
self.about = AboutWindow()
def quit(self):
print("Quit application")
QtCore.QCoreApplication.instance().quit()
示例6: __init__
def __init__(self, config=None):
"""
Initialization of ChemSpider scraper
:param config: a dictionary of settings for this scraper, must contain
'reliability' key
"""
Source.__init__(self, config)
self.ignore_list = []
if 'token' not in self.cfg or self.cfg['token'] == '':
log.msg('ChemSpider token not set or empty, search/MassSpec API '
'not available', level=log.WARNING)
self.cfg['token'] = ''
self.search += self.cfg['token']
self.extendedinfo += self.cfg['token']
示例7: getSource
def getSource(self):
from source import Source
if hasattr(self, 'source_id'):
self.source = Source(_id=self.source_id)
else:
fingerprint = None
try:
fingerprint = self.j3m['intent']['pgpKeyFingerprint'].lower()
except KeyError as e:
print "NO FINGERPRINT???"
self.source = Source(inflate={
'invalid': {
'error_code' : invalidate['codes']['source_missing_pgp_key'],
'reason' : invalidate['reasons']['source_missing_pgp_key']
}
})
if fingerprint is not None:
source = self.submission.db.query(
'_design/sources/_view/getSourceByFingerprint',
params={
'fingerprint' : fingerprint
}
)[0]
if source:
self.source = Source(_id=source['_id'])
else:
# we didn't have the pgp key.
# so init a new source and set an invalid flag about that.
inflate = {
'fingerprint' : fingerprint
}
## TODO: ACTUALLY THIS IS CASE-SENSITIVE! MUST BE UPPERCASE!
self.source = Source(inflate=inflate)
self.source.invalidate(
invalidate['codes']['source_missing_pgp_key'],
invalidate['reasons']['source_missing_pgp_key']
)
setattr(self, 'source_id', self.source._id)
self.save()
if hasattr(self, 'source_id'):
return True
else:
return False
示例8: main
def main(args):
problem_dir, working_dir, source_path, language = parse_options(args)
os.chdir(working_dir)
shutil.copy(source_path, './source.' + LANG_EXT_MAP.get(language))
output_path = RUNNABLE_PATH
problem_obj = Problem(problem_dir)
source_obj = Source(source_path, language)
program_obj = source_obj.compile(output_path)
program_obj.run(problem_obj)
return os.EX_OK
示例9: setup_source
def setup_source(self, x, y, source_image, source_size, to_intersection,
car_images, car_size, generative=True, spawn_delay=4.0):
''' Sets up a Source, which is an Intersection. '''
s = Sprite(source_image, source_size)
s.move_to(x=x, y=self.height - y)
source = Source(x, y, None, None, self, car_images, car_size,
spawn_delay=spawn_delay, generative=generative)
road = self.setup_road(source, to_intersection, 'road.bmp')
source.road = road
source.length_along_road = road.length
self.source_set.add(source)
self.window.add_sprite(s)
return source
示例10: validate_forms
def validate_forms(self):
"""Validate form."""
root_pass = self.ids.pr2.text
username = self.ids.us1.text
user_pass = self.ids.us3.text
home = self.ids.us4.text
shell = self.ids.us5.text
pre = self.ids.pre.text
pos = self.ids.pos.text
if self.source:
s = self.source
else:
s = 'cdrom'
folder = ''
server = ''
partition = self.ids.partition.text
ftp_user = self.ids.ftp_user.text
ftp_pass = self.ids.ftp_pass.text
print('SOURCE:' + self.source)
if s == 'Hard drive':
folder = self.ids.hh_folder.text
elif s == 'NFS':
folder = self.ids.nfs_folder.text
server = self.ids.nfs_server.text
elif s == 'HTTP':
folder = self.ids.http_folder.text
server = self.ids.http_server.text
elif s == 'FTP':
folder = self.ids.ftp_folder.text
server = self.ids.ftp_server.text
source = Source()
source.save_source(s, partition, folder, server, ftp_user, ftp_pass)
# if self.active is True and self.ids.pr1.text
# is not self.ids.pr2.text:
# print(self.ids.pr1.focus)
# popup = InfoPopup()
# popup.set_info('Root passwords do not match')
# popup.open()
user = User()
user.save_user(root_pass, username, user_pass, home, shell)
script = Script()
script.save_script(pre, pos)
section = Section()
section.create_file()
示例11: __init__
def __init__(self, database, admin):
QtGui.QMainWindow.__init__(self)
Ui_MainWindow.__init__(self)
self.setupUi(self)
self.show()
# parameters
self.admin = admin
self.database = database
# menu action signals
self.actionOpen.triggered.connect(self.open_file)
self.actionOpen_Camera.triggered.connect(\
self.open_camera)
self.actionQuit.triggered.connect(self.quit)
self.actionAbout.triggered.connect(self.about)
# objects
self.source = Source(self, database, admin)
# init settings
init_main(self)
# keyboard shortcuts
shortcuts(self)
# admin
self.admin_window = AdminWindow(self.source, self)
# notification object here
self.notification = Notification(self.source, self)
# report tab
self.report = Report(self.source, self)
示例12: setup
def setup(
self,
item=False,
meshes=False,
keyable=False,
prefix=False,
parentVis=False,
):
"""
Sets up and initialises the source mesh
"""
# add the parent visibility node
# to the core node store so it can be hidden
# on render
self.coreNode.addParentGroup(parentVis)
# now make the source node
self.source = Source(
meshes=meshes,
keyable=keyable,
parentVis=parentVis,
prefix=prefix,
node=item
)
self.melSettings()
示例13: test_should_get_row_from_cache
def test_should_get_row_from_cache(self):
q = Query(
lambda: [{"t": 1, "v": 55000}, {"t": 2, "v": 11000}],
query_name="q1",
key_column="t",
mapping={},
non_data_fields=[],
)
s = Source(source_name="src", query=q)
s.get_records()
# to move the values into the hot part of the cache we need to push twice
s.get_records()
self.assertEquals(s.cache.get_row(1), {"t": 1, "v": 55000})
self.assertEquals(s.cache.get_row(2), {"t": 2, "v": 11000})
示例14: __init__
def __init__(self, program):
super(Scanner, self).__init__()
self.source = Source(program)
self.char = ''
self.atomPositionEnd = TextPos()
self.atomPositionStart = TextPos()
self.intConst = 0
self.strConst = ""
self.spell = ""
self.__nextChar()
示例15: sample
def sample(self):
"""
Method to pick the sample satisfying the likelihood constraint using uniform sampling
Returns
-------
new : object
The evolved sample
number : int
Number of likelihood calculations after sampling
"""
new = Source()
x_l, x_u = self.getPrior_X()
y_l, y_u = self.getPrior_Y()
r_l, r_u = self.getPrior_R()
a_l, a_u = self.getPrior_A()
while(True):
new.X = np.random.uniform(x_l,x_u)
new.Y = np.random.uniform(y_l,y_u)
new.A = np.random.uniform(a_l,a_u)
new.R = np.random.uniform(r_l,r_u)
new.logL = self.log_likelihood(new)
self.number+=1
if(new.logL > self.LC):
break
return new, self.number