khard.helpers
¶
Some helper functions for khard
Module Contents¶
Functions¶
|
Converts a list of lists into a string formatted like a table |
|
converts list to string recursively so that nested lists are supported |
|
|
|
Convert a date string into a date object. |
|
|
|
|
|
converts a value list into yaml syntax |
|
|
|
- khard.helpers.pretty_print(table: List[List[str]], justify: str = 'L') str ¶
Converts a list of lists into a string formatted like a table with spaces separating fields and newlines separating rows
- khard.helpers.list_to_string(input: Union[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 deimiter to use when joining the items
- Returns
the recursively joined list
- khard.helpers.string_to_list(input: Union[str, List[str]], delimiter: str) List[str] ¶
- khard.helpers.string_to_date(string: str) datetime ¶
Convert a date string into a date object.
- Parameters
string – the date string to parse
- Returns
the parsed datetime object
- khard.helpers.get_random_uid() str ¶
- khard.helpers.file_modification_date(filename: str) datetime ¶
- khard.helpers.convert_to_yaml(name: str, value: Union[None, str, List], indentation: int, index_of_colon: int, show_multi_line_character: bool) List[str] ¶
converts a value list into yaml syntax
- Parameters
name – name of object (example: phone)
value (str, list(str), list(list(str)), list(dict)) – object contents
indentation – indent all by number of spaces
index_of_colon – use to position : at the name string (-1 for no space)
show_multi_line_character – option to hide “|”
- Returns
yaml formatted string array of name, value pair
- khard.helpers.indent_multiline_string(input: Union[str, List], indentation: int, show_multi_line_character: bool) str ¶
- khard.helpers.get_new_contact_template(supported_private_objects: Optional[List[str]] = None) str ¶