Модуль позволяет работат с контактами
>>> import contacts
>>> db = contacts.open()
contacts.
open
([filename, mode])filename – путь к файлу справочника
mode – режим открытия (c - создать, n - новый)
Возвращает объект ContactDb()
. По дефолту открывает стандартный справочник смартфона.
contacts.
ContactDb
Объект, база данных контактов
ContactDb.
add_contact
()Возвращает объект новый объект Contact
ContactDb.
find
(searchterm)Поиск контаков которые содержат searcterm, возвращает список
ContactDb.
import_vcards
(vcards)Импорт карточек
ContactDb.
export_vcards
(ids)Експорт контакта с номером id в карточку, возвращает строку
ContactDb.
keys
()Возвращает список ID контактов, объектов Contact.
ContactDb.
compact_required
()Verifies whether compacting is recommended. Returns an integer value indicating either a true or false state. Returns True if more than 32K of space is unused and if this comprises more than 50 percent of the database file, or if more than 256K is wasted in the database file.
ContactDb.
compact
()Compacts the database to its minimum size.
ContactDb.
field_types
()Возвращает список словарей который содержит информацию обо всех филдах.
ContactDb.
groups
()Список объектов Groups
групп контактов
contacts.
Contact
Contact.
begin
()Блокирует изменение контакта текущими приложениями.
Contact.
commit
()Освобождвает блокировку и сохраняет изменения
Contact.
rollback
()Освобождает блокировку и откатывает изменения
Contact.
as_vcard
()Возвращает строку контакта в формате карточки.
Contact.
add_field
(type [, value [, label=field label ][, location=location spec ]])type –
city
company_name
country
date
dtmf_string
email_address
extended_address
fax_number
first_name
job_title
last_name
mobile_number
note
pager_number
phone_number
po_box
postal_address
postal_code
state
street_address
url
video_number
picture
second_name
voip
sip_id
personal_ringtone
share_view
prefix
suffix
push_to_talk
locationid_indication
The following field types are recognized but cannot be created at present:
first_name_reading
last_name_reading
speed_dial
thumbnail_image
voice_tag
wvid
Добавляет новый филд контакту.
Contact.
find
([type=field type ][, location=field location ])Возвращает список фидов контакта. Если параметры не заданы, то возвращает все фиды.
db[7].find()
Contact.
id
Возвращает уникальный номер контакта, id. Только для чтения
Contact.
title
Возвращает имя абонента. Только для чтения
Contact.
last_modified
Возвращает дату последнего измененения контакта. Только для чтения
Contact.
is_group
Возвращает 1 если контакт состоит в группе. Только для чтения
contacts.
ContactField
ContactField.
label
Отображаемый текст фида.
ContactField.
value
Значение фида
ContactField.
type
Тип фида
ContactField.
location
Параметр соответствует типу номера - обычный (none), домашний (‘home’), служебный (‘work’)
ContactField.
schema
A dictionary that contains some properties of this field. The contents of this dictionary correspond to those returned by the ContactDb method field_types.
contacts.
Groups
Groups.
add_group
([name])Добавляет новую группу
contacts.
Group
Group.
id
Возвращает id группы
Group.
name
Возвращает название группы
import contacts
db = contacts.open()
del db[contact.id]