| Trees | Indices | Help |
|
|---|
|
|
1 import vobject 2 import conduit.datatypes.DataType as DataType4 """ 5 Parses a vcf string, potentially containing many vcards 6 @returns: A list of Contacts 7 """ 8 contacts = [] 9 for vobj in vobject.readComponents(string): 10 if vobj.behavior == vobject.vcard.VCard3_0: 11 contacts.append(Contact(vcard=vobj)) 12 return contacts1315 """ 16 Very basic contact representation 17 @keyword vcard: A vobject.vcard.VCard3_0 instance 18 """ 19 _name_ = "contact"9021 DataType.DataType.__init__(self) 22 self.vcard = kwargs.get('vcard',vobject.vCard()) 23 self.set_name(**kwargs)24 2729 for prop in ('fn', 'n'): 30 if prop not in self.vcard.contents: 31 self.vcard.add(prop) 32 return self.vcard.serialize()3335 emails = [] 36 if 'email' in self.vcard.contents: 37 for email in self.vcard.contents['email']: 38 emails.append(email.value) 39 return emails4042 #In order of preference, 1)formatted name, 2)name, 3)"" 43 #FIXME: Return dict of formattedName, givenName, familyName, etc 44 for attr in [self.vcard.fn, self.vcard.n]: 45 #because str() on a vobject.vcard.Name pads with whitespace 46 name = str(attr.value).strip() 47 if len(name) > 0: 48 return name 49 return ""5052 #vcards must have one, and only one N and FN 53 fn = kwargs.get("formattedName","") 54 try: 55 self.vcard.fn 56 except AttributeError: 57 self.vcard.add('fn') 58 if fn: 59 self.vcard.fn.value = fn 60 61 g = kwargs.get("givenName","") 62 f = kwargs.get("familyName","") 63 try: 64 self.vcard.n 65 except AttributeError: 66 self.vcard.add('n') 67 if f or g: 68 self.vcard.n.value = vobject.vcard.Name(family=f,given=g)6971 for address in args: 72 email = self.vcard.add('email') 73 email.value = address 74 email.type_param = 'INTERNET'7577 data = DataType.DataType.__getstate__(self) 78 data['vcard'] = self.get_vcard_string() 79 return data80 8486 return "Name: %s" % self.get_name()8789 return hash(self.get_vcard_string())
| Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0beta1 on Sat Aug 2 22:18:48 2008 | http://epydoc.sourceforge.net |