本文整理汇总了Python中source.Source.get方法的典型用法代码示例。如果您正苦于以下问题:Python Source.get方法的具体用法?Python Source.get怎么用?Python Source.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类source.Source
的用法示例。
在下文中一共展示了Source.get方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from source import Source [as 别名]
# 或者: from source.Source import get [as 别名]
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')