utils¶
- otto.utils.split_on_commas(values)¶
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.
- Return type:¶
list[str]- 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=
False, elem_type=None, name=None, help=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.-
variadic : --is-rst--:py:class:`bool` =
False¶
-
elem_type : --is-rst--:py:class:`type` | :py:obj:`None` =
None¶
-
name : --is-rst--:py:class:`str` | :py:obj:`None` =
None¶
-
help : --is-rst--:py:class:`str` | :py:obj:`None` =
None¶
-
variadic : --is-rst--:py:class:`bool` =
-
class otto.utils.Opt(elem_type=
None, name=None, help=None)¶ Bases:
objectCLI overlay: force a parameter to a
--option. Imports no typer.-
elem_type : --is-rst--:py:class:`type` | :py:obj:`None` =
None¶
-
name : --is-rst--:py:class:`str` | :py:obj:`None` =
None¶
-
help : --is-rst--:py:class:`str` | :py:obj:`None` =
None¶
-
elem_type : --is-rst--:py:class:`type` | :py:obj:`None` =
-
otto.utils.cli_exposed(fn=
None, *, name=None, help=None, success=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, literal_type)¶
Raise a TypeError if value is not a valid member of the Literal type.
- Return type:¶
TypeVar(T)
- 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¶
- property is_ok : bool¶
True for statuses that should be treated as passing (Success, Skipped).
-
Success =
- class otto.utils.CommandStatus(command: str, output: str, status: Status, retcode: int)¶
Bases:
NamedTupleResult of a command execution on a host.
>>> result = CommandStatus("echo hi", "hi", Status.Success, 0) >>> result.status <Status.Success: 0> >>> result.retcode 0- command : --is-rst--:py:class:`str`¶
Command that was issued
- output : --is-rst--:py:class:`str`¶
Command output
- status : --is-rst--:py:class:`~otto.utils.Status`¶
Command status
- retcode : --is-rst--:py:class:`int`¶
Command shell retcode