-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sourcery refactored master branch #1
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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}') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
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.') | ||
Comment on lines
-49
to
+63
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
sys.exit(0) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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()}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
print("SIZE (%s) = %d" % (arg, os.path.getsize(arg))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
calc_sha256
refactored with the following changes:use-fstring-for-concatenation
)