summaryrefslogtreecommitdiff
path: root/sleekxmpp/plugins/xep_0030/stanza/info.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2012-01-05 11:33:47 -0500
committerLance Stout <lancestout@gmail.com>2012-01-05 11:33:47 -0500
commit8fd2efa2fa50751af7b5182ad7793295c540d294 (patch)
tree7639768de4d93b00e998f3575b02830b2ac97b44 /sleekxmpp/plugins/xep_0030/stanza/info.py
parent79f1aa0e1ba7dd29bf597beeae924b96950f9416 (diff)
parent6b6995bb0b80c91eda72bc92974f68133cef93a3 (diff)
downloadslixmpp-8fd2efa2fa50751af7b5182ad7793295c540d294.tar.gz
slixmpp-8fd2efa2fa50751af7b5182ad7793295c540d294.tar.bz2
slixmpp-8fd2efa2fa50751af7b5182ad7793295c540d294.tar.xz
slixmpp-8fd2efa2fa50751af7b5182ad7793295c540d294.zip
Merge branch 'develop-1.1' into develop
Diffstat (limited to 'sleekxmpp/plugins/xep_0030/stanza/info.py')
-rw-r--r--sleekxmpp/plugins/xep_0030/stanza/info.py36
1 files changed, 25 insertions, 11 deletions
diff --git a/sleekxmpp/plugins/xep_0030/stanza/info.py b/sleekxmpp/plugins/xep_0030/stanza/info.py
index 6764acbb..25d1d07f 100644
--- a/sleekxmpp/plugins/xep_0030/stanza/info.py
+++ b/sleekxmpp/plugins/xep_0030/stanza/info.py
@@ -146,7 +146,7 @@ class DiscoInfo(ElementBase):
return True
return False
- def get_identities(self, lang=None):
+ def get_identities(self, lang=None, dedupe=True):
"""
Return a set of all identities in tuple form as so:
(category, type, lang, name)
@@ -155,17 +155,25 @@ class DiscoInfo(ElementBase):
that language.
Arguments:
- lang -- Optional, standard xml:lang value.
+ lang -- Optional, standard xml:lang value.
+ dedupe -- If True, de-duplicate identities, otherwise
+ return a list of all identities.
"""
- identities = set()
+ if dedupe:
+ identities = set()
+ else:
+ identities = []
for id_xml in self.findall('{%s}identity' % self.namespace):
xml_lang = id_xml.attrib.get('{%s}lang' % self.xml_ns, None)
if lang is None or xml_lang == lang:
- identities.add((
- id_xml.attrib['category'],
- id_xml.attrib['type'],
- id_xml.attrib.get('{%s}lang' % self.xml_ns, None),
- id_xml.attrib.get('name', None)))
+ id = (id_xml.attrib['category'],
+ id_xml.attrib['type'],
+ id_xml.attrib.get('{%s}lang' % self.xml_ns, None),
+ id_xml.attrib.get('name', None))
+ if dedupe:
+ identities.add(id)
+ else:
+ identities.append(id)
return identities
def set_identities(self, identities, lang=None):
@@ -237,11 +245,17 @@ class DiscoInfo(ElementBase):
return True
return False
- def get_features(self):
+ def get_features(self, dedupe=True):
"""Return the set of all supported features."""
- features = set()
+ if dedupe:
+ features = set()
+ else:
+ features = []
for feature_xml in self.findall('{%s}feature' % self.namespace):
- features.add(feature_xml.attrib['var'])
+ if dedupe:
+ features.add(feature_xml.attrib['var'])
+ else:
+ features.append(feature_xml.attrib['var'])
return features
def set_features(self, features):