khard.address_book module¶
A simple class to load and manage the vcard files from disk.
-
class
khard.address_book.
AddressBook
(name, private_objects=(), localize_dates=True, skip=False)¶ Bases:
object
The base class of all address book implementations.
-
get_short_uid
(uid)¶ Get the shortend UID for the given UID.
Parameters: uid (str) – the full UID to shorten Returns: the shortend uid or the empty string Return type: str
-
get_short_uid_dict
(query=None)¶ Create a dictionary of shortend UIDs for all contacts.
All arguments are only used if the address book is not yet initialized and will just be handed to self.load().
Parameters: query (str) – see self.load() Returns: the contacts mapped by the shortes unique prefix of their UID Return type: dict(str: CarddavObject)
-
load
(query=None)¶ Load the vCards from the backing store.
If a query is given loading is limited to entries which match the query. If the query is None all entries will be loaded.
Parameters: query (str) – the query to limit loading to matching entries Returns: the number of loaded contacts and the number of errors Return type: (int, int)
-
search
(query, method='all')¶ Search this address book for contacts matching the query.
The method can be one of “all”, “name” and “uid”. The backend for this address book migth be load()ed if needed.
Parameters: - query (str) – the query to search for
- method (str) – the type of fileds to use when seaching
Returns: all found contacts
Return type:
-
-
class
khard.address_book.
AddressBookCollection
(name, abooks, **kwargs)¶ Bases:
khard.address_book.AddressBook
A collection of several address books.
This represents a temporary merege of the contact collections provided by the underlying adress books. On load all contacts from all subadressbooks are copied into a dict in this address book. This allow this class to use all other methods from the parent AddressBook class.
-
get_abook
(name)¶ Get one of the backing abdress books by its name,
Parameters: name (str) – the name of the address book to get Returns: the matching address book or None Return type: AddressBook or NoneType
-
load
(query=None)¶ Load the vCards from the backing store.
If a query is given loading is limited to entries which match the query. If the query is None all entries will be loaded.
Parameters: query (str) – the query to limit loading to matching entries Returns: the number of loaded contacts and the number of errors Return type: (int, int)
-
-
exception
khard.address_book.
AddressBookParseError
(filename, abook, reason, *args, **kwargs)¶ Bases:
Exception
Indicate an error while parsing data from an address book backend.
-
class
khard.address_book.
VdirAddressBook
(name, path, **kwargs)¶ Bases:
khard.address_book.AddressBook
An AddressBook implementation based on a vdir.
This address book can load contacts from vcard files that reside in one direcotry on disk.
-
load
(query=None, search_in_source_files=False)¶ Load all vcard files in this address book from disk.
If a search string is given only files which contents match that will be loaded.
Parameters: - query (str) – a regular expression to limit the results
- search_in_source_files (bool) – apply search regexp directly on the .vcf files to speed up parsing (less accurate)
Returns: the number of successfully loaded cards and the number of errors
Return type: int, int
Throws: AddressBookParseError
-