DoitRunner
Base classes
| Name |
Children |
Inherits |
TaskRunner anyenv.task_runners._base Base class for task runner configurations. |
|
|
⋔ Inheritance diagram
graph TD
1452670658["_python.DoitRunner"]
3225203877["_base.TaskRunner"]
2751680898["builtins.object"]
3225203877 --> 1452670658
2751680898 --> 3225203877
🛈 DocStrings
Bases: TaskRunner
Task runner for doit (pydoit.org).
Source code in src/anyenv/task_runners/_python.py
| @dataclass
class DoitRunner(TaskRunner):
"""Task runner for doit (pydoit.org)."""
id: ClassVar[Literal["doit"]] = "doit"
website: ClassVar[str] = "http://pydoit.org"
filenames: ClassVar[list[str]] = ["dodo.py"]
help_cmd: ClassVar[list[str]] = ["doit", "list"]
logo: ClassVar[str | None] = "https://pydoit.org/_static/doit-logo.png"
# Pattern for task_ function definitions
_TASK_FUNC_PATTERN: ClassVar[re.Pattern[str]] = re.compile(r"^def\s+(task_\w+)\s*\(")
async def get_tasks(self, fs: AsyncFileSystem, cwd: str) -> list[TaskInfo]:
"""Parse dodo.py and return available tasks."""
config_file = await self.get_config_file(fs, cwd)
if config_file is None:
return []
content = await self._read_file(fs, config_file)
return self._parse_dodo(content)
def _parse_dodo(self, content: str) -> list[TaskInfo]:
"""Parse dodo.py to extract task_ functions."""
try:
tree = ast.parse(content)
except SyntaxError:
return []
tasks: list[TaskInfo] = []
for node in ast.walk(tree):
if not isinstance(node, ast.FunctionDef):
continue
# doit tasks are functions named task_*
if not node.name.startswith("task_"):
continue
# Task name is function name without task_ prefix
task_name = node.name[5:] # Remove "task_" prefix
# Extract docstring as description
description = ast.get_docstring(node)
tasks.append(TaskInfo(name=task_name, description=description))
return sorted(tasks, key=lambda t: t.name)
def get_run_command(self, task_name: str, *args: str) -> list[str]:
"""Get the doit command for a specific task."""
return ["doit", "run", task_name, *args]
|
get_run_command
get_run_command(task_name: str, *args: str) -> list[str]
Get the doit command for a specific task.
Source code in src/anyenv/task_runners/_python.py
| def get_run_command(self, task_name: str, *args: str) -> list[str]:
"""Get the doit command for a specific task."""
return ["doit", "run", task_name, *args]
|
get_tasks
async
get_tasks(fs: AsyncFileSystem, cwd: str) -> list[TaskInfo]
Parse dodo.py and return available tasks.
Source code in src/anyenv/task_runners/_python.py
| async def get_tasks(self, fs: AsyncFileSystem, cwd: str) -> list[TaskInfo]:
"""Parse dodo.py and return available tasks."""
config_file = await self.get_config_file(fs, cwd)
if config_file is None:
return []
content = await self._read_file(fs, config_file)
return self._parse_dodo(content)
|
:fa-brands-github: Show source on GitHub