本文整理汇总了Python中doit.control.TaskControl._filter_tasks方法的典型用法代码示例。如果您正苦于以下问题:Python TaskControl._filter_tasks方法的具体用法?Python TaskControl._filter_tasks怎么用?Python TaskControl._filter_tasks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类doit.control.TaskControl
的用法示例。
在下文中一共展示了TaskControl._filter_tasks方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_filter_delayed_subtask
# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import _filter_tasks [as 别名]
def test_filter_delayed_subtask(self):
t1 = Task("taskX", None)
t2 = Task("taskY", None, loader=DelayedLoader(lambda: None))
control = TaskControl([t1, t2])
control._filter_tasks(['taskY:foo'])
assert isinstance(t2.loader, DelayedLoader)
# sub-task will use same loader, and keep parent basename
assert control.tasks['taskY:foo'].loader.basename == 'taskY'
assert control.tasks['taskY:foo'].loader is t2.loader
示例2: testPosParam
# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import _filter_tasks [as 别名]
def testPosParam(self):
tasks = list(TASKS_SAMPLE)
tasks.append(Task("tP", [""],[],[], pos_arg='myp'))
tc = TaskControl(tasks)
args = ["tP", "hello option!", "t1"]
assert ['tP',] == tc._filter_tasks(args)
assert ["hello option!", "t1"] == tc.tasks['tP'].pos_arg_val
示例3: test_delayed_creation_target_regex
# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import _filter_tasks [as 别名]
def test_delayed_creation_target_regex(self):
def creator():
yield Task('foo', None, targets=['tgt1'])
delayed_loader = DelayedLoader(creator,
executed='t2', target_regex='tgt1')
tasks = {
't1': Task('t1', None, loader=delayed_loader),
't2': Task('t2', None),
}
tc = TaskControl(list(tasks.values()))
selection = tc._filter_tasks(['tgt1'])
assert ['_regex_target_tgt1:t1'] == selection
td = TaskDispatcher(tc.tasks, tc.targets, selection)
n1 = td._gen_node(None, '_regex_target_tgt1:t1')
gen = td._add_task(n1)
# first returned node is `t2` because it is an implicit task_dep
n2 = next(gen)
assert n2.task.name == 't2'
# wait until t2 is finished
n3 = next(gen)
assert n3 == 'wait'
# after t2 is done, generator is reseted
n2.run_status = 'done'
td._update_waiting(n2)
n4 = next(gen)
assert n4 == "reset generator"
# manually reset generator
n1.reset_task(td.tasks[n1.task.name], td._add_task(n1))
# get the delayed created task
gen2 = n1.generator # n1 generator was reset / replaced
# get t1 because of its target was a file_dep of _regex_target_tgt1
n5 = next(gen2)
assert n5.task.name == 'foo'
# get internal created task
n5.run_status = 'done'
td._update_waiting(n5)
n6 = next(gen2)
assert n6.name == '_regex_target_tgt1:t1'
# file_dep is removed because foo might not be task
# that creates this task (support for multi regex matches)
assert n6.file_dep == {}
示例4: test_filter_delayed_multi_select
# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import _filter_tasks [as 别名]
def test_filter_delayed_multi_select(self):
t1 = Task("taskX", None)
t2 = Task("taskY", None,
loader=DelayedLoader(lambda: None, target_regex='a.*'))
t3 = Task("taskZ", None,
loader=DelayedLoader(lambda: None, target_regex='b.*'))
t4 = Task("taskW", None,
loader=DelayedLoader(lambda: None))
control = TaskControl([t1, t2, t3, t4], auto_delayed_regex=False)
selected = control._filter_tasks(['abc', 'att'])
assert isinstance(t2.loader, DelayedLoader)
assert len(selected) == 2
assert selected[0] == '_regex_target_abc:taskY'
assert selected[1] == '_regex_target_att:taskY'
示例5: test_regex_not_found
# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import _filter_tasks [as 别名]
def test_regex_not_found(self):
def creator1():
yield Task('foo1', None, targets=['tgt1'])
delayed_loader1 = DelayedLoader(creator1, target_regex='tgt.*')
t1 = Task('t1', None, loader=delayed_loader1)
tc = TaskControl([t1])
selection = tc._filter_tasks(['tgt666'])
assert ['_regex_target_tgt666:t1'] == selection
td = TaskDispatcher(tc.tasks, tc.targets, selection)
n1 = td._gen_node(None, '_regex_target_tgt666:t1')
gen = td._add_task(n1)
# target not found after generating all tasks from regex group
pytest.raises(InvalidCommand, next, gen)
示例6: test_filter_delayed_regex_auto
# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import _filter_tasks [as 别名]
def test_filter_delayed_regex_auto(self):
t1 = Task("taskX", None)
t2 = Task("taskY", None,
loader=DelayedLoader(lambda: None, target_regex='a.*'))
t3 = Task("taskZ", None,
loader=DelayedLoader(lambda: None))
control = TaskControl([t1, t2, t3], auto_delayed_regex=True)
selected = control._filter_tasks(['abc'])
assert len(selected) == 2
assert (sorted(selected) ==
['_regex_target_abc:taskY', '_regex_target_abc:taskZ'])
assert control.tasks['_regex_target_abc:taskY'].file_dep == {'abc'}
assert control.tasks['_regex_target_abc:taskZ'].file_dep == {'abc'}
assert (control.tasks['_regex_target_abc:taskY'].loader.basename ==
t2.name)
assert (control.tasks['_regex_target_abc:taskZ'].loader.basename ==
t3.name)
示例7: test_filter_delayed_regex_single
# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import _filter_tasks [as 别名]
def test_filter_delayed_regex_single(self):
t1 = Task("taskX", None)
t2 = Task("taskY", None,
loader=DelayedLoader(lambda: None, target_regex='a.*'))
t3 = Task("taskZ", None,
loader=DelayedLoader(lambda: None, target_regex='b.*'))
t4 = Task("taskW", None,
loader=DelayedLoader(lambda: None))
control = TaskControl([t1, t2, t3, t4], auto_delayed_regex=False)
selected = control._filter_tasks(['abc'])
assert isinstance(t2.loader, DelayedLoader)
assert len(selected) == 1
assert selected[0] == '_regex_target_abc:taskY'
sel_task = control.tasks['_regex_target_abc:taskY']
assert sel_task.file_dep == {'abc'}
assert sel_task.loader.basename == 'taskY'
assert sel_task.loader is t2.loader
示例8: test_regex_group_already_created
# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import _filter_tasks [as 别名]
def test_regex_group_already_created(self):
# this is required to avoid loading more tasks than required, GH-#60
def creator1():
yield Task('foo1', None, targets=['tgt1'])
delayed_loader1 = DelayedLoader(creator1, target_regex='tgt.*')
def creator2(): # pragma: no cover
yield Task('foo2', None, targets=['tgt2'])
delayed_loader2 = DelayedLoader(creator2, target_regex='tgt.*')
t1 = Task('t1', None, loader=delayed_loader1)
t2 = Task('t2', None, loader=delayed_loader2)
tc = TaskControl([t1, t2])
selection = tc._filter_tasks(['tgt1'])
assert ['_regex_target_tgt1:t1', '_regex_target_tgt1:t2'] == selection
td = TaskDispatcher(tc.tasks, tc.targets, selection)
n1 = td._gen_node(None, '_regex_target_tgt1:t1')
gen = td._add_task(n1)
# delayed loader executed, so generator is reset
n1b = next(gen)
assert n1b == "reset generator"
# manually reset generator
n1.reset_task(td.tasks[n1.task.name], td._add_task(n1))
# get the delayed created task
gen1b = n1.generator # n1 generator was reset / replaced
# get t1 because of its target was a file_dep of _regex_target_tgt1
n1c = next(gen1b)
assert n1c.task.name == 'foo1'
# get internal created task
n1c.run_status = 'done'
td._update_waiting(n1c)
n1d = next(gen1b)
assert n1d.name == '_regex_target_tgt1:t1'
## go for second selected task
n2 = td._gen_node(None, '_regex_target_tgt1:t2')
gen2 = td._add_task(n2)
# loader is not executed because target t1 was already found
pytest.raises(StopIteration, next, gen2)
示例9: testFilterTarget
# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import _filter_tasks [as 别名]
def testFilterTarget(self):
tasks = list(TASKS_SAMPLE)
tasks.append(Task("tX", [""],[],["targetX"]))
tc = TaskControl(tasks)
assert ['tX'] == tc._filter_tasks(["targetX"])
示例10: testFilterSubtask
# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import _filter_tasks [as 别名]
def testFilterSubtask(self):
filter_ = ["t1", "g1.b"]
tc = TaskControl(TASKS_SAMPLE)
assert filter_ == tc._filter_tasks(filter_)
示例11: testFilterPattern
# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import _filter_tasks [as 别名]
def testFilterPattern(self):
tc = TaskControl(TASKS_SAMPLE)
assert ['t1', 'g1', 'g1.a', 'g1.b'] == tc._filter_tasks(['*1*'])
示例12: testFilter
# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import _filter_tasks [as 别名]
def testFilter(self):
filter_ = ['t2', 't3']
tc = TaskControl(TASKS_SAMPLE)
assert filter_ == tc._filter_tasks(filter_)
示例13: testOptions
# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import _filter_tasks [as 别名]
def testOptions(self):
options = ["t3", "--message", "hello option!", "t1"]
tc = TaskControl(TASKS_SAMPLE)
assert ['t3', 't1'] == tc._filter_tasks(options)
assert "hello option!" == tc.tasks['t3'].options['opt1']
示例14: testFilterEmptyList
# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import _filter_tasks [as 别名]
def testFilterEmptyList(self):
filter_ = []
tc = TaskControl(TASKS_SAMPLE)
assert filter_ == tc._filter_tasks(filter_)