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
path: root/nbxmpp
diff options
context:
space:
mode:
authorlovetox <philipp@hoerist.com>2020-04-13 17:21:52 +0300
committerlovetox <philipp@hoerist.com>2020-04-13 17:21:52 +0300
commit8016441c9981d48e14b555101275d6199796ad98 (patch)
tree21ab08606580f28e164b0735923844ab996f279f /nbxmpp
parentcbfb6e15f4dd21a809961d4e534a58628decb5f5 (diff)
JID: Refactor some methods
Diffstat (limited to 'nbxmpp')
-rw-r--r--nbxmpp/protocol.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/nbxmpp/protocol.py b/nbxmpp/protocol.py
index 7f57a30..36580f2 100644
--- a/nbxmpp/protocol.py
+++ b/nbxmpp/protocol.py
@@ -881,13 +881,13 @@ class JID:
"""
Return the bare representation of JID. I.e. string value w/o resource
"""
- return self.__str__(0)
+ return '%s@%s' % (self.node, self.domain)
def getBare(self):
"""
Return the bare representation of JID. I.e. string value w/o resource
"""
- return self.__str__(0)
+ return '%s@%s' % (self.node, self.domain)
def setBare(self):
"""
@@ -931,18 +931,26 @@ class JID:
"""
Compare the node and domain parts of the JID's for equality
"""
- return self.__str__(0) == JID(other).__str__(0)
+ if not isinstance(other, JID):
+ try:
+ other = JID(other)
+ except Exception:
+ return False
+
+ return (self.node == other.node and
+ self.domain == other.domain)
- def __str__(self, wresource=1):
+ def __str__(self):
"""
Serialise JID into string
"""
if self.node:
- jid = self.node + '@' + self.domain
+ jid = '%s@%s' % (self.node, self.domain)
else:
jid = self.domain
- if wresource and self.resource:
- return jid + '/' + self.resource
+
+ if self.resource:
+ return '%s/%s' % (jid, self.resource)
return jid
def __hash__(self):