From a5f5e7ed9b07b902af4438d76087e034abcba9b2 Mon Sep 17 00:00:00 2001 From: ng0 Date: Sat, 12 Oct 2019 18:16:07 +0000 Subject: format python --- contrib/scripts/gnunet-chk.py.in | 23 ++++++++++++----------- contrib/scripts/gnunet_janitor.py.in | 1 + contrib/scripts/gnunet_pyexpect.py.in | 20 +++++++++++++++----- contrib/scripts/pydiffer.py.in | 5 ++++- contrib/scripts/removetrailingwhitespace.py.in | 1 - contrib/scripts/terminate.py.in | 2 +- 6 files changed, 33 insertions(+), 19 deletions(-) (limited to 'contrib/scripts') diff --git a/contrib/scripts/gnunet-chk.py.in b/contrib/scripts/gnunet-chk.py.in index 0fb591627..7d2cf73d3 100755 --- a/contrib/scripts/gnunet-chk.py.in +++ b/contrib/scripts/gnunet-chk.py.in @@ -29,9 +29,8 @@ import sys from Crypto.Cipher import AES from functools import reduce - # Defaults -DBLOCK_SIZE = (32 * 1024) # Data block size +DBLOCK_SIZE = (32 * 1024) # Data block size # Pick a multiple of 2 here to achive 8-byte alignment! We also # probably want DBlocks to have (roughly) the same size as IBlocks. @@ -39,7 +38,7 @@ DBLOCK_SIZE = (32 * 1024) # Data block size # byte = 2 * 512 bits). DO NOT CHANGE! CHK_PER_INODE = 256 -CHK_HASH_SIZE = 64 # SHA-512 hash = 512 bits = 64 bytes +CHK_HASH_SIZE = 64 # SHA-512 hash = 512 bits = 64 bytes CHK_QUERY_SIZE = CHK_HASH_SIZE # Again a SHA-512 hash @@ -94,11 +93,11 @@ class AESKey(object): """Class for AES Keys. Contains the main key and the initialization vector. """ - key = None # The actual AES key - iv = None # The initialization vector - cipher = None # The cipher object - KEY_SIZE = 32 # AES 256-bit key = 32 bytes - IV_SIZE = AES.block_size # Initialization vector size (= AES block size) + key = None # The actual AES key + iv = None # The initialization vector + cipher = None # The cipher object + KEY_SIZE = 32 # AES 256-bit key = 32 bytes + IV_SIZE = AES.block_size # Initialization vector size (= AES block size) def __init__(self, passphrase): """Creates a new AES key. @@ -355,13 +354,15 @@ def chkuri_from_path(path): def usage(): """Prints help about using this script.""" - print(""" + print( + """ Usage: gnunet-chk.py [options] file Prints the Content Hash Key of given file in GNUNET-style URI. Options: -h, --help : prints this message -""") +""" + ) if '__main__' == __name__: @@ -373,7 +374,7 @@ if '__main__' == __name__: usage() sys.exit(2) for option, value in opts: - if option in("-h", "--help"): + if option in ("-h", "--help"): usage() sys.exit(0) if len(args) != 1: diff --git a/contrib/scripts/gnunet_janitor.py.in b/contrib/scripts/gnunet_janitor.py.in index b0b50ca76..d6834bfb4 100644 --- a/contrib/scripts/gnunet_janitor.py.in +++ b/contrib/scripts/gnunet_janitor.py.in @@ -31,6 +31,7 @@ import time import signal import terminate + def get_process_list(): result = [] pids = [pid for pid in os.listdir('/proc') if pid.isdigit()] diff --git a/contrib/scripts/gnunet_pyexpect.py.in b/contrib/scripts/gnunet_pyexpect.py.in index 188436f51..48f8acdc1 100644 --- a/contrib/scripts/gnunet_pyexpect.py.in +++ b/contrib/scripts/gnunet_pyexpect.py.in @@ -11,7 +11,7 @@ # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Affero General Public License for more details. -# +# # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # @@ -27,7 +27,7 @@ import shutil import time -class pexpect (object): +class pexpect(object): def __init__(self): super(pexpect, self).__init__() @@ -54,12 +54,22 @@ class pexpect (object): if len(stream) == 0: return True else: - print("Failed to find `{1}' in {0}, which is `{2}' ({3})".format(s, r, stream, len(stream))) + print( + "Failed to find `{1}' in {0}, which is `{2}' ({3})". + format(s, r, stream, len(stream)) + ) sys.exit(2) - raise ValueError("Argument `r' should be an instance of re.RegexObject or a special string, but is `{0}'".format(r)) + raise ValueError( + "Argument `r' should be an instance of re.RegexObject or a special string, but is `{0}'" + .format(r) + ) m = r.search(stream.decode(), flags) if not m: - print("Failed to find `{1}' in {0}, which is is `{2}'".format(s, r.pattern, stream)) + print( + "Failed to find `{1}' in {0}, which is is `{2}'".format( + s, r.pattern, stream + ) + ) sys.exit(2) stream = stream[m.end():] if s == 'stdout': diff --git a/contrib/scripts/pydiffer.py.in b/contrib/scripts/pydiffer.py.in index 35d9ffa35..08f0f4ae6 100644 --- a/contrib/scripts/pydiffer.py.in +++ b/contrib/scripts/pydiffer.py.in @@ -10,7 +10,10 @@ def getdiff(old, new): diff = [] with open(old) as a: with open(new) as b: - for l in difflib.unified_diff(a.read().splitlines(), b.read().splitlines()): + for l in difflib.unified_diff( + a.read().splitlines(), + b.read().splitlines() + ): diff.append(l) return diff diff --git a/contrib/scripts/removetrailingwhitespace.py.in b/contrib/scripts/removetrailingwhitespace.py.in index 5824fb591..e6c2d9014 100755 --- a/contrib/scripts/removetrailingwhitespace.py.in +++ b/contrib/scripts/removetrailingwhitespace.py.in @@ -3,7 +3,6 @@ import sys import re - for fileName in sys.argv[1:]: f = open(fileName, 'r+') fileString = f.read() diff --git a/contrib/scripts/terminate.py.in b/contrib/scripts/terminate.py.in index f57ac6167..2cb4a13c4 100644 --- a/contrib/scripts/terminate.py.in +++ b/contrib/scripts/terminate.py.in @@ -26,7 +26,7 @@ import subprocess import os -class dummyobj (object): +class dummyobj(object): pass -- cgit v1.2.3