diff sat_frontends/tools/jid.py @ 2624:56f94936df1e

code style reformatting using black
author Goffi <goffi@goffi.org>
date Wed, 27 Jun 2018 20:14:46 +0200
parents 26edcf3a30eb
children 003b8b4b56a7
line wrap: on
line diff
--- a/sat_frontends/tools/jid.py	Wed Jun 27 07:51:29 2018 +0200
+++ b/sat_frontends/tools/jid.py	Wed Jun 27 20:14:46 2018 +0200
@@ -20,7 +20,7 @@
 
 # hack to use this module with pyjamas
 try:
-    unicode('')  # XXX: unicode doesn't exist in pyjamas
+    unicode("")  # XXX: unicode doesn't exist in pyjamas
 
     # normal version
     class BaseJID(unicode):
@@ -33,19 +33,23 @@
 
         def _parse(self):
             """Find node domain and resource"""
-            node_end = self.find('@')
+            node_end = self.find("@")
             if node_end < 0:
                 node_end = 0
-            domain_end = self.find('/')
+            domain_end = self.find("/")
             if domain_end == 0:
                 raise ValueError("a jid can't start with '/'")
             if domain_end == -1:
                 domain_end = len(self)
             self.node = self[:node_end] or None
-            self.domain = self[(node_end + 1) if node_end else 0:domain_end]
-            self.resource = self[domain_end + 1:] or None
+            self.domain = self[(node_end + 1) if node_end else 0 : domain_end]
+            self.resource = self[domain_end + 1 :] or None
+
 
-except (TypeError, AttributeError):  # Error raised is not the same depending on pyjsbuild options
+except (
+    TypeError,
+    AttributeError,
+):  # Error raised is not the same depending on pyjsbuild options
 
     # pyjamas version
     class BaseJID(object):
@@ -61,29 +65,33 @@
         def __eq__(self, other):
             if not isinstance(other, JID):
                 return False
-            return (self.node == other.node
-                    and self.domain == other.domain
-                    and self.resource == other.resource)
+            return (
+                self.node == other.node
+                and self.domain == other.domain
+                and self.resource == other.resource
+            )
 
         def __hash__(self):
-            return hash('JID<{}>'.format(self.__internal_str))
+            return hash("JID<{}>".format(self.__internal_str))
 
         def find(self, *args):
             return self.__internal_str.find(*args)
 
         def _parse(self):
             """Find node domain and resource"""
-            node_end = self.__internal_str.find('@')
+            node_end = self.__internal_str.find("@")
             if node_end < 0:
                 node_end = 0
-            domain_end = self.__internal_str.find('/')
+            domain_end = self.__internal_str.find("/")
             if domain_end == 0:
                 raise ValueError("a jid can't start with '/'")
             if domain_end == -1:
                 domain_end = len(self.__internal_str)
             self.node = self.__internal_str[:node_end] or None
-            self.domain = self.__internal_str[(node_end + 1) if node_end else 0:domain_end]
-            self.resource = self.__internal_str[domain_end + 1:] or None
+            self.domain = self.__internal_str[
+                (node_end + 1) if node_end else 0 : domain_end
+            ]
+            self.resource = self.__internal_str[domain_end + 1 :] or None
 
 
 class JID(BaseJID):
@@ -98,9 +106,9 @@
         """Naive normalization before instantiating and parsing the JID"""
         if not jid_str:
             return jid_str
-        tokens = jid_str.split('/')
+        tokens = jid_str.split("/")
         tokens[0] = tokens[0].lower()  # force node and domain to lower-case
-        return '/'.join(tokens)
+        return "/".join(tokens)
 
     @property
     def bare(self):