diff options
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2015-06-22 01:12:56 +0100 |
---|---|---|
committer | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2015-06-22 01:12:56 +0100 |
commit | 75ba28357220646a8f912b918c9477899b45b928 (patch) | |
tree | 77a2139d774171133c354642e62419763e3cded0 | |
parent | 4afbb0322bb12023631e644671716fb413a32d13 (diff) | |
download | slixmpp-75ba28357220646a8f912b918c9477899b45b928.tar.gz slixmpp-75ba28357220646a8f912b918c9477899b45b928.tar.bz2 slixmpp-75ba28357220646a8f912b918c9477899b45b928.tar.xz slixmpp-75ba28357220646a8f912b918c9477899b45b928.zip |
Store None instead of '' for unset parts of a JID.
-rw-r--r-- | slixmpp/jid.py | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/slixmpp/jid.py b/slixmpp/jid.py index abb8067a..2e23e242 100644 --- a/slixmpp/jid.py +++ b/slixmpp/jid.py @@ -79,7 +79,7 @@ def _validate_node(node): :returns: The local portion of a JID, as validated by nodeprep. """ if node is None: - return '' + return None try: node = nodeprep(node) @@ -160,7 +160,7 @@ def _validate_resource(resource): :returns: The local portion of a JID, as validated by resourceprep. """ if resource is None: - return '' + return None try: resource = resourceprep(resource) @@ -209,12 +209,12 @@ def _format_jid(local=None, domain=None, resource=None): :return: A full or bare JID string. """ result = [] - if local: + if local is not None: result.append(local) result.append('@') - if domain: + if domain is not None: result.append(domain) - if resource: + if resource is not None: result.append('/') result.append(resource) return ''.join(result) @@ -250,11 +250,11 @@ class UnescapedJID: full, or bare. """ if name == 'resource': - return self._resource + return self._resource or '' if name in ('user', 'username', 'local', 'node'): - return self._node + return self._node or '' if name in ('server', 'domain', 'host'): - return self._domain + return self._domain or '' if name in ('full', 'jid'): return _format_jid(self._node, self._domain, self._resource) if name == 'bare': @@ -304,9 +304,9 @@ class JID: def __init__(self, jid=None): if not jid: - self._node = '' - self._domain = '' - self._resource = '' + self._node = None + self._domain = None + self._resource = None elif not isinstance(jid, JID): self._node, self._domain, self._resource = _parse_jid(jid) else: @@ -331,39 +331,39 @@ class JID: @property def node(self): - return self._node + return self._node or '' @property def user(self): - return self._node + return self._node or '' @property def local(self): - return self._node + return self._node or '' @property def username(self): - return self._node + return self._node or '' @property def domain(self): - return self._domain + return self._domain or '' @property def server(self): - return self._domain + return self._domain or '' @property def host(self): - return self._domain + return self._domain or '' @property - def bare(self): - return _format_jid(self._node, self._domain) + def resource(self): + return self._resource or '' @property - def resource(self): - return self._resource + def bare(self): + return _format_jid(self._node, self._domain) @property def full(self): |