diff options
author | practicalswift <practicalswift@users.noreply.github.com> | 2018-04-16 11:13:07 +0200 |
---|---|---|
committer | practicalswift <practicalswift@users.noreply.github.com> | 2018-04-16 17:25:11 +0200 |
commit | f020aca297e8a6c9f7b6a6e08e583847d37edace (patch) | |
tree | b7573c8faefcf5c92d21f1bd297fc72a8da3393f /contrib/devtools | |
parent | 0d6992168c2bda85b18fda8f6dea08da433a0dc9 (diff) |
Minor Python cleanups to make flake8 pass with the new rules enabled
Diffstat (limited to 'contrib/devtools')
-rwxr-xr-x | contrib/devtools/copyright_header.py | 8 | ||||
-rwxr-xr-x | contrib/devtools/github-merge.py | 3 | ||||
-rwxr-xr-x | contrib/devtools/optimize-pngs.py | 8 |
3 files changed, 10 insertions, 9 deletions
diff --git a/contrib/devtools/copyright_header.py b/contrib/devtools/copyright_header.py index c817e794b9..e7cccaab03 100755 --- a/contrib/devtools/copyright_header.py +++ b/contrib/devtools/copyright_header.py @@ -286,7 +286,7 @@ Arguments: def report_cmd(argv): if len(argv) == 2: sys.exit(REPORT_USAGE) - + base_directory = argv[2] if not os.path.exists(base_directory): sys.exit("*** bad <base_directory>: %s" % base_directory) @@ -444,7 +444,7 @@ def print_file_action_message(filename, action): def update_cmd(argv): if len(argv) != 3: sys.exit(UPDATE_USAGE) - + base_directory = argv[2] if not os.path.exists(base_directory): sys.exit("*** bad base_directory: %s" % base_directory) @@ -570,13 +570,13 @@ def insert_cmd(argv): _, extension = os.path.splitext(filename) if extension not in ['.h', '.cpp', '.cc', '.c', '.py']: sys.exit("*** cannot insert for file extension %s" % extension) - + if extension == '.py': style = 'python' else: style = 'cpp' exec_insert_header(filename, style) - + ################################################################################ # UI ################################################################################ diff --git a/contrib/devtools/github-merge.py b/contrib/devtools/github-merge.py index 9c666673cf..187ef75fb7 100755 --- a/contrib/devtools/github-merge.py +++ b/contrib/devtools/github-merge.py @@ -21,7 +21,8 @@ import argparse import hashlib import subprocess import sys -import json,codecs +import json +import codecs try: from urllib.request import Request,urlopen except: diff --git a/contrib/devtools/optimize-pngs.py b/contrib/devtools/optimize-pngs.py index 565b199125..a75731ef76 100755 --- a/contrib/devtools/optimize-pngs.py +++ b/contrib/devtools/optimize-pngs.py @@ -41,19 +41,19 @@ for folder in folders: file_path = os.path.join(absFolder, file) fileMetaMap = {'file' : file, 'osize': os.path.getsize(file_path), 'sha256Old' : file_hash(file_path)} fileMetaMap['contentHashPre'] = content_hash(file_path) - + try: subprocess.call([pngcrush, "-brute", "-ow", "-rem", "gAMA", "-rem", "cHRM", "-rem", "iCCP", "-rem", "sRGB", "-rem", "alla", "-rem", "text", file_path], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) except: print("pngcrush is not installed, aborting...") sys.exit(0) - + #verify if "Not a PNG file" in subprocess.check_output([pngcrush, "-n", "-v", file_path], stderr=subprocess.STDOUT, universal_newlines=True): print("PNG file "+file+" is corrupted after crushing, check out pngcursh version") sys.exit(1) - + fileMetaMap['sha256New'] = file_hash(file_path) fileMetaMap['contentHashPost'] = content_hash(file_path) @@ -72,5 +72,5 @@ for fileDict in outputArray: totalSaveBytes += fileDict['osize'] - fileDict['psize'] noHashChange = noHashChange and (oldHash == newHash) print(fileDict['file']+"\n size diff from: "+str(fileDict['osize'])+" to: "+str(fileDict['psize'])+"\n old sha256: "+oldHash+"\n new sha256: "+newHash+"\n") - + print("completed. Checksum stable: "+str(noHashChange)+". Total reduction: "+str(totalSaveBytes)+" bytes") |