summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Matveev <stargrave@stargrave.org>2020-03-25 13:19:31 +0300
committerSergey Matveev <stargrave@stargrave.org>2020-03-25 14:16:50 +0300
commit7decc606fe85d6c37a20ba48b14d80fcb1741443 (patch)
tree5e9fc40a61b8be674df2f3cf86e4538ae1c26117
parentdf4edf45ae38fdde82784de40a95f6f0279f5e89 (diff)
downloadpyderasn-7decc606fe85d6c37a20ba48b14d80fcb1741443.tar.xz
PEP8
-rwxr-xr-xpyderasn.py14
-rw-r--r--tests/test_pyderasn.py7
2 files changed, 14 insertions, 7 deletions
diff --git a/pyderasn.py b/pyderasn.py
index f611efa..54f2027 100755
--- a/pyderasn.py
+++ b/pyderasn.py
@@ -1287,11 +1287,13 @@ def file_mmaped(fd):
"""
return memoryview(mmap(fd.fileno(), 0, prot=PROT_READ))
+
def pureint(value):
if not set(value) <= DECIMALS:
raise ValueError("non-pure integer")
return int(value)
+
def fractions2float(fractions_raw):
pureint(fractions_raw)
return float("0." + fractions_raw)
@@ -1304,7 +1306,7 @@ def get_def_by_path(defines_by_path, sub_decode_path):
if len(path) != len(sub_decode_path):
continue
for p1, p2 in zip(path, sub_decode_path):
- if (not p1 is any) and (p1 != p2):
+ if (p1 is not any) and (p1 != p2):
break
else:
return define
@@ -1963,7 +1965,7 @@ class Obj(object):
yield None
return
_decode_path, obj, tail = result
- if not _decode_path is decode_path:
+ if _decode_path is not decode_path:
yield result
else:
try:
@@ -2005,7 +2007,7 @@ class Obj(object):
yield None
return
_decode_path, obj, tail = result
- if not _decode_path is decode_path:
+ if _decode_path is not decode_path:
yield result
eoc_expected, tail = tail[:EOC_LEN], tail[EOC_LEN:]
if eoc_expected.tobytes() != EOC:
@@ -2044,7 +2046,7 @@ class Obj(object):
yield None
return
_decode_path, obj, tail = result
- if not _decode_path is decode_path:
+ if _decode_path is not decode_path:
yield result
if obj.tlvlen < l and not ctx.get("allow_expl_oob", False):
raise DecodeError(
@@ -3373,7 +3375,7 @@ class BitString(Obj):
int2byte(0),
octets[offset:offset + 999],
)))
- tail = octets[offset+999:]
+ tail = octets[offset + 999:]
if len(tail) > 0:
tail = int2byte((8 - bit_len % 8) % 8) + tail
write_full(writer, b"".join((
@@ -3833,7 +3835,7 @@ class OctetString(Obj):
LEN1K,
octets[offset:offset + 1000],
)))
- tail = octets[offset+1000:]
+ tail = octets[offset + 1000:]
if len(tail) > 0:
write_full(writer, b"".join((
OctetString.tag_default,
diff --git a/tests/test_pyderasn.py b/tests/test_pyderasn.py
index b16c6f6..d112a60 100644
--- a/tests/test_pyderasn.py
+++ b/tests/test_pyderasn.py
@@ -2662,7 +2662,6 @@ class TestNull(CommonMixin, TestCase):
repr(obj)
list(obj.pps())
-
@given(integers(min_value=1))
def test_invalid_len(self, l):
with self.assertRaises(InvalidLength):
@@ -6274,6 +6273,7 @@ class SeqMixing(object):
min_size=len(_schema),
max_size=len(_schema),
))]
+
class Wahl(Choice):
schema = (("int", Integer()),)
@@ -7046,6 +7046,7 @@ class TestSequenceOf(SeqOfMixing, CommonMixin, TestCase):
schema = Integer()
bounds = (10, 20)
seqof = None
+
def gen(n):
for i in six_xrange(n):
yield Integer(i)
@@ -7065,6 +7066,7 @@ class TestSequenceOf(SeqOfMixing, CommonMixin, TestCase):
class SeqOf(SequenceOf):
schema = Integer()
bounds = (1, float("+inf"))
+
def gen():
for i in six_xrange(10):
yield Integer(i)
@@ -7079,6 +7081,7 @@ class TestSequenceOf(SeqOfMixing, CommonMixin, TestCase):
class SeqOf(SequenceOf):
schema = Integer()
bounds = (1, float("+inf"))
+
def gen():
for i in six_xrange(10):
yield Integer(i)
@@ -7613,6 +7616,7 @@ class TestDefinesByPath(TestCase):
def test_remaining_data(self):
oid = ObjectIdentifier("1.2.3")
+
class Seq(Sequence):
schema = (
("oid", ObjectIdentifier(defines=((("tgt",), {
@@ -7630,6 +7634,7 @@ class TestDefinesByPath(TestCase):
def test_remaining_data_seqof(self):
oid = ObjectIdentifier("1.2.3")
+
class SeqOf(SetOf):
schema = OctetString()