Download taskweaver/cli/util.py from TRaw/tskwvr: direct link, hf CLI and curl.
- Browser
- Download file 1.64 kB
-
https://huggingface.co/spaces/TRaw/tskwvr/resolve/main/taskweaver/cli/util.py
- Command line
-
hf download hf://spaces/TRaw/tskwvr/taskweaver/cli/util.py
-
curl -L -o util.py https://huggingface.co/spaces/TRaw/tskwvr/resolve/main/taskweaver/cli/util.py
1.64 kB
| from dataclasses import dataclass | |
| from functools import wraps | |
| from textwrap import dedent | |
| from typing import Any, Callable, Optional | |
| import click | |
| def require_workspace(): | |
| def require_workspace_inner(f: Callable[..., None]): | |
| def new_func(ctx: click.Context, *args: Any, **kwargs: Any): | |
| if ctx.obj.is_workspace_valid: | |
| return ctx.invoke(f, *args, **kwargs) | |
| else: | |
| click.echo( | |
| "The current directory is not a valid Task Weaver project directory. " | |
| "There needs to be a `taskweaver-config.json` in the root of the project directory. " | |
| "Please change the working directory to a valid project directory or initialize a new one. " | |
| "Refer to --help for more information.", | |
| ) | |
| ctx.exit(1) | |
| return new_func | |
| return require_workspace_inner | |
| class CliContext: | |
| workspace: Optional[str] | |
| workspace_param: Optional[str] | |
| is_workspace_valid: bool | |
| is_workspace_empty: bool | |
| def get_ascii_banner() -> str: | |
| return dedent( | |
| r""" | |
| ========================================================= | |
| _____ _ _ __ | |
| |_ _|_ _ ___| | _ | | / /__ ____ __ _____ _____ | |
| | |/ _` / __| |/ /| | /| / / _ \/ __ `/ | / / _ \/ ___/ | |
| | | (_| \__ \ < | |/ |/ / __/ /_/ /| |/ / __/ / | |
| |_|\__,_|___/_|\_\|__/|__/\___/\__,_/ |___/\___/_/ | |
| ========================================================= | |
| """, | |
| ).strip() | |