[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Correct stylistic issues



commit 54ea347242f0966240fc0d072983e636b0f7caab
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Mon Feb 27 15:49:22 2017 -0800

    Correct stylistic issues
    
    Handful of things spotted by pycodestyle.
---
 stem/descriptor/server_descriptor.py      | 15 ++++++---------
 stem/prereq.py                            |  1 +
 test/settings.cfg                         |  4 ++++
 test/unit/descriptor/server_descriptor.py |  1 -
 4 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/stem/descriptor/server_descriptor.py b/stem/descriptor/server_descriptor.py
index 7d134dd..a8a1ba2 100644
--- a/stem/descriptor/server_descriptor.py
+++ b/stem/descriptor/server_descriptor.py
@@ -666,8 +666,8 @@ class ServerDescriptor(Descriptor):
       raise ValueError("Descriptor must end with a '%s' entry" % expected_last_keyword)
 
     if 'identity-ed25519' in entries.keys():
-      if not 'router-sig-ed25519' in entries.keys():
-        raise ValueError("Descriptor must have router-sig-ed25519 entry to accompany identity-ed25519")
+      if 'router-sig-ed25519' not in entries.keys():
+        raise ValueError('Descriptor must have router-sig-ed25519 entry to accompany identity-ed25519')
 
       if 'router-sig-ed25519' != list(entries.keys())[-2]:
         if 'router-sig-ed25519' != list(entries.keys())[-1]:
@@ -772,13 +772,11 @@ class RelayDescriptor(ServerDescriptor):
                                               validate)
 
         if self.certificate.identity_key != self.ed25519_master_key:
-          raise ValueError("master-key-ed25519 does not match ed25519 certificate identity key")
+          raise ValueError('master-key-ed25519 does not match ed25519 certificate identity key')
 
         self.certificate.verify_descriptor_signature(raw_contents,
                                                      self.ed25519_signature)
 
-
-
   @lru_cache()
   def digest(self):
     """
@@ -791,7 +789,6 @@ class RelayDescriptor(ServerDescriptor):
 
     return self._digest_for_content(b'router ', b'\nrouter-signature\n')
 
-
   @lru_cache()
   def onion_key_crosscert_digest(self):
     """
@@ -804,10 +801,10 @@ class RelayDescriptor(ServerDescriptor):
 
     :raises: ValueError if the digest cannot be calculated
     """
-    signing_key_digest = hashlib.sha1(_bytes_for_block(self.signing_key)).digest()
-    data = signing_key_digest + base64.b64decode(self.ed25519_master_key +  b'=')
-    return data.encode("hex").upper()
 
+    signing_key_digest = hashlib.sha1(_bytes_for_block(self.signing_key)).digest()
+    data = signing_key_digest + base64.b64decode(self.ed25519_master_key + b'=')
+    return data.encode('hex').upper()
 
   def _compare(self, other, method):
     if not isinstance(other, RelayDescriptor):
diff --git a/stem/prereq.py b/stem/prereq.py
index e8769a3..5d6e80a 100644
--- a/stem/prereq.py
+++ b/stem/prereq.py
@@ -149,6 +149,7 @@ def is_mock_available():
   except ImportError:
     return False
 
+
 @lru_cache()
 def is_nacl_available():
   """
diff --git a/test/settings.cfg b/test/settings.cfg
index 558487d..c953773 100644
--- a/test/settings.cfg
+++ b/test/settings.cfg
@@ -152,6 +152,10 @@ pyflakes.ignore stem/prereq.py => 'modes' imported but unused
 pyflakes.ignore stem/prereq.py => 'Cipher' imported but unused
 pyflakes.ignore stem/prereq.py => 'algorithms' imported but unused
 pyflakes.ignore stem/prereq.py => 'unittest' imported but unused
+pyflakes.ignore stem/prereq.py => 'unittest.mock' imported but unused
+pyflakes.ignore stem/prereq.py => 'long_to_bytes' imported but unused
+pyflakes.ignore stem/prereq.py => 'encoding' imported but unused
+pyflakes.ignore stem/prereq.py => 'signing' imported but unused
 pyflakes.ignore stem/interpreter/__init__.py => undefined name 'raw_input'
 pyflakes.ignore stem/util/conf.py => undefined name 'unicode'
 pyflakes.ignore stem/util/test_tools.py => 'pyflakes' imported but unused
diff --git a/test/unit/descriptor/server_descriptor.py b/test/unit/descriptor/server_descriptor.py
index c4e9b67..8170532 100644
--- a/test/unit/descriptor/server_descriptor.py
+++ b/test/unit/descriptor/server_descriptor.py
@@ -310,7 +310,6 @@ Qlx9HNCqCY877ztFRC624ja2ql6A2hBcuoYMbkHjcQ4=
     desc_iter = stem.descriptor.server_descriptor._parse_file(io.BytesIO(desc_text), validate = True)
     self.assertRaises(ValueError, list, desc_iter)
 
-
   def test_bridge_with_ed25519(self):
     """
     Parses a bridge descriptor with ed25519.



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits