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

Method execute

invoke/executor.py:52–149  ·  view source on GitHub ↗

Execute one or more ``tasks`` in sequence. :param tasks: An all-purpose iterable of "tasks to execute", each member of which may take one of the following forms: **A string** naming a task from the Executor's `.Collection`. This name

(
        self, *tasks: Union[str, Tuple[str, Dict[str, Any]], ParserContext]
    )

Source from the content-addressed store, hash-verified

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
71 [
72 ('task1', {}),
73 ('task2', {'arg1': 'val1'}),
74 ...
75 ]
76
77 is equivalent, roughly, to::
78
79 task1()
80 task2(arg1='val1')
81
82 **A `.ParserContext`** instance, whose ``.name`` attribute is used
83 as the task name and whose ``.as_kwargs`` attribute is used as the
84 task kwargs (again following the above specifications).
85
86 .. note::
87 When called without any arguments at all (i.e. when ``*tasks``
88 is empty), the default task from ``self.collection`` is used
89 instead, if defined.
90
91 :returns:
92 A dict mapping task objects to their return values.
93
94 This dict may include pre- and post-tasks if any were executed. For
95 example, in a collection with a ``build`` task depending on another
96 task named ``setup``, executing ``build`` will result in a dict
97 with two keys, one for ``build`` and one for ``setup``.
98
99 .. versionadded:: 1.0
100 """
101 # Normalize input
102 debug("Examining top level tasks {!r}".format([x for x in tasks]))
103 calls = self.normalize(tasks)
104 debug("Tasks (now Calls) with kwargs: {!r}".format(calls))
105 # Obtain copy of directly-given tasks since they should sometimes
106 # behave differently
107 direct = list(calls)
108 # Expand pre/post tasks
109 # TODO: may make sense to bundle expansion & deduping now eh?

Calls 7

normalizeMethod · 0.95
expand_callsMethod · 0.95
dedupeMethod · 0.95
configurationMethod · 0.80
load_shell_envMethod · 0.80
make_contextMethod · 0.80
load_collectionMethod · 0.45

Tested by

no test coverage detected