khard.helpers.typing¶
Helper code for type annotations and runtime type conversion.
Attributes¶
Functions¶
converts user input into vCard compatible data structures |
|
|
converts list to string recursively so that nested lists are supported |
|
|
|
Convert a date string into a date object. |
Module Contents¶
- khard.helpers.typing.Date¶
- khard.helpers.typing.StrList¶
- khard.helpers.typing.PostAddress¶
- khard.helpers.typing.convert_to_vcard(name: str, value: StrList, constraint: type[str]) str¶
- khard.helpers.typing.convert_to_vcard(name: str, value: StrList, constraint: type[list]) list[str]
- khard.helpers.typing.convert_to_vcard(name: str, value: StrList, constraint: None) StrList
converts user input into vCard compatible data structures
- Parameters:
name – object name, only required for error messages
value – user input
constraint – set the accepted return type for vCard attribute
- Returns:
cleaned user input, ready for vCard or a ValueError
- khard.helpers.typing.list_to_string(input: str | list, delimiter: str) str¶
converts list to string recursively so that nested lists are supported
- Parameters:
input – a list of strings and lists of strings (and so on recursive)
delimiter – the delimiter to use when joining the items
- Returns:
the recursively joined list
- khard.helpers.typing.string_to_list(input: str | list[str], delimiter: str) list[str]¶
- khard.helpers.typing.string_to_date(string: str) datetime.datetime¶
Convert a date string into a date object.
- Parameters:
string – the date string to parse
- Returns:
the parsed datetime object