Add a parser from xml Element to Bookmark

This commit is contained in:
mathieui 2011-11-26 23:06:11 +01:00
parent 64b8970d25
commit 2f5ecf24b7

View file

@ -56,3 +56,20 @@ class Bookmark(object):
p.text = self.password
el.append(p)
return el
def parse_from_element(el, method=None):
"""
Generate a Bookmark object from a <conference/> element
"""
jid = el.get('jid')
name = el.get('name')
autojoin = True if el.get('autojoin', False) == 'true' else False
nick = None
for n in el.iter('nick'):
nick = nick.text
password = None
for p in el.iter('password'):
password = p.text
return Bookmark(jid, name, autojoin, nick, password, method)