[esnacc-dev] [PATCH] py-lib: add flake8 fixes

Aaron Conole aconole at bytheb.org
Tue Aug 7 17:34:07 UTC 2018


Resolves:
  E302, E227, E226, E201, E202, E303, and E501

Signed-off-by: Aaron Conole <aconole at bytheb.org>
---
 py-lib/esnacc/asn_base.py           |  5 +++--
 py-lib/esnacc/asn_bool.py           |  2 ++
 py-lib/esnacc/asn_ints.py           |  6 +++---
 py-lib/esnacc/asn_useful.py         |  1 +
 py-lib/esnacctests/asn_ints_test.py | 11 +++++++----
 5 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/py-lib/esnacc/asn_base.py b/py-lib/esnacc/asn_base.py
index 5e88247..9b46b09 100644
--- a/py-lib/esnacc/asn_base.py
+++ b/py-lib/esnacc/asn_base.py
@@ -10,6 +10,7 @@ from asn_buffer import AsnBuf
 from asn_buffer import BDecDefLen
 from asn_buffer import BEncDefLen
 
+
 class Constraint(object):
     def __init__(self):
         pass
@@ -54,9 +55,9 @@ class BERConsts(object):
             tg = intcnv(tag & 0x7f)
             tag >>= 7
             while tag:
-                tg = intcnv(0x80|(tag & 0x7f)) + tg
+                tg = intcnv(0x80 | (tag & 0x7f)) + tg
                 tag >>= 7
-            fnl = intcnv(fnl|0x1f) + tg
+            fnl = intcnv(fnl | 0x1f) + tg
 
         return int(fnl.encode('hex'), 16)
 
diff --git a/py-lib/esnacc/asn_bool.py b/py-lib/esnacc/asn_bool.py
index 5646e5a..0164ded 100644
--- a/py-lib/esnacc/asn_bool.py
+++ b/py-lib/esnacc/asn_bool.py
@@ -9,6 +9,7 @@
 from asn_base import BERConsts
 from asn_ints import AsnInt
 
+
 def convert_to_bool(value):
     if value is None:
         return False
@@ -25,6 +26,7 @@ def convert_to_bool(value):
 
     return False
 
+
 class AsnBool(AsnInt):
 
     BER_TAG = BERConsts.BOOLEAN_TAG_CODE
diff --git a/py-lib/esnacc/asn_ints.py b/py-lib/esnacc/asn_ints.py
index db1b77e..dd4aef2 100644
--- a/py-lib/esnacc/asn_ints.py
+++ b/py-lib/esnacc/asn_ints.py
@@ -53,7 +53,7 @@ class AsnInt(AsnBase):
             return False
         return True
 
-    __nonzero__=__bool__
+    __nonzero__ = __bool__
 
     def __cmp__(self, obj):
         cmpValA = self.intVal
@@ -257,7 +257,7 @@ class AsnReal(AsnBase):
     def __str__(self):
         return str(self.value())
 
-    __nonzero__=__bool__
+    __nonzero__ = __bool__
 
     def __cmp__(self, obj):
         cmpValA = self.floatVal
@@ -329,7 +329,7 @@ class AsnReal(AsnBase):
             encE = intcnv(e & 0xff)
         else:
             while e not in (0, -1):
-                encE = intcnv(e&0xff) + encE
+                encE = intcnv(e & 0xff) + encE
                 e >>= 8
             if e == 0 and encE[0] != 0 and int(encE[0]) & 0x80:
                 encE = intcnv(0) + encE
diff --git a/py-lib/esnacc/asn_useful.py b/py-lib/esnacc/asn_useful.py
index b818d4c..07840cc 100644
--- a/py-lib/esnacc/asn_useful.py
+++ b/py-lib/esnacc/asn_useful.py
@@ -28,6 +28,7 @@ class NumericString(AsnOcts):
         if self.octs is not None:
             self.setData(value)
 
+
 class IA5String(AsnOcts):
     BER_TAG = BERConsts.IA5STRING_TAG_CODE
 
diff --git a/py-lib/esnacctests/asn_ints_test.py b/py-lib/esnacctests/asn_ints_test.py
index ea4193f..ccf08ee 100755
--- a/py-lib/esnacctests/asn_ints_test.py
+++ b/py-lib/esnacctests/asn_ints_test.py
@@ -11,13 +11,14 @@ import unittest
 if __package__ is None:
     import sys
     from os import path
-    sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
+    sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
     from esnacc import asn_ints
     from esnacc import asn_buffer
 else:
     from ..esnacc import asn_ints
     from ..esnacc import asn_buffer
 
+
 class TestAsnInts(unittest.TestCase):
     def test_operations_default(self):
         asninteger = asn_ints.AsnInt(1)
@@ -126,21 +127,22 @@ class TestAsnInts(unittest.TestCase):
         for x in tests:
             self.assertTrue(x.run())
 
-
     def test_constraints(self):
         class testVec(unittest.TestCase):
             def __init__(self, number):
                 self.nm = number
 
             def run(self):
-                cnstraint_good = asn_ints.IntegerConstraint(self.nm-1, self.nm+1)
+                cnstraint_good = asn_ints.IntegerConstraint(self.nm-1,
+                                                            self.nm+1)
                 asninteger = asn_ints.AsnInt(self.nm)
                 asninteger.addConstraint(cnstraint_good)
 
                 buf = asn_buffer.AsnBuf()
                 self.assertTrue(asninteger.BEnc(buf) != 0)
 
-                cnstraint_bad = asn_ints.IntegerConstraint(self.nm+1, self.nm+2)
+                cnstraint_bad = asn_ints.IntegerConstraint(self.nm+1,
+                                                           self.nm+2)
                 asninteger.addConstraint(cnstraint_bad)
                 with self.assertRaises(ValueError):
                     asninteger.BEnc(buf)
@@ -160,6 +162,7 @@ class TestAsnInts(unittest.TestCase):
         for x in tests:
             self.assertTrue(x.run())
 
+
 class TestAsnEnums(unittest.TestCase):
     def test_enumeration_encoding(self):
         class testVec(unittest.TestCase):
-- 
2.14.3



More information about the dev mailing list