Actions can receive parameters from three sources:
kwargs: Explicitly defined in the action's definition.- Task Metadata: Automatically calculated values like
dependencies, changed, targets, and task. - Computed Values: Values calculated by other tasks (via
getargs).
Keywords with Task Metadata
doit automatically calculates these values for every task:
dependencies: list of file_dep.changed: list of file_dep that changed since the last successful execution.targets: list of targets.task: (Python actions only) The actual Task object instance.
Using Metadata in cmd-action
For cmd-action strings, you can use implicit keyword substitution via Python formatting. The keyword value is a string of all respective filenames separated by a space.
Control the formatting style via DOIT_CONFIG['action_string_formatting']:
'old': Uses % (default in version 0.32).'new': Uses {}.'both': Supports both.
Note: If using the string form of cmd-action, you must escape control characters by doubling them (e.g., %% for % or {{}} for {}). If using the list form (e.g., ['echo', '{}']), escaping is not required.
Using Metadata in python-action
For python-action, simply add the keyword as a parameter in your function. dependencies, changed, and targets are passed as lists of strings.