Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/python-nbxmpp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Hörist <philipp@hoerist.com>2019-06-29 11:59:48 +0300
committerPhilipp Hörist <philipp@hoerist.com>2019-06-29 11:59:48 +0300
commitf57bd1aef78ee7ddb37045efe7fc81434a2c2114 (patch)
treeb151e044015161f37b3c49a12ec030f5f9944d4d /nbxmpp/structs.py
parentf9532825b89abf55d6d41a0b7aa50c91dd4c9250 (diff)
Add method and tests for entity caps hash computation
Diffstat (limited to 'nbxmpp/structs.py')
-rw-r--r--nbxmpp/structs.py25
1 files changed, 23 insertions, 2 deletions
diff --git a/nbxmpp/structs.py b/nbxmpp/structs.py
index c33f422..6f7ac29 100644
--- a/nbxmpp/structs.py
+++ b/nbxmpp/structs.py
@@ -113,14 +113,35 @@ IBBData = namedtuple('IBBData', 'block_size sid seq type data')
IBBData.__new__.__defaults__ = (None, None, None, None, None)
DiscoInfo = namedtuple('DiscoInfo', 'jid node identities features dataforms')
-DiscoIdentity = namedtuple('DiscoIdentity', 'category type name lang')
-DiscoIdentity.__new__.__defaults__ = (None, None)
DiscoItems = namedtuple('DiscoItems', 'jid node items')
DiscoItem = namedtuple('DiscoItem', 'jid name node')
DiscoItem.__new__.__defaults__ = (None, None)
+class DiscoIdentity(namedtuple('DiscoIdentity', 'category type name lang')):
+
+ __slots__ = []
+
+ def __new__(cls, category, type, name=None, lang=None):
+ return super(DiscoIdentity, cls).__new__(cls, category, type, name, lang)
+
+ def __eq__(self, other):
+ return str(self) == str(other)
+
+ def __ne__(self, other):
+ return not self.__eq__(other)
+
+ def __str__(self):
+ return '%s/%s/%s/%s' % (self.category,
+ self.type,
+ self.lang or '',
+ self.name or '')
+
+ def __hash__(self):
+ return hash(str(self))
+
+
class AdHocCommand(namedtuple('AdHocCommand', 'jid node name sessionid status data actions notes')):
__slots__ = []