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/SCsub | 164 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 82 insertions(+), 82 deletions(-) (limited to 'tools/SCsub') diff --git a/tools/SCsub b/tools/SCsub index b0b33d4f01..a54b8f48a2 100644 --- a/tools/SCsub +++ b/tools/SCsub @@ -11,115 +11,115 @@ Export('env') def make_translations_header(target,source,env): - dst = target[0].srcnode().abspath + dst = target[0].srcnode().abspath - g = open(dst,"wb") + g = open(dst,"wb") - - """" + + """" """ - g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") - g.write("#ifndef _EDITOR_TRANSLATIONS_H\n") - g.write("#define _EDITOR_TRANSLATIONS_H\n") + g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") + g.write("#ifndef _EDITOR_TRANSLATIONS_H\n") + g.write("#define _EDITOR_TRANSLATIONS_H\n") - import zlib - import os.path + import zlib + import os.path - paths = [node.srcnode().abspath for node in source] - sorted_paths = sorted(paths, key=lambda path: os.path.splitext(os.path.basename(path))[0]) + paths = [node.srcnode().abspath for node in source] + sorted_paths = sorted(paths, key=lambda path: os.path.splitext(os.path.basename(path))[0]) - xl_names=[] - for i in range(len(sorted_paths)): - print("Appending translation: "+sorted_paths[i]) - f = open(sorted_paths[i],"rb") - buf = f.read() - decomp_size = len(buf) - buf = zlib.compress(buf) - name = os.path.splitext(os.path.basename(sorted_paths[i]))[0] + xl_names=[] + for i in range(len(sorted_paths)): + print("Appending translation: "+sorted_paths[i]) + f = open(sorted_paths[i],"rb") + buf = f.read() + decomp_size = len(buf) + buf = zlib.compress(buf) + name = os.path.splitext(os.path.basename(sorted_paths[i]))[0] - #g.write("static const int _translation_"+name+"_compressed_size="+str(len(buf))+";\n") - #g.write("static const int _translation_"+name+"_uncompressed_size="+str(decomp_size)+";\n") - g.write("static const unsigned char _translation_"+name+"_compressed[]={\n") - for i in range(len(buf)): - g.write(str(ord(buf[i]))+",\n") + #g.write("static const int _translation_"+name+"_compressed_size="+str(len(buf))+";\n") + #g.write("static const int _translation_"+name+"_uncompressed_size="+str(decomp_size)+";\n") + g.write("static const unsigned char _translation_"+name+"_compressed[]={\n") + for i in range(len(buf)): + g.write(str(ord(buf[i]))+",\n") - g.write("};\n") + g.write("};\n") - xl_names.append([name,len(buf),str(decomp_size)]) + xl_names.append([name,len(buf),str(decomp_size)]) - g.write("struct EditorTranslationList {\n") - g.write("\tconst char* lang;\n"); - g.write("\tint comp_size;\n"); - g.write("\tint uncomp_size;\n"); - g.write("\tconst unsigned char* data;\n"); - g.write("};\n\n"); - g.write("static EditorTranslationList _editor_translations[]={\n") - for x in xl_names: - g.write("\t{ \""+x[0]+"\", "+str(x[1])+", "+str(x[2])+",_translation_"+x[0]+"_compressed},\n") - g.write("\t{NULL,0,0,NULL}\n") - g.write("};\n") + g.write("struct EditorTranslationList {\n") + g.write("\tconst char* lang;\n"); + g.write("\tint comp_size;\n"); + g.write("\tint uncomp_size;\n"); + g.write("\tconst unsigned char* data;\n"); + g.write("};\n\n"); + g.write("static EditorTranslationList _editor_translations[]={\n") + for x in xl_names: + g.write("\t{ \""+x[0]+"\", "+str(x[1])+", "+str(x[2])+",_translation_"+x[0]+"_compressed},\n") + g.write("\t{NULL,0,0,NULL}\n") + g.write("};\n") - g.write("#endif") + g.write("#endif") def make_fonts_header(target,source,env): - dst = target[0].srcnode().abspath + dst = target[0].srcnode().abspath + + g = open(dst,"wb") - g = open(dst,"wb") - - """" + """" """ - g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") - g.write("#ifndef _EDITOR_FONTS_H\n") - g.write("#define _EDITOR_FONTS_H\n") - - #saving uncompressed, since freetype will reference from memory pointer - xl_names=[] - for i in range(len(source)): - print("Appending font: "+source[i].srcnode().abspath) - f = open(source[i].srcnode().abspath,"rb") - buf = f.read() - import os.path - - name = os.path.splitext(os.path.basename(source[i].srcnode().abspath))[0] - - g.write("static const int _font_"+name+"_size="+str(len(buf))+";\n") - g.write("static const unsigned char _font_"+name+"[]={\n") - for i in range(len(buf)): - g.write(str(ord(buf[i]))+",\n") - - g.write("};\n") - - g.write("#endif") - - + g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") + g.write("#ifndef _EDITOR_FONTS_H\n") + g.write("#define _EDITOR_FONTS_H\n") + + #saving uncompressed, since freetype will reference from memory pointer + xl_names=[] + for i in range(len(source)): + print("Appending font: "+source[i].srcnode().abspath) + f = open(source[i].srcnode().abspath,"rb") + buf = f.read() + import os.path + + name = os.path.splitext(os.path.basename(source[i].srcnode().abspath))[0] + + g.write("static const int _font_"+name+"_size="+str(len(buf))+";\n") + g.write("static const unsigned char _font_"+name+"[]={\n") + for i in range(len(buf)): + g.write(str(ord(buf[i]))+",\n") + + g.write("};\n") + + g.write("#endif") + + if (env["tools"]!="no"): - import glob + import glob - dir = env.Dir('.').abspath - tlist = glob.glob(dir + "/translations/*.po") + dir = env.Dir('.').abspath + tlist = glob.glob(dir + "/translations/*.po") - print("translations: ",tlist) - env.Depends('#tools/editor/translations.h',tlist) - env.Command('#tools/editor/translations.h',tlist,make_translations_header) + print("translations: ",tlist) + env.Depends('#tools/editor/translations.h',tlist) + env.Command('#tools/editor/translations.h',tlist,make_translations_header) - flist = glob.glob(dir + "/editor_fonts/*.ttf") - flist.append( glob.glob(dir + "/editor_fonts/*.otf") ) + flist = glob.glob(dir + "/editor_fonts/*.ttf") + flist.append( glob.glob(dir + "/editor_fonts/*.otf") ) - print("fonts: ",flist) - env.Depends('#tools/editor/builtin_fonts.h',flist) - env.Command('#tools/editor/builtin_fonts.h',flist,make_fonts_header) + print("fonts: ",flist) + env.Depends('#tools/editor/builtin_fonts.h',flist) + env.Command('#tools/editor/builtin_fonts.h',flist,make_fonts_header) - SConscript('editor/SCsub'); - SConscript('collada/SCsub'); - SConscript('doc/SCsub') + SConscript('editor/SCsub'); + SConscript('collada/SCsub'); + SConscript('doc/SCsub') - lib = env.Library("tool",env.tool_sources) + lib = env.Library("tool",env.tool_sources) - env.Prepend(LIBS=[lib]) + env.Prepend(LIBS=[lib]) -- 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/SCsub | 62 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'tools/SCsub') diff --git a/tools/SCsub b/tools/SCsub index a54b8f48a2..87ed836ae0 100644 --- a/tools/SCsub +++ b/tools/SCsub @@ -2,18 +2,18 @@ Import('env') -env.tool_sources=[] -env.add_source_files(env.tool_sources,"*.cpp") +env.tool_sources = [] +env.add_source_files(env.tool_sources, "*.cpp") Export('env') -def make_translations_header(target,source,env): +def make_translations_header(target, source, env): dst = target[0].srcnode().abspath - g = open(dst,"wb") + g = open(dst, "wb") """" @@ -29,24 +29,24 @@ def make_translations_header(target,source,env): paths = [node.srcnode().abspath for node in source] sorted_paths = sorted(paths, key=lambda path: os.path.splitext(os.path.basename(path))[0]) - xl_names=[] + xl_names = [] for i in range(len(sorted_paths)): - print("Appending translation: "+sorted_paths[i]) - f = open(sorted_paths[i],"rb") + print("Appending translation: " + sorted_paths[i]) + f = open(sorted_paths[i], "rb") buf = f.read() decomp_size = len(buf) buf = zlib.compress(buf) - name = os.path.splitext(os.path.basename(sorted_paths[i]))[0] + name = os.path.splitext(os.path.basename(sorted_paths[i]))[0] #g.write("static const int _translation_"+name+"_compressed_size="+str(len(buf))+";\n") #g.write("static const int _translation_"+name+"_uncompressed_size="+str(decomp_size)+";\n") - g.write("static const unsigned char _translation_"+name+"_compressed[]={\n") + g.write("static const unsigned char _translation_" + name + "_compressed[]={\n") for i in range(len(buf)): - g.write(str(ord(buf[i]))+",\n") + g.write(str(ord(buf[i])) + ",\n") g.write("};\n") - xl_names.append([name,len(buf),str(decomp_size)]) + xl_names.append([name, len(buf), str(decomp_size)]) g.write("struct EditorTranslationList {\n") g.write("\tconst char* lang;\n"); @@ -56,19 +56,19 @@ def make_translations_header(target,source,env): g.write("};\n\n"); g.write("static EditorTranslationList _editor_translations[]={\n") for x in xl_names: - g.write("\t{ \""+x[0]+"\", "+str(x[1])+", "+str(x[2])+",_translation_"+x[0]+"_compressed},\n") + g.write("\t{ \"" + x[0] + "\", " + str(x[1]) + ", " + str(x[2]) + ",_translation_" + x[0] + "_compressed},\n") g.write("\t{NULL,0,0,NULL}\n") g.write("};\n") g.write("#endif") -def make_fonts_header(target,source,env): +def make_fonts_header(target, source, env): dst = target[0].srcnode().abspath - g = open(dst,"wb") + g = open(dst, "wb") """" @@ -78,48 +78,48 @@ def make_fonts_header(target,source,env): g.write("#ifndef _EDITOR_FONTS_H\n") g.write("#define _EDITOR_FONTS_H\n") - #saving uncompressed, since freetype will reference from memory pointer - xl_names=[] + # saving uncompressed, since freetype will reference from memory pointer + xl_names = [] for i in range(len(source)): - print("Appending font: "+source[i].srcnode().abspath) - f = open(source[i].srcnode().abspath,"rb") + print("Appending font: " + source[i].srcnode().abspath) + f = open(source[i].srcnode().abspath, "rb") buf = f.read() import os.path - name = os.path.splitext(os.path.basename(source[i].srcnode().abspath))[0] + name = os.path.splitext(os.path.basename(source[i].srcnode().abspath))[0] - g.write("static const int _font_"+name+"_size="+str(len(buf))+";\n") - g.write("static const unsigned char _font_"+name+"[]={\n") + g.write("static const int _font_" + name + "_size=" + str(len(buf)) + ";\n") + g.write("static const unsigned char _font_" + name + "[]={\n") for i in range(len(buf)): - g.write(str(ord(buf[i]))+",\n") + g.write(str(ord(buf[i])) + ",\n") g.write("};\n") g.write("#endif") -if (env["tools"]!="no"): +if (env["tools"] != "no"): import glob dir = env.Dir('.').abspath tlist = glob.glob(dir + "/translations/*.po") - print("translations: ",tlist) - env.Depends('#tools/editor/translations.h',tlist) - env.Command('#tools/editor/translations.h',tlist,make_translations_header) + print("translations: ", tlist) + env.Depends('#tools/editor/translations.h', tlist) + env.Command('#tools/editor/translations.h', tlist, make_translations_header) flist = glob.glob(dir + "/editor_fonts/*.ttf") - flist.append( glob.glob(dir + "/editor_fonts/*.otf") ) + flist.append(glob.glob(dir + "/editor_fonts/*.otf")) - print("fonts: ",flist) - env.Depends('#tools/editor/builtin_fonts.h',flist) - env.Command('#tools/editor/builtin_fonts.h',flist,make_fonts_header) + print("fonts: ", flist) + env.Depends('#tools/editor/builtin_fonts.h', flist) + env.Command('#tools/editor/builtin_fonts.h', flist, make_fonts_header) SConscript('editor/SCsub'); SConscript('collada/SCsub'); SConscript('doc/SCsub') - lib = env.Library("tool",env.tool_sources) + lib = env.Library("tool", env.tool_sources) env.Prepend(LIBS=[lib]) -- 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/SCsub | 4 ---- 1 file changed, 4 deletions(-) (limited to 'tools/SCsub') diff --git a/tools/SCsub b/tools/SCsub index 87ed836ae0..f11aa34ee6 100644 --- a/tools/SCsub +++ b/tools/SCsub @@ -10,12 +10,10 @@ Export('env') def make_translations_header(target, source, env): - dst = target[0].srcnode().abspath g = open(dst, "wb") - """" """ @@ -65,12 +63,10 @@ def make_translations_header(target, source, env): def make_fonts_header(target, source, env): - dst = target[0].srcnode().abspath g = open(dst, "wb") - """" """ -- 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/SCsub | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'tools/SCsub') diff --git a/tools/SCsub b/tools/SCsub index f11aa34ee6..43cad794d4 100644 --- a/tools/SCsub +++ b/tools/SCsub @@ -47,11 +47,11 @@ def make_translations_header(target, source, env): xl_names.append([name, len(buf), str(decomp_size)]) g.write("struct EditorTranslationList {\n") - g.write("\tconst char* lang;\n"); - g.write("\tint comp_size;\n"); - g.write("\tint uncomp_size;\n"); - g.write("\tconst unsigned char* data;\n"); - g.write("};\n\n"); + g.write("\tconst char* lang;\n") + g.write("\tint comp_size;\n") + g.write("\tint uncomp_size;\n") + g.write("\tconst unsigned char* data;\n") + g.write("};\n\n") g.write("static EditorTranslationList _editor_translations[]={\n") for x in xl_names: g.write("\t{ \"" + x[0] + "\", " + str(x[1]) + ", " + str(x[2]) + ",_translation_" + x[0] + "_compressed},\n") @@ -112,8 +112,8 @@ if (env["tools"] != "no"): env.Depends('#tools/editor/builtin_fonts.h', flist) env.Command('#tools/editor/builtin_fonts.h', flist, make_fonts_header) - SConscript('editor/SCsub'); - SConscript('collada/SCsub'); + SConscript('editor/SCsub') + SConscript('collada/SCsub') SConscript('doc/SCsub') lib = env.Library("tool", env.tool_sources) -- cgit v1.2.3