summaryrefslogtreecommitdiff
path: root/sleekxmpp/roster
diff options
context:
space:
mode:
authorNathan Fritz <fritzy@netflint.net>2011-08-18 00:35:37 -0700
committerNathan Fritz <fritzy@netflint.net>2011-08-18 00:35:37 -0700
commit4ea22ff69bac4b619b1eeb918c67a209f6e953ee (patch)
treecc4a245ea03429d59b192cb3f79b3bee95343ba8 /sleekxmpp/roster
parent3853898ab36fa1a74b5d9d5ea3070c3e8e1bc0f2 (diff)
parent7d8aa4157bc7a602243996a45268b172629a6ae3 (diff)
downloadslixmpp-4ea22ff69bac4b619b1eeb918c67a209f6e953ee.tar.gz
slixmpp-4ea22ff69bac4b619b1eeb918c67a209f6e953ee.tar.bz2
slixmpp-4ea22ff69bac4b619b1eeb918c67a209f6e953ee.tar.xz
slixmpp-4ea22ff69bac4b619b1eeb918c67a209f6e953ee.zip
Merge branch 'develop' of github.com:fritzy/SleekXMPP into develop
Diffstat (limited to 'sleekxmpp/roster')
-rw-r--r--sleekxmpp/roster/single.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/sleekxmpp/roster/single.py b/sleekxmpp/roster/single.py
index deb1ac8b..c2a73d34 100644
--- a/sleekxmpp/roster/single.py
+++ b/sleekxmpp/roster/single.py
@@ -75,6 +75,10 @@ class RosterNode(object):
self.add(key, save=True)
return self._jids[key]
+ def __len__(self):
+ """Return the number of JIDs referenced by the roster."""
+ return len(self._jids)
+
def keys(self):
"""Return a list of all subscribed JIDs."""
return self._jids.keys()
@@ -83,6 +87,16 @@ class RosterNode(object):
"""Returns whether the roster has a JID."""
return jid in self._jids
+ def groups(self):
+ """Return a dictionary mapping group names to JIDs."""
+ result = {}
+ for jid in self._jids:
+ for group in self._jids[jid]['groups']:
+ if group not in result:
+ result[group] = []
+ result[group].append(jid)
+ return result
+
def __iter__(self):
"""Iterate over the roster items."""
return self._jids.__iter__()
@@ -204,10 +218,8 @@ class RosterNode(object):
iq['roster']['items'] = {jid: {'name': name,
'subscription': subscription,
'groups': groups}}
- response = iq.send(block, timeout, callback)
- if response in [False, None] or isinstance(response, Iq):
- return response
- return response and response['type'] == 'result'
+
+ return iq.send(block, timeout, callback)
def presence(self, jid, resource=None):
"""