A collection of executable tasks.
Returns task named
name. Honors aliases and subcollections.
If this collection has a default task, it is returned when
nameis empty or
None. If empty input is given and no task has been selected as the default, ValueError will be raised.
Tasks within subcollections should be given in dotted form, e.g. ‘foo.bar’. Subcollection default tasks will be returned on the subcollection’s name.
collas a sub-collection of this one.
add_task(task, name=None, default=None)¶
taskto this collection.
- task – The
Taskobject to add to this collection.
- name – Optional string name to bind to (overrides the task’s own
nameattribute and/or any Python identifier (i.e.
- default – Whether this task should be the collection default.
- task – The
Obtain merged configuration values from collection & children.
Parameters: taskpath – (Optional) Task name/path, identical to that used for
__getitem__(e.g. may be dotted for nested tasks, etc.) Used to decide which path to follow in the collection tree when merging config values.
dictcontaining configuration values.
optionsinto the current
Options configured this way will be available to all tasks. It is recommended to use unique keys to avoid potential clashes with other config options
For example, if you were configuring a Sphinx docs build target directory, it’s better to use a key like
Parameters: options – An object implementing the dictionary protocol. Returns:
from_module(module, name=None, config=None, loaded_from=None)¶
Return a new
Taskinstances and adds them to a new
Collection, returning it. If any explicit namespace collections exist (named
namespace) a copy of that collection object is preferentially loaded instead.
When the implicit/default collection is generated, it will be named after the module’s
__name__attribute, or its last dotted section if it’s a submodule. (I.e. it should usually map to the actual
Explicitly given collections will only be given that module-derived name if they don’t already have a valid
- name (str) – A string, which if given will override any automatically derived collection name (or name set on the module’s root namespace, if it has one.)
- config (dict) –
If the imported module had a root namespace object,
configis merged on top of it (i.e. overriding any conflicts.)
- loaded_from (str) – Identical to the same-named kwarg from the regular class constructor - should be the path where the module was found.
Obtain first collection + remainder, of a task path.
("subcollection", "taskname"); for
("subcollection", "nested.taskname"), etc.
An empty path becomes simply
Return all task identifiers for this collection as a dict.
Specifically, a dict with the primary/”real” task names as the key, and any aliases as a list value.
Return task named
nameplus its configuration dict.
E.g. in a deeply nested tree, this method returns the
Task, and a configuration dict created by merging that of this
Collectionand any nested
Collections, up through the one actually holding the
__getitem__for semantics of the
Returns: Two-tuple of (
Returns all contained tasks and subtasks as a list of parser contexts.