diff options
Diffstat (limited to 'release/datafiles/datatoc.py')
-rwxr-xr-x | release/datafiles/datatoc.py | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/release/datafiles/datatoc.py b/release/datafiles/datatoc.py index 32d4749a007..8a0e5290cb5 100755 --- a/release/datafiles/datatoc.py +++ b/release/datafiles/datatoc.py @@ -24,26 +24,29 @@ # # ***** END GPL LICENCE BLOCK ***** -import sys, os +# <pep8 compliant> + +import sys +import os if len(sys.argv) < 2: - sys.stdout.write("Usage: datatoc <data_file>\n") - sys.exit(1) + sys.stdout.write("Usage: datatoc <data_file>\n") + sys.exit(1) filename = sys.argv[1] try: - fpin = open(filename, "rb"); + fpin = open(filename, "rb") except: - sys.stdout.write("Unable to open input %s\n" % sys.argv[1]) - sys.exit(1) + sys.stdout.write("Unable to open input %s\n" % sys.argv[1]) + sys.exit(1) fpin.seek(0, os.SEEK_END) size = fpin.tell() fpin.seek(0) if filename[0] == ".": - filename = filename[1:] + filename = filename[1:] cname = filename + ".c" sys.stdout.write("Making C file <%s>\n" % cname) @@ -53,10 +56,10 @@ filename = filename.replace(".", "_") sys.stdout.write(str(size)) sys.stdout.write("\n") try: - fpout = open(cname, "w") + fpout = open(cname, "w") except: - sys.stdout.write("Unable to open output %s\n" % cname) - sys.exit(1) + sys.stdout.write("Unable to open output %s\n" % cname) + sys.exit(1) fpout.write("/* DataToC output of file <%s> */\n\n" % filename) fpout.write("int datatoc_%s_size= %d;\n" % (filename, size)) @@ -64,11 +67,11 @@ fpout.write("int datatoc_%s_size= %d;\n" % (filename, size)) fpout.write("char datatoc_%s[]= {\n" % filename) while size > 0: - size -= 1 - if size % 32 == 31: - fpout.write("\n") + size -= 1 + if size % 32 == 31: + fpout.write("\n") - fpout.write("%3d," % ord(fpin.read(1))) + fpout.write("%3d," % ord(fpin.read(1))) fpout.write("\n 0};\n\n") |