summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2011-11-28 21:27:40 +0100
committerFlorent Le Coz <louiz@louiz.org>2012-01-26 10:05:32 +0100
commita1575237fd0de77e0d623204eae2c369d8d32b2a (patch)
tree049c939c58ac8e7eab83e1042ed8f878a098a202 /src
parent73ca8ddca00ff5eb14aa13dbf07bc1bd8d5a1b43 (diff)
downloadpoezio-a1575237fd0de77e0d623204eae2c369d8d32b2a.tar.gz
poezio-a1575237fd0de77e0d623204eae2c369d8d32b2a.tar.bz2
poezio-a1575237fd0de77e0d623204eae2c369d8d32b2a.tar.xz
poezio-a1575237fd0de77e0d623204eae2c369d8d32b2a.zip
Python 3.0/.1 compatibility
Diffstat (limited to 'src')
-rw-r--r--src/bookmark.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/bookmark.py b/src/bookmark.py
index dbd8855a..45616d93 100644
--- a/src/bookmark.py
+++ b/src/bookmark.py
@@ -1,9 +1,16 @@
import os
+from sys import version_info
from sleekxmpp.plugins.xep_0048 import *
from core import JID
from config import config
+def iter(xml, tag=''):
+ if version_info[1] >= 2:
+ return xml.iter(tag)
+ else:
+ return xml.getiterator(tag)
+
preferred = config.get('use_bookmarks_method', 'pep').lower()
if preferred not in ('pep', 'privatexml'):
preferred = 'privatexml'
@@ -73,10 +80,10 @@ class Bookmark(object):
name = el.get('name')
autojoin = True if el.get('autojoin', False) == 'true' else False
nick = None
- for n in el.iter('nick'):
+ for n in iter(el, 'nick'):
nick = nick.text
password = None
- for p in el.iter('password'):
+ for p in iter(el, 'password'):
password = p.text
return Bookmark(jid, name, autojoin, nick, password, method)
@@ -150,7 +157,7 @@ def get_pep(xmpp):
iq = xmpp.plugin['xep_0048'].get_bookmarks()
except:
return False
- for conf in iq.xml.iter('{storage:bookmarks}conference'):
+ for conf in iter(iq.xml, '{storage:bookmarks}conference'):
b = Bookmark.parse_from_element(conf, method='pep')
if not get_by_jid(b.jid):
bookmarks.append(b)
@@ -162,7 +169,7 @@ def get_privatexml(xmpp):
iq = xmpp.plugin['xep_0048'].get_bookmarks_old()
except:
return False
- for conf in iq.xml.iter('{storage:bookmarks}conference'):
+ for conf in iter(iq.xml, '{storage:bookmarks}conference'):
b = Bookmark.parse_from_element(conf, method='privatexml')
if not get_by_jid(b.jid):
bookmarks.append(b)