Source code for doitoml.updaters.doit_tools
"""Uptodate checkers provided by ``doit``."""
from pprint import pformat
from typing import TYPE_CHECKING, Any, Optional, cast
import doit.tools
from doitoml.types import ExecutionContext, FnAction
from ._updater import Updater
if TYPE_CHECKING:
from doitoml.sources._config import ConfigSource
[docs]
class ConfigChanged(Updater):
"""A wrapper for ``doit.tools.config_changed``."""
[docs]
def get_update_function(
self,
uptodate: Any,
execution_context: ExecutionContext,
) -> FnAction:
"""Create a ``doit.tools.config_changed``."""
return cast(FnAction, doit.tools.config_changed(uptodate))
[docs]
def resolve_one_arg(self, source: "ConfigSource", arg_value: Any) -> Optional[Any]:
"""Resolve a single argument."""
if isinstance(arg_value, str):
return self.doitoml.config.resolve_one_path_spec(
source,
arg_value,
source_relative=False,
)
return arg_value
[docs]
class RunOnce(Updater):
"""A wrapper for ``doit.tools.run_once``."""
[docs]
def get_update_function(
self,
uptodate: Any,
execution_context: ExecutionContext,
) -> FnAction:
"""Create a ``doit.tools.run_once``."""
return cast(FnAction, doit.tools.run_once)