MCPcopy Index your code
hub / github.com/pyinvoke/invoke / Executor

Class Executor

invoke/executor.py:13–232  ·  view source on GitHub ↗

An execution strategy for Task objects. Subclasses may override various extension points to change, add or remove behavior. .. versionadded:: 1.0

Source from the content-addressed store, hash-verified

11
12
13class Executor:
14 """
15 An execution strategy for Task objects.
16
17 Subclasses may override various extension points to change, add or remove
18 behavior.
19
20 .. versionadded:: 1.0
21 """
22
23 def __init__(
24 self,
25 collection: "Collection",
26 config: Optional["Config"] = None,
27 core: Optional["ParseResult"] = None,
28 ) -> None:
29 """
30 Initialize executor with handles to necessary data structures.
31
32 :param collection:
33 A `.Collection` used to look up requested tasks (and their default
34 config data, if any) by name during execution.
35
36 :param config:
37 An optional `.Config` holding configuration state. Defaults to an
38 empty `.Config` if not given.
39
40 :param core:
41 An optional `.ParseResult` holding parsed core program arguments.
42 Defaults to ``None``.
43
44 .. versionchanged:: 3.0
45 The ``core`` attribute now defaults to an 'empty' `.ParseResult` if
46 ``None`` was given.
47 """
48 self.collection = collection
49 self.config = config if config is not None else Config()
50 self.core = core if core is not None else ParseResult()
51
52 def execute(
53 self, *tasks: Union[str, Tuple[str, Dict[str, Any]], ParserContext]
54 ) -> Dict["Task", "Result"]:
55 """
56 Execute one or more ``tasks`` in sequence.
57
58 :param tasks:
59 An all-purpose iterable of "tasks to execute", each member of which
60 may take one of the following forms:
61
62 **A string** naming a task from the Executor's `.Collection`. This
63 name may contain dotted syntax appropriate for calling namespaced
64 tasks, e.g. ``subcollection.taskname``. Such tasks are executed
65 without arguments.
66
67 **A two-tuple** whose first element is a task name string (as
68 above) and whose second element is a dict suitable for use as
69 ``**kwargs`` when calling the named task. E.g.::
70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…