:mod:`khard.formatter` ====================== .. py:module:: khard.formatter .. autoapi-nested-parse:: Formatting and sorting of contacts Module Contents --------------- .. py:class:: Formatter(display: str, preferred_email: List[str], preferred_phone: List[str], show_nicknames: bool) A formtter for CarddavObject. It recieves some settings on initialisation which influence the formatting of the contact. .. method:: format_labeled_field(field, preferred) :staticmethod: Format a labeled field from a vcard for display, the first entry under the preferred label will be returned :param dict(str:list(str)) field: the labeled field :param list(str) preferred: the order of preferred labels :returns: the formatted field entry :rtype: str .. method:: get_special_field(self, vcard: CarddavObject, field: str) Returns certain fields with specific formatting options (for support of some list command options). .. method:: get_nested_field(vcard: CarddavObject, field: str) :staticmethod: Returns the value of a nested field from a string get_nested_field(vcard,'emails.home.1') is equivalent to vcard.emails['home'][1]. :param vcard: the contact from which to get the field :param field: a field specification :returns: the nested field, or the empty string if it didn't exist