[Vobject] reading vCard extracting type_param
Jeffrey Harris
jeffrey at osafoundation.org
Mon Apr 14 15:55:16 CDT 2008
Hi Neil,
> Sorry on two fronts – I cannot figure out how to keep my responses in
> the thread! Do I respond to the email / change the subject line?
Hmm, I'm not sure what you mean. Your responses look fine to me.
> So, as a follow-up, I can read in a vCard (readOne etc.) and get most of
> what I want. Then, if I iterate the vCard (via Python, not via an
> iterable function within the vObject module), and run the
> textLineToContentLine parm on each line, I can gather the data I want on
> each TEL line item, match it up to the tel_list contents, and voila. I
> KNOW I am probably doing that wrong, but in it does accomplish what I want.
Hmm. Sorry, I confused you with what I sent, apparently.
textLineToContentLine was just a way for me to describe what I was
working from, it converts a string into a vobject ContentLine.
If you use readOne, it'll convert a stream into ContentLines for you.
So, if you're reading in a vCard, you might do something like:
>>> j = vobject.readOne(f)
>>> for tel in j.tel_list:
... if "cell" in tel.singletonparams:
... # do your logic for the cell number
If you're creating a vCard, you should just do:
>>> card = vobject.vCard()
>>> tel = card.add("tel")
>>> tel.value = "555-5555"
>>> tel.type_param = "cell"
Sincerely,
Jeffrey
More information about the VObject
mailing list