quickie.tasks.Task

class quickie.tasks.Task(name: str | None = None, *, aliases: Sequence[str] | None = None, private: bool = False, defined_from: type | Callable | None = None, args: Sequence[Arg | str | Sequence[str]] | None = None, extra_args: bool | None = None, condition: BaseCondition | None = None, before: Sequence[Callable] | None = None, after: Sequence[Callable] | None = None, cleanup: Sequence[Callable] | None = None)

Base class for all tasks.

__init__(name: str | None = None, *, aliases: Sequence[str] | None = None, private: bool = False, defined_from: type | Callable | None = None, args: Sequence[Arg | str | Sequence[str]] | None = None, extra_args: bool | None = None, condition: BaseCondition | None = None, before: Sequence[Callable] | None = None, after: Sequence[Callable] | None = None, cleanup: Sequence[Callable] | None = None)

Initialize the task.

Parameters:
  • name – The name it can be invoked with. If not provided, it defaults to the class name.

  • aliases – Alternative names it can be invoked with..

  • defined_from – The obj (class or function) where the task was defined. If not provided, and the task is not private, it defaults to the class itself.

  • private – Whether the task is private. If not provided, it is private if the class name starts with an underscore.

  • args – The arguments for the task. If not provided, it defaults to the class attribute args.

  • extra_args – Whether to allow extra command line arguments. If not provided, it defaults to the class attribute extra_args.

  • condition – The condition to check before running the task. If not provided, it defaults to the class attribute condition.

  • before – The tasks to run before this task. If not provided, it defaults to the class attribute before.

  • after – The tasks to run after this task. If not provided, it defaults to the class attribute after.

  • cleanup – The tasks to run at the end, even if the task, or before or after tasks fail. If not provided, it defaults to the class attribute cleanup.

Methods

__init__([name, aliases, private, ...])

Initialize the task.

add_args(parser)

Add arguments to the parser.

condition_passes(*args, **kwargs)

Check the condition before running the task.

full_run(*args, **kwargs)

Call the task, including before, after, and cleanup tasks.

get_after(*args, **kwargs)

Get the tasks to run after this task.

get_before(*args, **kwargs)

Get the tasks to run before this task.

get_cleanup(*args, **kwargs)

Get the tasks to run after this task, even if it fails.

get_help()

Get the help message of the task.

get_parser(*[, name])

Get the parser for the task.

get_short_help()

Get the short help message of the task.

log_task_execution(*args, **kwargs)

Log information about the task execution.

log_task_execution_details(*args, **kwargs)

Log details about the task execution.

parse_and_run(args)

Parse arguments and run the task.

parse_args(*, parser, args, extra_args)

Parse arguments.

run(*args, **kwargs)

Runs work related to the task, excluding before, after, and cleanup tasks.

run_after(*args, **kwargs)

Run the tasks after this task.

run_before(*args, **kwargs)

Run the tasks before this task.

run_cleanup(*args, **kwargs)

Run the tasks after this task, even if it fails.

Attributes

after

Tasks to run after this task.

args

Arguments for the task.

before

Tasks to run before this task.

cleanup

Tasks to run at the end, even if the task, or before or after tasks fail.

condition

The condition to check before running the task.

extra_args

Whether to allow extra command line arguments.

parser

Parser for the task.