Arguments¶
These classes are used internally by Command and CommandSerializer
to serialize its parameters to the format expected by Tor.
Base class¶
- aiostem.utils.argument.KeyTypes¶
All types allowed as a key in a keyword argument.
- aiostem.utils.argument.ValueTypes¶
All types allowed as a value, either for a keyword or a simple string.
alias of
IPv4Address|IPv6Address|IntEnum|StrEnum|int|str
Argument classes¶
- class aiostem.utils.argument.ArgumentKeyword[source]¶
Bases:
BaseArgumentDescribe a keyword argument.
- __init__(key: KeyTypes, value: ValueTypes | None, *, quotes: QuoteStyle = QuoteStyle.AUTO) None[source]¶
Create a new keyword argument.
Important
Both
keyandvaluecannot beNoneat the same time.Note
When value is
None, quotes is enforced toQuoteStyle.NEVER.- Parameters:
key (
KeyTypes) – Key part of the keyword, if any.value (
ValueTypes|None) – Value part of the keyword, if any.
- Raises:
CommandError – when
keyandvalueare bothNone.- Keyword Arguments:
quotes – Tell how to quote the value part when serialized.
- property quotes: QuoteStyle¶
Get the applied quoting style.
- class aiostem.utils.argument.ArgumentString[source]¶
Bases:
BaseArgumentDescribe a string argument.
- __init__(value: ValueTypes, *, safe: bool = False) None[source]¶
Create a new string argument.
- Parameters:
value (
ValueTypes) – Raw string value.- Keyword Arguments:
safe – Whether the caller ensures that the value contains no space.
Note
This value cannot contain spaces.
Helpers¶
- class aiostem.utils.argument.QuoteStyle[source]¶
Bases:
IntEnumSet the type of quote to use.
- NEVER = 0¶
No quote are added around the value, no checks are being performed.
- NEVER_ENSURE = 1¶
No quote are added around the value, check input to ensure that.
- ALWAYS = 2¶
Value is always enclosed with quotes.
- AUTO = 3¶
Automatically determine the quoting style.