Module vcard
[hide private]
[frames] | no frames]

Module vcard

source code

Code for reading and writing Vcard

VCARD is defined in RFC 2425 and 2426

Classes [hide private]
  VFileException
  VFile
  VCards
Understands vcards in a vfile
  VCard
A single vcard
Functions [hide private]
 
myqpencodestring(value)
My own routine to do qouted printable since the builtin one doesn't encode CR or NL!
source code
 
format_stringv2(value)
Return a vCard v2 string.
source code
 
format_stringv3(value)
Return a vCard v3 string.
source code
 
format_binary(value)
Return base 64 encoded string
source code
 
_is_sequence(v)
Determine if v is a sequence such as passed to value in out_line.
source code
 
out_line(name, attributes, value, formatter, join_char=';')
Returns a single field correctly formatted and encoded (including trailing newline)
source code
 
_line_reformat(line, width=70, firstlinewidth=0)
Takes line string and inserts newlines and spaces on following continuation lines so it all fits in width characters
source code
 
out_names(vals, formatter, limit=1) source code
 
out_categories(vals, formatter, field='CATEGORIES') source code
 
out_categories_apple(vals, formatter) source code
 
out_eu(vals, formatter, field, bpkey) source code
 
out_emails(vals, formatter) source code
 
out_urls(vals, formatter) source code
 
out_tel(vals, formatter) source code
 
out_adr(vals, formatter) source code
 
out_note(vals, formatter, limit=1) source code
 
out_tel_scp6600(vals, formatter) source code
 
out_email_scp6600(vals, formatter) source code
 
out_url_scp660(vals, formatter) source code
 
out_adr_scp6600(vals, formatter) source code
 
output_entry(entry, profile, limit_fields=None) source code
Variables [hide private]
  _string_formatters = format_stringv2, format_stringv3
  _out_tel_mapping = {'cell': 'CELL', 'data': 'MODEM', 'fax': 'F...
  _field_order = ('names', 'wallpapers', 'addresses', 'numbers',...
  profile_vcard2 = {'_formatter': format_stringv2, '_limit': 1, ...
  profile_vcard3 = profile_vcard2.copy()
  profile_apple = profile_vcard3.copy()
  profile_full = profile_vcard3.copy()
  profile_scp6600 = profile_full.copy()
  profiles = {'apple': {'description': 'Apple', 'profile': {'_fo...
Function Details [hide private]

format_stringv2(value)

source code 

Return a vCard v2 string. Any embedded commas or semi-colons are removed.

format_stringv3(value)

source code 

Return a vCard v3 string. Embedded commas and semi-colons are backslash quoted

_is_sequence(v)

source code 

Determine if v is a sequence such as passed to value in out_line. Note that a sequence of chars is not a sequence for our purposes.

out_line(name, attributes, value, formatter, join_char=';')

source code 

Returns a single field correctly formatted and encoded (including trailing newline)

Parameters:
  • name - The field name
  • attributes - A list of string attributes (eg "TYPE=intl,post" ). Usually empty except for TEL and ADR. You can also pass in None.
  • value - The field value. You can also pass in a list of components which will be joined with join_char such as the 6 components of N
  • formatter - The function that formats the value/components. See the various format_ functions. They will automatically ensure that ENCODING=foo attributes are added if appropriate

_line_reformat(line, width=70, firstlinewidth=0)

source code 

Takes line string and inserts newlines and spaces on following continuation lines so it all fits in width characters

Parameters:
  • width - how many characters to fit it in
  • firstlinewidth - if >0 then first line is this width. if equal to zero then first line is same width as rest. if <0 then first line will go immediately to continuation.

Variables Details [hide private]

_out_tel_mapping

Value:
{'cell': 'CELL',
 'data': 'MODEM',
 'fax': 'FAX',
 'home': 'HOME',
 'none': 'VOICE',
 'office': 'WORK',
 'pager': 'PAGER'}

_field_order

Value:
('names',
 'wallpapers',
 'addresses',
 'numbers',
 'categories',
 'emails',
 'urls',
 'ringtones',
...

profile_vcard2

Value:
{'_formatter': format_stringv2, '_limit': 1, '_version': "2.1", 'names\
': out_names, 'categories': out_categories, 'emails': out_emails, 'url\
s': out_urls, 'numbers': out_tel, 'addresses': out_adr, 'memos': out_n\
ote,}

profiles

Value:
{'apple': {'description': 'Apple',
           'profile': {'_formatter': <function format_stringv3 at 0x03\
9D3C70>,
                       '_limit': 1,
                       '_version': '3.0',
                       'addresses': <function out_adr at 0x039D3F70>,
                       'categories': <function out_categories_apple at\
 0x039D3E30>,
...