本文整理汇总了Python中source.Source类的典型用法代码示例。如果您正苦于以下问题:Python Source类的具体用法?Python Source怎么用?Python Source使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Source类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:barnabywalters,项目名称:activitystreams-unofficial,代码行数:7,代码来源:source_test.py
示例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)
开发者ID:maolin-cdzl,项目名称:mswatcher,代码行数:29,代码来源:server.py
示例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()
开发者ID:jjdekker,项目名称:Fourmi,代码行数:8,代码来源:NIST.py
示例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']
开发者ID:aaronlifshin,项目名称:howtosavedemocaracy,代码行数:54,代码来源:point.py
示例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()
开发者ID:janmaghuyop,项目名称:fuzztrack,代码行数:52,代码来源:main.py
示例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']
开发者ID:jjdekker,项目名称:Fourmi,代码行数:14,代码来源:ChemSpider.py
示例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
开发者ID:harlo,项目名称:InformaCam-Service,代码行数:50,代码来源:derivative.py
示例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
开发者ID:,项目名称:,代码行数:14,代码来源:
示例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
开发者ID:popcorncolonel,项目名称:TrafficSim,代码行数:14,代码来源:master.py
示例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()
开发者ID:albertoburitica,项目名称:kickoff,代码行数:50,代码来源:settings.py
示例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)
开发者ID:janmaghuyop,项目名称:fuzztrack,代码行数:34,代码来源:main.py
示例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()
开发者ID:campbellwmorgan,项目名称:charactercrowd,代码行数:25,代码来源:characterCrowd.py
示例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})
开发者ID:PeterHenell,项目名称:performance-dashboard,代码行数:16,代码来源:__init__.py
示例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()
开发者ID:kawazaki0,项目名称:tkom,代码行数:11,代码来源:scanner.py
示例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
开发者ID:ProfessorBrunner,项目名称:bayes-detect,代码行数:34,代码来源:uniform.py
示例16: _load_sources
def _load_sources(self):
for source_file_physical_path, dirnames, filenames in os.walk(self.source_dir):
# get relative path starting from self.source_dir
source_file_relative_path = os.path.relpath(source_file_physical_path, self.source_dir)
get_formats = etree.XPath("//meta[@name='dcterms.Format']/@content")
for f in filenames:
# append a Source object to sources files list
s = Source(os.path.abspath(source_file_physical_path), source_file_relative_path, f)
xml = etree.parse(s.source)
formats = get_formats(xml)
for ext in formats:
physical_path = os.path.abspath(os.path.join(self.out_dir, s.relative_path))
target = Target(physical_path, s.relative_path, s.basename, ext)
s.add_target(target)
# XXX: only use one format for now
break
self.sources.append(s)
logging.debug(self.sources)
开发者ID:konker,项目名称:blogilainen,代码行数:22,代码来源:blogilainen.py
示例17: __init__
def __init__(self, events):
config = Conf()
self.reddit = praw.Reddit(user_agent='Switcharoo Cartographer v.0.2.1')
self.reddit.login(config.r_username, config.r_password, disable_warning=True)
self.events = events
self.queue = None
self.data = Access(self.events)
self.source = Source(self)
self._port = config.com_port
self._share_port = config.share_port
self._auth = config.auth
self._should_stop = False
self._threshold = 10
开发者ID:admgrn,项目名称:Switcharoo,代码行数:13,代码来源:transverse.py
示例18: _parse
def _parse(self):
funclines = {}
source = None
with open(self.filename) as f:
for line in f:
line = line.strip()
if line == 'end_of_record':
if source is not None:
directory, filename = os.path.split(source.filename)
self.sources[directory][filename] = source
source = None
else:
key, argstr = tuple(line.split(':'))
args = argstr.split(',')
if key == 'SF':
fname = args[0]
if fname.startswith(self.basepath):
source = Source(args[0])
else:
source = None
elif source is not None:
if key == 'FN':
name = args[1]
funclines[name] = int(args[0])
elif key == 'FNDA':
hits = int(args[0])
name = args[1]
func = Function(funclines[name], name, hits)
source.add_function(func)
elif key == 'BRDA':
line = int(args[0])
path = int(args[2])
hits = 0 if args[3] == '-' else int(args[3])
source.add_branch(Branch(line, path, hits))
elif key == 'DA':
line = int(args[0])
hits = int(args[1])
source.add_line(Line(line, hits))
开发者ID:sr527,项目名称:gcov,代码行数:46,代码来源:parser.py
示例19: run
def run(config_path, days = 1):
logging.info('Started')
with open(config_path, 'r') as config_file:
import json
from datetime import datetime, timedelta
from notifier import Notifier
from source import Source
from seminarparser import Parser
config = json.load(config_file)
source = Source.get(config['source']['type'], config['source'])
parser = Parser.get(config['parser']['type'], config['parser'])
notifier = Notifier.get(config['notifier']['type'], config['notifier'])
now = datetime.now().date()
tomorrow = now + timedelta(days = days)
logging.info('Initialized')
src = source.get(tomorrow)
logging.info('Getting source is complete')
headers = parser.find_headers(src)
logging.info('%d headers found' % len(headers))
defaults = config['defaults']
seminars = [parser.parse_seminar(header, defaults) for header in headers]
logging.info('%d seminars found' % len(headers))
for seminar in [(seminar.title, datetime.combine(seminar.date, seminar.time).isoformat(' '), seminar.place, '/'.join(seminar.contents)) for seminar in seminars]:
logging.debug('Seminar found: %s, %s, %s, %s' % seminar)
tomorrow_seminars = [seminar for seminar in seminars if seminar.date == tomorrow]
logging.info('%d seminars found on %s' % (len(tomorrow_seminars), tomorrow))
for seminar in tomorrow_seminars:
notifier.notify(seminar)
logging.info('Notify sent: %s, %s, %s' % (seminar.title, seminar.date, seminar.time))
logging.info('Done')
开发者ID:ukatama,项目名称:seminarnotifier,代码行数:43,代码来源:__main__.py
示例20: transactionalCreate
def transactionalCreate(pointRoot, title, nodetype, content, summaryText, user,
imageURL=None, imageAuthor=None,
imageDescription=None, sourceURLs=None, sourceNames=None):
pointRoot.put()
point = Point(parent=pointRoot.key)
point.title = title
point.nodetype = nodetype
point.url = pointRoot.url
point.content = content
point.summaryText = summaryText if (len(
summaryText) != 250) else summaryText + '...'
point.authorName = user.name
point.authorURL = user.url
point.version = 1
point.current = True
point.upVotes = 1
point.downVotes = 0
point.voteTotal = 1
point.imageURL = imageURL
point.imageDescription = imageDescription
point.imageAuthor = imageAuthor
point.put()
sources = Source.constructFromArrays(sourceURLs, sourceNames, point.key)
if sources:
sourceKeys = []
for source in sources:
source.put()
sourceKeys = sourceKeys + [source.key]
point.sources = sourceKeys
point.put()
point.addToSearchIndexNew()
pointRoot.current = point.key
pointRoot.put()
user.addVote(point, voteValue=1, updatePoint=False)
user.recordCreatedPoint(pointRoot.key)
return point, pointRoot
开发者ID:aaronlifshin,项目名称:howtosavedemocaracy,代码行数:39,代码来源:point.py
注:本文中的source.Source类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论