Minor Python cleanups to make flake8 pass with the new rules enabled
This commit is contained in:
1 parent
0d6992168c
commit
f020aca297
21 files changed
+58
-50
No files matched your search
@@ -43,8 +43,10 @@ def b58encode(v):
|
||||
# leading 0-bytes in the input become leading-1s
|
||||
nPad = 0
|
||||
for c in v:
|
||||
if c == 0: nPad += 1
|
||||
else: break
|
||||
if c == 0:
|
||||
nPad += 1
|
||||
else:
|
||||
break
|
||||
|
||||
return (__b58chars[0]*nPad) + result
|
||||
|
||||
@@ -98,7 +100,8 @@ def b58decode_chk(v):
|
||||
def get_bcaddress_version(strAddress):
|
||||
""" Returns None if strAddress is invalid. Otherwise returns integer version of address. """
|
||||
addr = b58decode_chk(strAddress)
|
||||
if addr is None or len(addr)!=21: return None
|
||||
if addr is None or len(addr)!=21:
|
||||
return None
|
||||
version = addr[0]
|
||||
return ord(version)
|
||||
|
||||
|
||||
@@ -74,12 +74,12 @@ def gen_invalid_vector(template, corrupt_prefix, randomize_payload_size, corrupt
|
||||
prefix = os.urandom(1)
|
||||
else:
|
||||
prefix = bytearray(template[0])
|
||||
|
||||
|
||||
if randomize_payload_size:
|
||||
payload = os.urandom(max(int(random.expovariate(0.5)), 50))
|
||||
else:
|
||||
payload = os.urandom(template[1])
|
||||
|
||||
|
||||
if corrupt_suffix:
|
||||
suffix = os.urandom(len(template[2]))
|
||||
else:
|
||||
@@ -114,7 +114,8 @@ def gen_invalid_vectors():
|
||||
yield val,
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys, json
|
||||
import sys
|
||||
import json
|
||||
iters = {'valid':gen_valid_vectors, 'invalid':gen_invalid_vectors}
|
||||
try:
|
||||
uiter = iters[sys.argv[1]]
|
||||
@@ -124,7 +125,7 @@ if __name__ == '__main__':
|
||||
count = int(sys.argv[2])
|
||||
except IndexError:
|
||||
count = 0
|
||||
|
||||
|
||||
data = list(islice(uiter(), count))
|
||||
json.dump(data, sys.stdout, sort_keys=True, indent=4)
|
||||
sys.stdout.write('\n')
|
||||
|
||||
Reference in new issue
Block a user