diff options
author | Jeff Forcier <jeff@bitprophet.org> | 2018-09-17 15:51:22 -0700 |
---|---|---|
committer | Jeff Forcier <jeff@bitprophet.org> | 2018-09-17 15:51:22 -0700 |
commit | 4e31612cfbcd7cb333ac54571f11dd5593b15d94 (patch) | |
tree | b9af871f3ee08287229260d26079a6485d0f0273 /paramiko/util.py | |
parent | 025a250d38b0046e06dfacf437a09276a84e2c59 (diff) | |
download | paramiko-4e31612cfbcd7cb333ac54571f11dd5593b15d94.tar.gz |
Blacken 2.0 with black 18.6b4
Diffstat (limited to 'paramiko/util.py')
-rw-r--r-- | paramiko/util.py | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/paramiko/util.py b/paramiko/util.py index de099c0c..181c3892 100644 --- a/paramiko/util.py +++ b/paramiko/util.py @@ -49,9 +49,9 @@ def inflate_long(s, always_positive=False): # noinspection PyAugmentAssignment s = filler * (4 - len(s) % 4) + s for i in range(0, len(s), 4): - out = (out << 32) + struct.unpack('>I', s[i:i + 4])[0] + out = (out << 32) + struct.unpack(">I", s[i : i + 4])[0] if negative: - out -= (long(1) << (8 * len(s))) + out -= long(1) << (8 * len(s)) return out @@ -66,7 +66,7 @@ def deflate_long(n, add_sign_padding=True): s = bytes() n = long(n) while (n != 0) and (n != -1): - s = struct.pack('>I', n & xffffffff) + s + s = struct.pack(">I", n & xffffffff) + s n >>= 32 # strip off leading zeros, FFs for i in enumerate(s): @@ -81,7 +81,7 @@ def deflate_long(n, add_sign_padding=True): s = zero_byte else: s = max_byte - s = s[i[0]:] + s = s[i[0] :] if add_sign_padding: if (n == 0) and (byte_ord(s[0]) >= 0x80): s = zero_byte + s @@ -90,11 +90,11 @@ def deflate_long(n, add_sign_padding=True): return s -def format_binary(data, prefix=''): +def format_binary(data, prefix=""): x = 0 out = [] while len(data) > x + 16: - out.append(format_binary_line(data[x:x + 16])) + out.append(format_binary_line(data[x : x + 16])) x += 16 if x < len(data): out.append(format_binary_line(data[x:])) @@ -102,19 +102,19 @@ def format_binary(data, prefix=''): def format_binary_line(data): - left = ' '.join(['%02X' % byte_ord(c) for c in data]) - right = ''.join([('.%c..' % c)[(byte_ord(c) + 63) // 95] for c in data]) - return '%-50s %s' % (left, right) + left = " ".join(["%02X" % byte_ord(c) for c in data]) + right = "".join([(".%c.." % c)[(byte_ord(c) + 63) // 95] for c in data]) + return "%-50s %s" % (left, right) def safe_string(s): - out = b('') + out = b("") for c in s: i = byte_ord(c) if 32 <= i <= 127: out += byte_chr(i) else: - out += b('%%%02X' % i) + out += b("%%%02X" % i) return out @@ -134,7 +134,7 @@ def bit_length(n): def tb_strings(): - return ''.join(traceback.format_exception(*sys.exc_info())).split('\n') + return "".join(traceback.format_exception(*sys.exc_info())).split("\n") def generate_key_bytes(hash_alg, salt, key, nbytes): @@ -185,6 +185,7 @@ def load_host_keys(filename): nested dict of `.PKey` objects, indexed by hostname and then keytype """ from paramiko.hostkeys import HostKeys + return HostKeys(filename) @@ -246,15 +247,15 @@ def log_to_file(filename, level=DEBUG): if len(l.handlers) > 0: return l.setLevel(level) - f = open(filename, 'a') + f = open(filename, "a") lh = logging.StreamHandler(f) - frm = '%(levelname)-.3s [%(asctime)s.%(msecs)03d] thr=%(_threadid)-3d %(name)s: %(message)s' # noqa - lh.setFormatter(logging.Formatter(frm, '%Y%m%d-%H:%M:%S')) + frm = "%(levelname)-.3s [%(asctime)s.%(msecs)03d] thr=%(_threadid)-3d %(name)s: %(message)s" # noqa + lh.setFormatter(logging.Formatter(frm, "%Y%m%d-%H:%M:%S")) l.addHandler(lh) # make only one filter object, so it doesn't get applied more than once -class PFilter (object): +class PFilter(object): def filter(self, record): record._threadid = get_thread_id() return True |