Return task named ``name`` plus 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 `.Collection` and any nested `Collections <.Collection>`, up through the one actually
(
self, name: Optional[str]
)
| 378 | return task, dict(config, **ours) |
| 379 | |
| 380 | def task_with_config( |
| 381 | self, name: Optional[str] |
| 382 | ) -> Tuple[str, Dict[str, Any]]: |
| 383 | """ |
| 384 | Return task named ``name`` plus its configuration dict. |
| 385 | |
| 386 | E.g. in a deeply nested tree, this method returns the `.Task`, and a |
| 387 | configuration dict created by merging that of this `.Collection` and |
| 388 | any nested `Collections <.Collection>`, up through the one actually |
| 389 | holding the `.Task`. |
| 390 | |
| 391 | See `~.Collection.__getitem__` for semantics of the ``name`` argument. |
| 392 | |
| 393 | :returns: Two-tuple of (`.Task`, `dict`). |
| 394 | |
| 395 | .. versionadded:: 1.0 |
| 396 | """ |
| 397 | # Our top level configuration |
| 398 | ours = self.configuration() |
| 399 | # Default task for this collection itself |
| 400 | if not name: |
| 401 | if not self.default: |
| 402 | raise ValueError("This collection has no default task.") |
| 403 | return self[self.default], ours |
| 404 | # Normalize name to the format we're expecting |
| 405 | name = self.transform(name) |
| 406 | # Non-default tasks within subcollections -> recurse (sorta) |
| 407 | if "." in name: |
| 408 | coll, rest = self._split_path(name) |
| 409 | return self._task_with_merged_config(coll, rest, ours) |
| 410 | # Default task for subcollections (via empty-name lookup) |
| 411 | if name in self.collections: |
| 412 | return self._task_with_merged_config(name, "", ours) |
| 413 | # Regular task lookup |
| 414 | return self.tasks[name], ours |
| 415 | |
| 416 | def __contains__(self, name: str) -> bool: |
| 417 | try: |
no test coverage detected