diff options
author | Nils Gillmann <ng0@n0.is> | 2018-05-17 13:31:11 +0000 |
---|---|---|
committer | Nils Gillmann <ng0@n0.is> | 2018-05-17 13:31:11 +0000 |
commit | c7e03281601aa687030fe3d561e1d693a46bba21 (patch) | |
tree | 272231e2d4856c0c67ab21bf249f0752147b5305 /contrib | |
parent | 42399e29836ef338bd6452391f3fc62348e6e4fa (diff) | |
download | gnunet-c7e03281601aa687030fe3d561e1d693a46bba21.tar.gz gnunet-c7e03281601aa687030fe3d561e1d693a46bba21.zip |
some 2to3 + flake8 fixes in contrib/gnunet-chk.py
Signed-off-by: Nils Gillmann <ng0@n0.is>
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/gnunet-chk.py.in | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/contrib/gnunet-chk.py.in b/contrib/gnunet-chk.py.in index 83e26f244..0d07e6239 100755 --- a/contrib/gnunet-chk.py.in +++ b/contrib/gnunet-chk.py.in | |||
@@ -27,6 +27,7 @@ import os | |||
27 | import getopt | 27 | import getopt |
28 | import sys | 28 | import sys |
29 | from Crypto.Cipher import AES | 29 | from Crypto.Cipher import AES |
30 | from functools import reduce | ||
30 | 31 | ||
31 | 32 | ||
32 | # Defaults | 33 | # Defaults |
@@ -76,7 +77,7 @@ def encode_data_to_string(data): | |||
76 | wpos += 1 | 77 | wpos += 1 |
77 | vbit -= 5 | 78 | vbit -= 5 |
78 | assert (0 == vbit) | 79 | assert (0 == vbit) |
79 | return out; | 80 | return out |
80 | 81 | ||
81 | 82 | ||
82 | def sha512_hash(data): | 83 | def sha512_hash(data): |
@@ -105,7 +106,7 @@ class AESKey: | |||
105 | passphrase: string containing the passphrase to get the AES key and | 106 | passphrase: string containing the passphrase to get the AES key and |
106 | initialization vector | 107 | initialization vector |
107 | """ | 108 | """ |
108 | passphrase = bytearray(passphrase); | 109 | passphrase = bytearray(passphrase) |
109 | self.key = bytearray(self.KEY_SIZE) | 110 | self.key = bytearray(self.KEY_SIZE) |
110 | self.iv = bytearray(self.IV_SIZE) | 111 | self.iv = bytearray(self.IV_SIZE) |
111 | if (len(passphrase) > self.KEY_SIZE): | 112 | if (len(passphrase) > self.KEY_SIZE): |
@@ -284,7 +285,7 @@ def compute_rootchk(readin, size): | |||
284 | readin: the stream where to read data from | 285 | readin: the stream where to read data from |
285 | size: the size of data to be read | 286 | size: the size of data to be read |
286 | """ | 287 | """ |
287 | depth = compute_depth_(size); | 288 | depth = compute_depth_(size) |
288 | current_depth = 0 | 289 | current_depth = 0 |
289 | chks = [None] * (depth * CHK_PER_INODE) # list buffer | 290 | chks = [None] * (depth * CHK_PER_INODE) # list buffer |
290 | read_offset = 0 | 291 | read_offset = 0 |
@@ -294,13 +295,13 @@ def compute_rootchk(readin, size): | |||
294 | off = CHK_PER_INODE * (depth - 1) | 295 | off = CHK_PER_INODE * (depth - 1) |
295 | assert (chks[off] is not None) | 296 | assert (chks[off] is not None) |
296 | logging.debug("Encoding done, reading CHK `" + chks[off].query + \ | 297 | logging.debug("Encoding done, reading CHK `" + chks[off].query + \ |
297 | "' from " + repr(off) + "\n") | 298 | "' from " + repr(off) + "\n") |
298 | uri_chk = chks[off] | 299 | uri_chk = chks[off] |
299 | assert (size == read_offset) | 300 | assert (size == read_offset) |
300 | uri_chk.setSize(size) | 301 | uri_chk.setSize(size) |
301 | return uri_chk | 302 | return uri_chk |
302 | if (0 == current_depth): | 303 | if (0 == current_depth): |
303 | pt_size = min(DBLOCK_SIZE, size - read_offset); | 304 | pt_size = min(DBLOCK_SIZE, size - read_offset) |
304 | try: | 305 | try: |
305 | pt_block = readin.read(pt_size) | 306 | pt_block = readin.read(pt_size) |
306 | except IOError: | 307 | except IOError: |