invoke_helpers
Invoke Helpers.
Functions⚓︎
get_doc_subdir ⚓︎
get_doc_subdir(path_project=None)
Retrieve the documentation directory from the copier answer file.
PARAMETER | DESCRIPTION |
---|---|
path_project |
Path to the project directory with contains
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Path
|
to the source documentation directory
TYPE:
|
Source code in calcipy/invoke_helpers.py
@beartype
def get_doc_subdir(path_project: Optional[Path] = None) -> Path:
"""Retrieve the documentation directory from the copier answer file.
Args:
path_project: Path to the project directory with contains `.copier-answers.yml`
Returns:
Path: to the source documentation directory
"""
path_copier = (path_project or get_project_path()) / COPIER_ANSWERS
doc_dir = read_yaml_file(path_copier).get('doc_dir', 'docs')
return path_copier.parent / doc_dir / 'docs' # type: ignore[no-any-return]
get_project_path
cached
⚓︎
get_project_path()
Retrieve the cwd
.
Source code in calcipy/invoke_helpers.py
@lru_cache(maxsize=1)
def get_project_path() -> Path:
"""Retrieve the `cwd`."""
return Path.cwd()
run ⚓︎
run(ctx, *run_args, **run_kwargs)
Wrap invoke.run to run within the working_dir
.
Source code in calcipy/invoke_helpers.py
@beartype
def run(ctx: Context, *run_args: Any, **run_kwargs: Any) -> Optional[Result]:
"""Wrap invoke.run to run within the `working_dir`."""
working_dir = '.'
with suppress(AttributeError):
working_dir = ctx.config.gto.working_dir
with ctx.cd(working_dir):
return ctx.run(*run_args, **run_kwargs)
use_pty
cached
⚓︎
use_pty()
Returns False on Windows and some CI environments.
Source code in calcipy/invoke_helpers.py
@lru_cache(maxsize=1)
def use_pty() -> bool:
"""Returns False on Windows and some CI environments."""
if platform.system() == 'Windows':
return False
return not environ.get('GITHUB_ACTION')