From 2f5ecf24b7d4394901389a0ab2f2fe1fd9c37114 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sat, 26 Nov 2011 23:06:11 +0100 Subject: Add a parser from xml Element to Bookmark --- src/bookmark.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src') diff --git a/src/bookmark.py b/src/bookmark.py index 8b4fed27..66a89830 100644 --- a/src/bookmark.py +++ b/src/bookmark.py @@ -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 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) + -- cgit v1.2.3