utils¶
- otto.utils.split_on_commas(values: list[str] | str) list[str]¶
Split a string or list of strings on commas into a flat list.
- Parameters:¶
values – A single comma-separated string, or a list of such strings.
- Returns:¶
A flat list of the individual values.
>>> split_on_commas("a,b,c") ['a', 'b', 'c'] >>> split_on_commas(["a,b", "c,d"]) ['a', 'b', 'c', 'd'] >>> split_on_commas("single") ['single']
-
class otto.utils.Arg(variadic: bool =
False, elem_type: type | None =None, name: str | None =None, help: str | None =None)¶ Bases:
objectCLI overlay: force a parameter to a positional argument.
variadic=Truemakes it a space-separated list ofelem_type(used for Python-union list params Typer can’t read, e.g.str | Sequence[...]).elem_typealso overrides the CLI type for a scalar union. Imports no typer.
-
class otto.utils.Opt(elem_type: type | None =
None, name: str | None =None, help: str | None =None)¶ Bases:
objectCLI overlay: force a parameter to a
--option. Imports no typer.
-
otto.utils.cli_exposed(fn=
None, *, name: str | None =None, help: str | None =None, success: str | None =None)¶ Mark a host coroutine method for auto-exposure as an
otto hostsubcommand.namedefaults to the method name with underscores dashed.successis an optional message printed on a successful(Status, "")result (e.g. “Transfer complete.”).Usable bare (
@cli_exposed) or called (@cli_exposed(name=..., ...)).
- otto.utils.is_literal(value: Any, literal_type: type[T]) T¶
Raise a TypeError if value is not a valid member of the Literal type.
- class otto.utils.Status(value)¶
Bases:
EnumGeneral status enum for commands and tests.
>>> Status.Success <Status.Success: 0> >>> Status.Failed <Status.Failed: 1> >>> Status(0) is Status.Success True-
Success =
0¶
-
Failed =
1¶
-
Error =
2¶
-
Unstable =
3¶
-
Skipped =
4¶
-
Success =