[Vobject] How to split name values?
Steffen Siebert
vobject at steffensiebert.de
Tue Jun 10 11:36:38 CDT 2008
Hi,
I'm trying to use vobject to parse vCard files, but have some problems.
How do I get a specific value like given name from the N entry?
>>> import vobject
>>> VCARD =
"BEGIN:VCARD\r\nVERSION:2.1\r\nN:Siebert;Steffen\r\nFN:Steffen
Siebert\r\nEND:VCARD\r\n"
>>> c = vobject.readOne(VCARD)
>>> card.n.value
Traceback (most recent call last):
File "<console>", line 1, in <module>
NameError: name 'card' is not defined
>>> c.n.value
u'Siebert;Steffen'
>>> c.n.given
Traceback (most recent call last):
File "<console>", line 1, in <module>
File
"/home/siebert/workspace/snom8xx/phone/PyLib/vobject-0.6.6-py2.5.egg/vobject/base.py",
line 309, in __getattr__
raise exceptions.AttributeError, name
AttributeError: given
>>> c.n.value.given
Traceback (most recent call last):
File "<console>", line 1, in <module>
AttributeError: 'unicode' object has no attribute 'given'
In vcard.py is some code handling the name parts, but I can't figure out
how to use it.
If there are several TEL entries (like TEL;WORK and TEL;FAX), they are
all merged together as a list. Is there any way to address the FAX value
directly? My current code iterates over the list and compares
singletonparams with "FAX".
Ciao,
Steffen
More information about the VObject
mailing list