# HG changeset patch # User Goffi # Date 1432746758 -7200 # Node ID 9a4c367b22bbd3f09589badb21cc9d7492785718 # Parent a07bf3fb4b548cf4ada9c5216fb58c0a02862be8 tmp (rsm): better use of domish.Element.elements() + minor fixes diff -r a07bf3fb4b54 -r 9a4c367b22bb wokkel/rsm.py --- a/wokkel/rsm.py Thu Apr 23 14:19:43 2015 +0200 +++ b/wokkel/rsm.py Wed May 27 19:12:38 2015 +0200 @@ -94,9 +94,7 @@ @rtype: L{RSMRequest} """ try: - set_elt = domish.generateElementsQNamed(element.elements(), - name="set", - uri=NS_RSM).next() + set_elt = element.elements(NS_RSM, 'set').next() except StopIteration: raise RSMNotFoundError() @@ -194,9 +192,7 @@ @rtype: L{RSMResponse} """ try: - set_elt = domish.generateElementsQNamed(element.elements(), - name="set", - uri=NS_RSM).next() + set_elt = element.elements(NS_RSM, 'set').next() except StopIteration: return RSMNotFoundError() @@ -331,9 +327,8 @@ def cb(iq): items = [] if iq.pubsub.items: - for element in iq.pubsub.items.elements(): - if element.uri == pubsub.NS_PUBSUB and element.name == 'item': - items.append(element) + for element in iq.pubsub.items.elements(pubsub.NS_PUBSUB, 'item'): + items.append(element) if request.rsm: response = RSMResponse.parse(iq.pubsub) @@ -345,21 +340,20 @@ d.addCallback(cb) return d - def getRSMResponse(self, id): - """ - Post-retrieve the RSM response data after items retrieval is done. + def getRSMResponse(self, id_): + """Post-retrieve the RSM response data after items retrieval is done. - @param id: extension data ID - @type id: C{unicode} + @param id_: extension data ID + @type id_: C{unicode} @return: dict representation of the RSM response. @rtype: C{dict} of C{unicode} """ # This method exists to not modify the return value of self.items. - if id not in self._rsm_responses: + if id_ not in self._rsm_responses: return {} - result = self._rsm_responses[id].toDict() - del self._rsm_responses[id] + result = self._rsm_responses[id_].toDict() + del self._rsm_responses[id_] return result