本文整理汇总了Python中flexget.task.Task.all_entries[:]方法的典型用法代码示例。如果您正苦于以下问题:Python Task.all_entries[:]方法的具体用法?Python Task.all_entries[:]怎么用?Python Task.all_entries[:]使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flexget.task.Task
的用法示例。
在下文中一共展示了Task.all_entries[:]方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_phase
# 需要导入模块: from flexget.task import Task [as 别名]
# 或者: from flexget.task.Task import all_entries[:] [as 别名]
def handle_phase(task, config):
entry_actions = {'accept': Entry.accept, 'reject': Entry.reject, 'fail': Entry.fail}
for item in config:
requirement, action = list(item.items())[0]
passed_entries = (e for e in task.entries if self.check_condition(requirement, e))
if isinstance(action, str):
if not phase == 'filter':
continue
# Simple entry action (accept, reject or fail) was specified as a string
for entry in passed_entries:
entry_actions[action](entry, 'Matched requirement: %s' % requirement)
else:
# Other plugins were specified to run on this entry
fake_task = Task(task.manager, task.name, config=action, options=task.options)
fake_task.session = task.session
# This entry still belongs to our feed, accept/reject etc. will carry through.
fake_task.all_entries[:] = passed_entries
methods = {}
for plugin_name, plugin_config in action.items():
p = plugin.get_plugin_by_name(plugin_name)
method = p.phase_handlers.get(phase)
if method:
methods[method] = (fake_task, plugin_config)
# Run the methods in priority order
for method in sorted(methods, reverse=True):
method(*methods[method])
示例2: handle_phase
# 需要导入模块: from flexget.task import Task [as 别名]
# 或者: from flexget.task.Task import all_entries[:] [as 别名]
def handle_phase(task, config):
if task.name not in self.task_phases:
log.debug('No config dict was generated for this task.')
return
entry_actions = {
'accept': Entry.accept,
'reject': Entry.reject,
'fail': Entry.fail}
for item in self.task_phases[task.name][phase]:
requirement, action = item.items()[0]
passed_entries = [e for e in task.entries if self.check_condition(requirement, e)]
if passed_entries:
if isinstance(action, basestring):
# Simple entry action (accept, reject or fail) was specified as a string
for entry in passed_entries:
entry_actions[action](entry, 'Matched requirement: %s' % requirement)
else:
# Other plugins were specified to run on this entry
fake_task = Task(task.manager, task.name, task.config)
fake_task.session = task.session
# This entry still belongs to our feed, accept/reject etc. will carry through.
fake_task.all_entries[:] = passed_entries
try:
for plugin_name, plugin_config in action.iteritems():
plugin = get_plugin_by_name(plugin_name)
method = plugin.phase_handlers[phase]
method(fake_task, plugin_config)
except Exception:
raise