khard.helpers module

Some helper functions for khard

khard.helpers.convert_to_yaml(name, value, indentation, index_of_colon, show_multi_line_character)

converts a value list into yaml syntax

Parameters:
  • name (str) – name of object (example: phone)
  • value (str, list(str), list(list(str)), list(dict)) – object contents
  • indentation (int) – indent all by number of spaces
  • index_of_colon (int) – use to position : at the name string (-1 for no space)
  • show_multi_line_character (bool) – option to hide “|”
Returns:

yaml formatted string array of name, value pair

Return type:

list(str)

khard.helpers.file_modification_date(filename)
khard.helpers.get_new_contact_template(supported_private_objects=None)
khard.helpers.get_random_uid()
khard.helpers.indent_multiline_string(input, indentation, show_multi_line_character)
khard.helpers.list_to_string(input, delimiter)

converts list to string recursively so that nested lists are supported

Parameters:
  • input (list) – a list of strings and lists of strings (and so on recursive)
  • delimiter (str) – the deimiter to use when joining the items
Returns:

the recursively joined list

Return type:

str

khard.helpers.pretty_print(table, justify='L')
khard.helpers.string_to_date(string)

Convert a date string into a date object.

Parameters:string (str) – the date string to parse
Returns:the parsed datetime object
Return type:datetime.datetime
khard.helpers.string_to_list(input, delimiter)