From 444bfd06a7d23229673d6307753b778c05295652 Mon Sep 17 00:00:00 2001 From: Sourcery AI <> Date: Sat, 6 Jan 2024 21:32:27 +0000 Subject: [PATCH] 'Refactored by Sourcery' --- scripts/validate_dist.py | 16 ++++++++-------- utils/calc_dist.py | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/validate_dist.py b/scripts/validate_dist.py index 8d039d9..3aa30ed 100755 --- a/scripts/validate_dist.py +++ b/scripts/validate_dist.py @@ -10,7 +10,7 @@ def calc_sha256(fn): h = hashlib.sha256() - with open('dist/' + fn, 'rb') as f: + with open(f'dist/{fn}', 'rb') as f: buf = f.read(1024*1024) while len(buf) > 0: h.update(buf) @@ -20,7 +20,7 @@ def calc_sha256(fn): def file_size(fn): try: - return os.path.getsize('dist/' + fn) + return os.path.getsize(f'dist/{fn}') except: return None @@ -46,19 +46,19 @@ def file_size(fn): # Validate that everything matches the distinfo for this file. size = file_size(fn) - if size == None: - sys.exit('File not found: %s' % (fn,)) + if size is None: + sys.exit(f'File not found: {fn}') if size != int(l2t[3]): sys.exit('File "%s" is incorrect size (expected %d)' % (fn, int(l2t[3]))) sha = calc_sha256(fn) - if sha == None: - sys.exit('File not found: %s' % (fn, )) + if sha is None: + sys.exit(f'File not found: {fn}') if sha != l1t[3]: - sys.exit('File "%s" is corrupt!' % (fn, )) + sys.exit(f'File "{fn}" is corrupt!') - print('File "%s" is ok.' % (fn, )) + print(f'File "{fn}" is ok.') sys.exit(0) diff --git a/utils/calc_dist.py b/utils/calc_dist.py index 8d7d191..6d75bf9 100755 --- a/utils/calc_dist.py +++ b/utils/calc_dist.py @@ -16,5 +16,5 @@ while len(buf) > 0: h.update(buf) buf = f.read(1024*1024) - print("SHA256 (%s) = %s" % (arg, h.hexdigest())) + print(f"SHA256 ({arg}) = {h.hexdigest()}") print("SIZE (%s) = %d" % (arg, os.path.getsize(arg)))