From 97c8508f5e4f57b1048830d44e76e1f4517fd449 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Sun, 30 Oct 2016 18:44:57 +0100 Subject: style: Start applying PEP8 to Python files, indentation issues Done with `autopep8 --select=E1`, fixes: - E101 - Reindent all lines. - E112 - Fix under-indented comments. - E113 - Fix over-indented comments. - E115 - Fix under-indented comments. - E116 - Fix over-indented comments. - E121 - Fix a badly indented line. - E122 - Fix a badly indented line. - E123 - Fix a badly indented line. - E124 - Fix a badly indented line. - E125 - Fix indentation undistinguish from the next logical line. - E126 - Fix a badly indented line. - E127 - Fix a badly indented line. - E128 - Fix a badly indented line. - E129 - Fix a badly indented line. --- tools/scripts/file-hex-array.py | 56 ++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'tools/scripts/file-hex-array.py') diff --git a/tools/scripts/file-hex-array.py b/tools/scripts/file-hex-array.py index 05352396f1..f50dcd4e26 100755 --- a/tools/scripts/file-hex-array.py +++ b/tools/scripts/file-hex-array.py @@ -3,33 +3,33 @@ import os.path import sys def tof(filepath): - with open(filepath, 'r') as f: - content = f.read() - content = content.replace("0x","") - content = content.split(',') - for i in range(len(content)): - if len(content[i]) == 1: content[i] = "0" + content[i] - content = "".join(content) - with open(filepath+".file", 'wb') as f: - content = f.write(content.decode("hex")) - print(os.path.basename(filepath)+".file created.") - exit(0) + with open(filepath, 'r') as f: + content = f.read() + content = content.replace("0x","") + content = content.split(',') + for i in range(len(content)): + if len(content[i]) == 1: content[i] = "0" + content[i] + content = "".join(content) + with open(filepath+".file", 'wb') as f: + content = f.write(content.decode("hex")) + print(os.path.basename(filepath)+".file created.") + exit(0) def toa(filepath): - with open(filepath, 'rb') as f: - content = f.read() - content = binascii.hexlify(content) - content = [content[i:i+2] for i in range(0, len(content), 2)] - content = ",0x".join(content) - content = "0x" + content - content = content.replace("0x00","0x0") - with open(filepath+".array", 'w') as f: - content = f.write(content) - print(os.path.basename(filepath)+".array created.") - exit(0) + with open(filepath, 'rb') as f: + content = f.read() + content = binascii.hexlify(content) + content = [content[i:i+2] for i in range(0, len(content), 2)] + content = ",0x".join(content) + content = "0x" + content + content = content.replace("0x00","0x0") + with open(filepath+".array", 'w') as f: + content = f.write(content) + print(os.path.basename(filepath)+".array created.") + exit(0) def usage(): - print("========================================================\n\ + print("========================================================\n\ #\n\ # Usage: python file-hex-array.py [action] [option]\n\ #\n\ @@ -40,13 +40,13 @@ def usage(): # Example : python file-hex-array.py toa 1.png\n\ #\n\ ========================================================") - exit(1) + exit(1) if len(sys.argv) != 3: - usage() + usage() if sys.argv[1] == "toa" and os.path.isfile(sys.argv[2]): - toa(sys.argv[2]) + toa(sys.argv[2]) elif sys.argv[1] == "tof" and os.path.isfile(sys.argv[2]): - tof(sys.argv[2]) + tof(sys.argv[2]) else: - usage() \ No newline at end of file + usage() -- cgit v1.2.3 From d4c17700aa2f36f69978beda04e42ff2749de270 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Sun, 30 Oct 2016 18:57:40 +0100 Subject: style: Fix PEP8 whitespace issues in Python files Done with `autopep8 --select=E2,W2`, fixes: - E201 - Remove extraneous whitespace. - E202 - Remove extraneous whitespace. - E203 - Remove extraneous whitespace. - E211 - Remove extraneous whitespace. - E221 - Fix extraneous whitespace around keywords. - E222 - Fix extraneous whitespace around keywords. - E223 - Fix extraneous whitespace around keywords. - E224 - Remove extraneous whitespace around operator. - E225 - Fix missing whitespace around operator. - E226 - Fix missing whitespace around operator. - E227 - Fix missing whitespace around operator. - E228 - Fix missing whitespace around operator. - E231 - Add missing whitespace. - E231 - Fix various deprecated code (via lib2to3). - E241 - Fix extraneous whitespace around keywords. - E242 - Remove extraneous whitespace around operator. - E251 - Remove whitespace around parameter '=' sign. - E261 - Fix spacing after comment hash. - E262 - Fix spacing after comment hash. - E265 - Format block comments. - E271 - Fix extraneous whitespace around keywords. - E272 - Fix extraneous whitespace around keywords. - E273 - Fix extraneous whitespace around keywords. - E274 - Fix extraneous whitespace around keywords. - W291 - Remove trailing whitespace. - W293 - Remove trailing whitespace. --- tools/scripts/file-hex-array.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'tools/scripts/file-hex-array.py') diff --git a/tools/scripts/file-hex-array.py b/tools/scripts/file-hex-array.py index f50dcd4e26..8b7c3edd7f 100755 --- a/tools/scripts/file-hex-array.py +++ b/tools/scripts/file-hex-array.py @@ -5,27 +5,27 @@ import sys def tof(filepath): with open(filepath, 'r') as f: content = f.read() - content = content.replace("0x","") + content = content.replace("0x", "") content = content.split(',') for i in range(len(content)): if len(content[i]) == 1: content[i] = "0" + content[i] content = "".join(content) - with open(filepath+".file", 'wb') as f: + with open(filepath + ".file", 'wb') as f: content = f.write(content.decode("hex")) - print(os.path.basename(filepath)+".file created.") + print(os.path.basename(filepath) + ".file created.") exit(0) def toa(filepath): with open(filepath, 'rb') as f: content = f.read() content = binascii.hexlify(content) - content = [content[i:i+2] for i in range(0, len(content), 2)] + content = [content[i:i + 2] for i in range(0, len(content), 2)] content = ",0x".join(content) content = "0x" + content - content = content.replace("0x00","0x0") - with open(filepath+".array", 'w') as f: + content = content.replace("0x00", "0x0") + with open(filepath + ".array", 'w') as f: content = f.write(content) - print(os.path.basename(filepath)+".array created.") + print(os.path.basename(filepath) + ".array created.") exit(0) def usage(): -- cgit v1.2.3 From 817dd7ccbb166b27c93706dffc5c0c0d59fd87f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Sun, 30 Oct 2016 19:05:14 +0100 Subject: style: Fix PEP8 blank lines issues in Python files Done with `autopep8 --select=E3,W3`, fixes: - E301 - Add missing blank line. - E302 - Add missing 2 blank lines. - E303 - Remove extra blank lines. - E304 - Remove blank line following function decorator. - E309 - Add missing blank line. - W391 - Remove trailing blank lines. --- tools/scripts/file-hex-array.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tools/scripts/file-hex-array.py') diff --git a/tools/scripts/file-hex-array.py b/tools/scripts/file-hex-array.py index 8b7c3edd7f..da95c9505f 100755 --- a/tools/scripts/file-hex-array.py +++ b/tools/scripts/file-hex-array.py @@ -2,6 +2,7 @@ import binascii import os.path import sys + def tof(filepath): with open(filepath, 'r') as f: content = f.read() @@ -15,6 +16,7 @@ def tof(filepath): print(os.path.basename(filepath) + ".file created.") exit(0) + def toa(filepath): with open(filepath, 'rb') as f: content = f.read() @@ -28,6 +30,7 @@ def toa(filepath): print(os.path.basename(filepath) + ".array created.") exit(0) + def usage(): print("========================================================\n\ #\n\ -- cgit v1.2.3 From f34151ff0f91e8f0df8eaf829334b2205eb7da3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Tue, 1 Nov 2016 00:24:30 +0100 Subject: style: Various other PEP8 fixes in Python files Done with `autopep8 --select=E7`, fixes: - E701 - Put colon-separated compound statement on separate lines. - E702 - Put semicolon-separated compound statement on separate lines. - E703 - Put semicolon-separated compound statement on separate lines. - E711 - Fix comparison with None. - E712 - Fix (trivial case of) comparison with boolean. - E713 - Fix (trivial case of) non-membership check. - E721 - Fix various deprecated code (via lib2to3). --- tools/scripts/file-hex-array.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tools/scripts/file-hex-array.py') diff --git a/tools/scripts/file-hex-array.py b/tools/scripts/file-hex-array.py index da95c9505f..a6cdfe541f 100755 --- a/tools/scripts/file-hex-array.py +++ b/tools/scripts/file-hex-array.py @@ -9,7 +9,8 @@ def tof(filepath): content = content.replace("0x", "") content = content.split(',') for i in range(len(content)): - if len(content[i]) == 1: content[i] = "0" + content[i] + if len(content[i]) == 1: + content[i] = "0" + content[i] content = "".join(content) with open(filepath + ".file", 'wb') as f: content = f.write(content.decode("hex")) -- cgit v1.2.3