diff options
| author | Rémi Verschelde | 2016-10-30 18:57:40 +0100 |
|---|---|---|
| committer | Rémi Verschelde | 2016-11-01 00:35:16 +0100 |
| commit | d4c17700aa2f36f69978beda04e42ff2749de270 (patch) | |
| tree | 466f774d5fff723d6496e7259529c366fe01855a /tools | |
| parent | 97c8508f5e4f57b1048830d44e76e1f4517fd449 (diff) | |
| download | godot-d4c17700aa2f36f69978beda04e42ff2749de270.tar.gz godot-d4c17700aa2f36f69978beda04e42ff2749de270.tar.zst godot-d4c17700aa2f36f69978beda04e42ff2749de270.zip | |
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.
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/SCsub | 62 | ||||
| -rw-r--r-- | tools/collada/SCsub | 2 | ||||
| -rw-r--r-- | tools/doc/SCsub | 2 | ||||
| -rw-r--r-- | tools/editor/SCsub | 52 | ||||
| -rw-r--r-- | tools/editor/fileserver/SCsub | 2 | ||||
| -rw-r--r-- | tools/editor/icons/SCsub | 56 | ||||
| -rw-r--r-- | tools/editor/io_plugins/SCsub | 2 | ||||
| -rw-r--r-- | tools/editor/plugins/SCsub | 2 | ||||
| -rw-r--r-- | tools/scripts/addheader.py | 56 | ||||
| -rwxr-xr-x | tools/scripts/file-hex-array.py | 14 | ||||
| -rw-r--r-- | tools/scripts/make_bmfhdr.py | 58 | ||||
| -rw-r--r-- | tools/scripts/make_glwrapper.py | 100 | ||||
| -rw-r--r-- | tools/scripts/makeargs.py | 26 | ||||
| -rw-r--r-- | tools/scripts/memsort.py | 30 | ||||
| -rw-r--r-- | tools/scripts/svgs_2_pngs.py | 38 | ||||
| -rwxr-xr-x | tools/translations/extract.py | 6 |
16 files changed, 254 insertions, 254 deletions
diff --git a/tools/SCsub b/tools/SCsub index a54b8f48a..87ed836ae 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]) diff --git a/tools/collada/SCsub b/tools/collada/SCsub index 473474201..4bc64ffdc 100644 --- a/tools/collada/SCsub +++ b/tools/collada/SCsub @@ -2,6 +2,6 @@ Import('env') -env.add_source_files(env.tool_sources,"*.cpp") +env.add_source_files(env.tool_sources, "*.cpp") Export('env') diff --git a/tools/doc/SCsub b/tools/doc/SCsub index 473474201..4bc64ffdc 100644 --- a/tools/doc/SCsub +++ b/tools/doc/SCsub @@ -2,6 +2,6 @@ Import('env') -env.add_source_files(env.tool_sources,"*.cpp") +env.add_source_files(env.tool_sources, "*.cpp") Export('env') diff --git a/tools/editor/SCsub b/tools/editor/SCsub index 41b4386e2..0dbb7d3f2 100644 --- a/tools/editor/SCsub +++ b/tools/editor/SCsub @@ -3,12 +3,12 @@ Import('env') -def make_doc_header(target,source,env): +def make_doc_header(target, source, env): src = source[0].srcnode().abspath dst = target[0].srcnode().abspath - f = open(src,"rb") - g = open(dst,"wb") + f = open(src, "rb") + g = open(dst, "wb") buf = f.read() decomp_size = len(buf) import zlib @@ -18,22 +18,22 @@ def make_doc_header(target,source,env): g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") g.write("#ifndef _DOC_DATA_RAW_H\n") g.write("#define _DOC_DATA_RAW_H\n") - g.write("static const int _doc_data_compressed_size="+str(len(buf))+";\n") - g.write("static const int _doc_data_uncompressed_size="+str(decomp_size)+";\n") + g.write("static const int _doc_data_compressed_size=" + str(len(buf)) + ";\n") + g.write("static const int _doc_data_uncompressed_size=" + str(decomp_size) + ";\n") g.write("static const unsigned char _doc_data_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") g.write("#endif") -def make_certs_header(target,source,env): +def make_certs_header(target, source, env): src = source[0].srcnode().abspath dst = target[0].srcnode().abspath - f = open(src,"rb") - g = open(dst,"wb") + f = open(src, "rb") + g = open(dst, "wb") buf = f.read() decomp_size = len(buf) import zlib @@ -43,11 +43,11 @@ def make_certs_header(target,source,env): g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") g.write("#ifndef _CERTS_RAW_H\n") g.write("#define _CERTS_RAW_H\n") - g.write("static const int _certs_compressed_size="+str(len(buf))+";\n") - g.write("static const int _certs_uncompressed_size="+str(decomp_size)+";\n") + g.write("static const int _certs_compressed_size=" + str(len(buf)) + ";\n") + g.write("static const int _certs_uncompressed_size=" + str(decomp_size) + ";\n") g.write("static const unsigned char _certs_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") g.write("#endif") @@ -57,29 +57,29 @@ def make_certs_header(target,source,env): -if (env["tools"]=="yes"): +if (env["tools"] == "yes"): - reg_exporters_inc='#include "register_exporters.h"\n' - reg_exporters='void register_exporters() {\n' + reg_exporters_inc = '#include "register_exporters.h"\n' + reg_exporters = 'void register_exporters() {\n' for e in env.platform_exporters: - env.tool_sources.append("#platform/"+e+"/export/export.cpp") - reg_exporters+='\tregister_'+e+'_exporter();\n' - reg_exporters_inc+='#include "platform/'+e+'/export/export.h"\n' - reg_exporters+='}\n' - f = open("register_exporters.cpp","wb") + env.tool_sources.append("#platform/" + e + "/export/export.cpp") + reg_exporters += '\tregister_' + e + '_exporter();\n' + reg_exporters_inc += '#include "platform/' + e + '/export/export.h"\n' + reg_exporters += '}\n' + f = open("register_exporters.cpp", "wb") f.write(reg_exporters_inc) f.write(reg_exporters) f.close() - env.Depends("#tools/editor/doc_data_compressed.h","#doc/base/classes.xml") - env.Command("#tools/editor/doc_data_compressed.h","#doc/base/classes.xml",make_doc_header) + env.Depends("#tools/editor/doc_data_compressed.h", "#doc/base/classes.xml") + env.Command("#tools/editor/doc_data_compressed.h", "#doc/base/classes.xml", make_doc_header) - env.Depends("#tools/editor/certs_compressed.h","#tools/certs/ca-certificates.crt") - env.Command("#tools/editor/certs_compressed.h","#tools/certs/ca-certificates.crt",make_certs_header) + env.Depends("#tools/editor/certs_compressed.h", "#tools/certs/ca-certificates.crt") + env.Command("#tools/editor/certs_compressed.h", "#tools/certs/ca-certificates.crt", make_certs_header) - #make_doc_header(env.File("#tools/editor/doc_data_raw.h").srcnode().abspath,env.File("#doc/base/classes.xml").srcnode().abspath,env) + # make_doc_header(env.File("#tools/editor/doc_data_raw.h").srcnode().abspath,env.File("#doc/base/classes.xml").srcnode().abspath,env) - env.add_source_files(env.tool_sources,"*.cpp") + env.add_source_files(env.tool_sources, "*.cpp") Export('env') SConscript('icons/SCsub'); diff --git a/tools/editor/fileserver/SCsub b/tools/editor/fileserver/SCsub index 6299fd416..4bf55189c 100644 --- a/tools/editor/fileserver/SCsub +++ b/tools/editor/fileserver/SCsub @@ -2,4 +2,4 @@ Import('env') Export('env') -env.add_source_files(env.tool_sources,"*.cpp") +env.add_source_files(env.tool_sources, "*.cpp") diff --git a/tools/editor/icons/SCsub b/tools/editor/icons/SCsub index 4806a89df..ac942b20e 100644 --- a/tools/editor/icons/SCsub +++ b/tools/editor/icons/SCsub @@ -16,47 +16,47 @@ def make_editor_icons_action(target, source, env): s.write("#include \"editor_scale.h\"\n\n") s.write("#include \"scene/resources/theme.h\"\n\n") - hidpi_list=[] + hidpi_list = [] for x in pixmaps: - x=str(x) - var_str=os.path.basename(x)[:-4]+"_png"; - #print(var_str) + x = str(x) + var_str = os.path.basename(x)[:-4] + "_png"; + # print(var_str) - s.write("static const unsigned char "+ var_str +"[]={\n"); + s.write("static const unsigned char " + var_str + "[]={\n"); - pngf=open(x,"rb"); + pngf = open(x, "rb"); - b=pngf.read(1); - while(len(b)==1): + b = pngf.read(1); + while(len(b) == 1): s.write(hex(ord(b))) - b=pngf.read(1); - if (len(b)==1): + b = pngf.read(1); + if (len(b) == 1): s.write(",") s.write("\n};\n\n"); pngf.close(); - var_str=os.path.basename(x)[:-4]+"_hidpi_png"; + var_str = os.path.basename(x)[:-4] + "_hidpi_png"; try: - pngf = open(os.path.dirname(x)+"/2x/"+os.path.basename(x), "rb") + pngf = open(os.path.dirname(x) + "/2x/" + os.path.basename(x), "rb") - s.write("static const unsigned char "+ var_str +"[]={\n"); + s.write("static const unsigned char " + var_str + "[]={\n"); - b=pngf.read(1); - while(len(b)==1): + b = pngf.read(1); + while(len(b) == 1): s.write(hex(ord(b))) - b=pngf.read(1); - if (len(b)==1): + b = pngf.read(1); + if (len(b) == 1): s.write(",") s.write("\n};\n\n\n"); hidpi_list.append(x) except: - s.write("static const unsigned char* "+ var_str +"=NULL;\n\n\n"); + s.write("static const unsigned char* " + var_str + "=NULL;\n\n\n"); @@ -75,24 +75,24 @@ def make_editor_icons_action(target, source, env): for x in pixmaps: - x=os.path.basename(str(x)) - type=x[5:-4].title().replace("_",""); - var_str=x[:-4]+"_png"; - var_str_hidpi=x[:-4]+"_hidpi_png"; - s.write("\tp_theme->set_icon(\""+type+"\",\"EditorIcons\",make_icon("+var_str+","+var_str_hidpi+"));\n"); + x = os.path.basename(str(x)) + type = x[5:-4].title().replace("_", ""); + var_str = x[:-4] + "_png"; + var_str_hidpi = x[:-4] + "_hidpi_png"; + s.write("\tp_theme->set_icon(\"" + type + "\",\"EditorIcons\",make_icon(" + var_str + "," + var_str_hidpi + "));\n"); s.write("\n\n}\n\n"); - f = open(dst,"wb") + f = open(dst, "wb") f.write(s.getvalue()) f.close() s.close() make_editor_icons_builder = Builder(action=make_editor_icons_action, - suffix = '.cpp', - src_suffix = '.png') -env['BUILDERS']['MakeEditorIconsBuilder']=make_editor_icons_builder -env.Alias('editor_icons',[env.MakeEditorIconsBuilder('#tools/editor/editor_icons.cpp',Glob("*.png"))]) + suffix='.cpp', + src_suffix='.png') +env['BUILDERS']['MakeEditorIconsBuilder'] = make_editor_icons_builder +env.Alias('editor_icons', [env.MakeEditorIconsBuilder('#tools/editor/editor_icons.cpp', Glob("*.png"))]) env.tool_sources.append("#tools/editor/editor_icons.cpp") Export('env') diff --git a/tools/editor/io_plugins/SCsub b/tools/editor/io_plugins/SCsub index 6299fd416..4bf55189c 100644 --- a/tools/editor/io_plugins/SCsub +++ b/tools/editor/io_plugins/SCsub @@ -2,4 +2,4 @@ Import('env') Export('env') -env.add_source_files(env.tool_sources,"*.cpp") +env.add_source_files(env.tool_sources, "*.cpp") diff --git a/tools/editor/plugins/SCsub b/tools/editor/plugins/SCsub index 6299fd416..4bf55189c 100644 --- a/tools/editor/plugins/SCsub +++ b/tools/editor/plugins/SCsub @@ -2,4 +2,4 @@ Import('env') Export('env') -env.add_source_files(env.tool_sources,"*.cpp") +env.add_source_files(env.tool_sources, "*.cpp") diff --git a/tools/scripts/addheader.py b/tools/scripts/addheader.py index fac35372d..573d5182f 100644 --- a/tools/scripts/addheader.py +++ b/tools/scripts/addheader.py @@ -1,4 +1,4 @@ -header="""\ +header = """\ /*************************************************************************/ /* $filename */ /*************************************************************************/ @@ -29,44 +29,44 @@ header="""\ /*************************************************************************/ """ -f = open("files","rb") +f = open("files", "rb") fname = f.readline() -while (fname!=""): +while (fname != ""): - fr = open(fname.strip(),"rb") + fr = open(fname.strip(), "rb") l = fr.readline() - bc=False + bc = False fsingle = fname.strip() - if (fsingle.find("/")!=-1): - fsingle=fsingle[fsingle.rfind("/")+1:] - rep_fl="$filename" - rep_fi=fsingle - len_fl=len(rep_fl) - len_fi=len(rep_fi) - if (len_fi<len_fl): - for x in range(len_fl-len_fi): - rep_fi+=" " - elif (len_fl<len_fi): - for x in range(len_fi-len_fl): - rep_fl+=" " - if (header.find(rep_fl)!=-1): - text=header.replace(rep_fl,rep_fi) + if (fsingle.find("/") != -1): + fsingle = fsingle[fsingle.rfind("/") + 1:] + rep_fl = "$filename" + rep_fi = fsingle + len_fl = len(rep_fl) + len_fi = len(rep_fi) + if (len_fi < len_fl): + for x in range(len_fl - len_fi): + rep_fi += " " + elif (len_fl < len_fi): + for x in range(len_fi - len_fl): + rep_fl += " " + if (header.find(rep_fl) != -1): + text = header.replace(rep_fl, rep_fi) else: - text=header.replace("$filename",fsingle) + text = header.replace("$filename", fsingle) - while (l!=""): - if ((l.find("//")!=0 and l.find("/*")!=0 and l.strip()!="") or bc): - text+=l - bc=True - l=fr.readline() + while (l != ""): + if ((l.find("//") != 0 and l.find("/*") != 0 and l.strip() != "") or bc): + text += l + bc = True + l = fr.readline() fr.close() - fr=open(fname.strip(),"wb") + fr = open(fname.strip(), "wb") fr.write(text) fr.close() - #print(text) - fname=f.readline() + # print(text) + fname = f.readline() diff --git a/tools/scripts/file-hex-array.py b/tools/scripts/file-hex-array.py index f50dcd4e2..8b7c3edd7 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(): diff --git a/tools/scripts/make_bmfhdr.py b/tools/scripts/make_bmfhdr.py index 3fa97c8fe..e6aa43f6b 100644 --- a/tools/scripts/make_bmfhdr.py +++ b/tools/scripts/make_bmfhdr.py @@ -2,43 +2,43 @@ import sys -if (len(sys.argv)!=2): +if (len(sys.argv) != 2): print("Pass me a .fnt argument!") -f = open(sys.argv[1],"rb") +f = open(sys.argv[1], "rb") -name = sys.argv[1].lower().replace(".fnt","") +name = sys.argv[1].lower().replace(".fnt", "") l = f.readline() -font_height=0 -font_ascent=0 -font_charcount=0 -font_chars=[] -font_cc=0 +font_height = 0 +font_ascent = 0 +font_charcount = 0 +font_chars = [] +font_cc = 0 -while(l!=""): +while(l != ""): fs = l.strip().find(" ") - if (fs==-1): - l=f.readline() + if (fs == -1): + l = f.readline() continue - t = l[0:fs] + t = l[0:fs] - dv = l[fs+1:].split(" ") + dv = l[fs + 1:].split(" ") d = {} for x in dv: - if (x.find("=")==-1): + if (x.find("=") == -1): continue s = x.split("=") - d[ s[0] ] = s[1] + d[s[0]] = s[1] - if (t=="common"): - font_height=d["lineHeight"] - font_ascent=d["base"] + if (t == "common"): + font_height = d["lineHeight"] + font_ascent = d["base"] - if (t=="char"): + if (t == "char"): font_chars.append(d["id"]) font_chars.append(d["x"]) font_chars.append(d["y"]) @@ -47,24 +47,24 @@ while(l!=""): font_chars.append(d["xoffset"]) font_chars.append(d["yoffset"]) font_chars.append(d["xadvance"]) - font_cc+=1 + font_cc += 1 l = f.readline() -print("static const int _bi_font_"+name+"_height="+str(font_height)+";") -print("static const int _bi_font_"+name+"_ascent="+str(font_ascent)+";") -print("static const int _bi_font_"+name+"_charcount="+str(font_cc)+";") -cstr="static const int _bi_font_"+name+"_characters={" +print("static const int _bi_font_" + name + "_height=" + str(font_height) + ";") +print("static const int _bi_font_" + name + "_ascent=" + str(font_ascent) + ";") +print("static const int _bi_font_" + name + "_charcount=" + str(font_cc) + ";") +cstr = "static const int _bi_font_" + name + "_characters={" for i in range(len(font_chars)): - c=font_chars[i] - if (i>0): - cstr+=", " - cstr+=c + c = font_chars[i] + if (i > 0): + cstr += ", " + cstr += c -cstr+=("};") +cstr += ("};") print(cstr) diff --git a/tools/scripts/make_glwrapper.py b/tools/scripts/make_glwrapper.py index 8da4e28c8..9f26f8430 100644 --- a/tools/scripts/make_glwrapper.py +++ b/tools/scripts/make_glwrapper.py @@ -1,31 +1,31 @@ #! /usr/bin/env python import sys -if (len(sys.argv)<2): +if (len(sys.argv) < 2): print("usage: make_glwrapper.py <headers>") sys.exit(255) -functions=[] -types=[] -constants=[] +functions = [] +types = [] +constants = [] -READ_FUNCTIONS=0 -READ_TYPES=1 -READ_CONSTANTS=2 +READ_FUNCTIONS = 0 +READ_TYPES = 1 +READ_CONSTANTS = 2 -read_what=READ_TYPES +read_what = READ_TYPES -for x in (range(len(sys.argv)-1)): - f=open(sys.argv[x+1],"r") +for x in (range(len(sys.argv) - 1)): + f = open(sys.argv[x + 1], "r") while(True): - line=f.readline() - if (line==""): + line = f.readline() + if (line == ""): break - line=line.replace("\n","").strip() + line = line.replace("\n", "").strip() """ if (line.find("[types]")!=-1): read_what=READ_TYPES @@ -38,67 +38,67 @@ for x in (range(len(sys.argv)-1)): continue """ - if (line.find("#define")!=-1): - if (line.find("0x")==-1 and line.find("GL_VERSION")==-1): + if (line.find("#define") != -1): + if (line.find("0x") == -1 and line.find("GL_VERSION") == -1): continue constants.append(line) - elif (line.find("typedef")!=-1): - if (line.find("(")!=-1 or line.find(")")!=-1 or line.find("ARB")!=-1 or line.find("EXT")!=-1 or line.find("GL")==-1): + elif (line.find("typedef") != -1): + if (line.find("(") != -1 or line.find(")") != -1 or line.find("ARB") != -1 or line.find("EXT") != -1 or line.find("GL") == -1): continue types.append(line) - elif (line.find("APIENTRY")!=-1 and line.find("GLAPI")!=-1): + elif (line.find("APIENTRY") != -1 and line.find("GLAPI") != -1): - if (line.find("ARB")!=-1 or line.find("EXT")!=-1 or line.find("NV")!=-1): + if (line.find("ARB") != -1 or line.find("EXT") != -1 or line.find("NV") != -1): continue - line=line.replace("APIENTRY","") - line=line.replace("GLAPI","") + line = line.replace("APIENTRY", "") + line = line.replace("GLAPI", "") - glpos=line.find(" gl") - if (glpos==-1): + glpos = line.find(" gl") + if (glpos == -1): - glpos=line.find("\tgl") - if (glpos==-1): + glpos = line.find("\tgl") + if (glpos == -1): continue - ret=line[:glpos].strip(); + ret = line[:glpos].strip(); - line=line[glpos:].strip() - namepos=line.find("(") + line = line[glpos:].strip() + namepos = line.find("(") - if (namepos==-1): + if (namepos == -1): continue - name=line[:namepos].strip() - line=line[namepos:] + name = line[:namepos].strip() + line = line[namepos:] - argpos=line.rfind(")") - if (argpos==-1): + argpos = line.rfind(")") + if (argpos == -1): continue - args=line[1:argpos] + args = line[1:argpos] - funcdata={} - funcdata["ret"]=ret - funcdata["name"]=name - funcdata["args"]=args + funcdata = {} + funcdata["ret"] = ret + funcdata["name"] = name + funcdata["args"] = args functions.append(funcdata) print(funcdata) -#print(types) -#print(constants) -#print(functions) +# print(types) +# print(constants) +# print(functions) -f=open("glwrapper.h","w") +f = open("glwrapper.h", "w") f.write("#ifndef GL_WRAPPER\n") f.write("#define GL_WRAPPER\n\n\n") -header_code="""\ +header_code = """\ #if defined(__gl_h_) || defined(__GL_H__) #error gl.h included before glwrapper.h #endif @@ -137,18 +137,18 @@ f.write("#else\n"); f.write("#define GLWRP_APIENTRY \n") f.write("#endif\n\n"); for x in types: - f.write(x+"\n") + f.write(x + "\n") f.write("\n\n") for x in constants: - f.write(x+"\n") + f.write(x + "\n") f.write("\n\n") for x in functions: - f.write("extern "+x["ret"]+" GLWRP_APIENTRY (*__wrapper_"+x["name"]+")("+x["args"]+");\n") - f.write("#define "+x["name"]+" __wrapper_"+x["name"]+"\n") + f.write("extern " + x["ret"] + " GLWRP_APIENTRY (*__wrapper_" + x["name"] + ")(" + x["args"] + ");\n") + f.write("#define " + x["name"] + " __wrapper_" + x["name"] + "\n") f.write("\n\n") f.write("typedef void (*GLWrapperFuncPtr)(void);\n\n"); @@ -158,21 +158,21 @@ f.write("#ifdef __cplusplus\n}\n#endif\n") f.write("#endif\n\n") -f=open("glwrapper.c","w") +f = open("glwrapper.c", "w") f.write("\n\n") f.write("#include \"glwrapper.h\"\n") f.write("\n\n") for x in functions: - f.write(x["ret"]+" GLWRP_APIENTRY (*__wrapper_"+x["name"]+")("+x["args"]+")=NULL;\n") + f.write(x["ret"] + " GLWRP_APIENTRY (*__wrapper_" + x["name"] + ")(" + x["args"] + ")=NULL;\n") f.write("\n\n") f.write("void glWrapperInit( GLWrapperFuncPtr (*wrapperFunc)(const char*) ) {\n") f.write("\n") for x in functions: - f.write("\t__wrapper_"+x["name"]+"=("+x["ret"]+" GLWRP_APIENTRY (*)("+x["args"]+"))wrapperFunc(\""+x["name"]+"\");\n") + f.write("\t__wrapper_" + x["name"] + "=(" + x["ret"] + " GLWRP_APIENTRY (*)(" + x["args"] + "))wrapperFunc(\"" + x["name"] + "\");\n") f.write("\n\n") f.write("}\n") diff --git a/tools/scripts/makeargs.py b/tools/scripts/makeargs.py index 7db9da82a..a52812eaf 100644 --- a/tools/scripts/makeargs.py +++ b/tools/scripts/makeargs.py @@ -1,5 +1,5 @@ -text=""" +text = """ #define FUNC$numR(m_r,m_func,$argt)\\ virtual m_r m_func($argtp) { \\ if (Thread::get_caller_ID()!=server_thread) {\\ @@ -65,21 +65,21 @@ text=""" -for i in range(1,8): +for i in range(1, 8): - tp="" - p="" - t="" + tp = "" + p = "" + t = "" for j in range(i): - if (j>0): - tp+=", " - p+=", " - t+=", " - tp +=("m_arg"+str(j+1)+" p"+str(j+1)) - p+=("p"+str(j+1)) - t+=("m_arg"+str(j+1)) + if (j > 0): + tp += ", " + p += ", " + t += ", " + tp += ("m_arg" + str(j + 1) + " p" + str(j + 1)) + p += ("p" + str(j + 1)) + t += ("m_arg" + str(j + 1)) - t = text.replace("$argtp",tp).replace("$argp",p).replace("$argt",t).replace("$num",str(i)) + t = text.replace("$argtp", tp).replace("$argp", p).replace("$argt", t).replace("$num", str(i)) print(t) diff --git a/tools/scripts/memsort.py b/tools/scripts/memsort.py index 15b4e7a84..fb636b0f7 100644 --- a/tools/scripts/memsort.py +++ b/tools/scripts/memsort.py @@ -1,35 +1,35 @@ import sys -arg="memdump.txt" +arg = "memdump.txt" -if (len(sys.argv)>1): - arg=sys.argv[1] +if (len(sys.argv) > 1): + arg = sys.argv[1] -f = open(arg,"rb") +f = open(arg, "rb") -l=f.readline() +l = f.readline() sum = {} -cnt={} +cnt = {} -while(l!=""): +while(l != ""): - s=l.split("-") + s = l.split("-") amount = int(s[1]) - what=s[2] + what = s[2] if (what in sum): - sum[what]+=amount - cnt[what]+=1 + sum[what] += amount + cnt[what] += 1 else: - sum[what]=amount - cnt[what]=1 + sum[what] = amount + cnt[what] = 1 - l=f.readline() + l = f.readline() for x in sum: - print(x.strip()+"("+str(cnt[x])+"):\n: "+str(sum[x])) + print(x.strip() + "(" + str(cnt[x]) + "):\n: " + str(sum[x])) diff --git a/tools/scripts/svgs_2_pngs.py b/tools/scripts/svgs_2_pngs.py index 4de69a14b..b55fd97d0 100644 --- a/tools/scripts/svgs_2_pngs.py +++ b/tools/scripts/svgs_2_pngs.py @@ -51,7 +51,7 @@ def export_icons(): # name without extensions name_only = file_name.replace('.svg', '') - out_icon_names = [name_only] # export to a png with the same file name + out_icon_names = [name_only] # export to a png with the same file name theme_out_icon_names = [] # special cases if special_icons.has_key(name_only): @@ -82,7 +82,7 @@ def export_theme(): # name without extensions name_only = file_name.replace('.svg', '') - out_icon_names = [name_only] # export to a png with the same file name + out_icon_names = [name_only] # export to a png with the same file name # special cases if theme_icons.has_key(name_only): special_icon = theme_icons[name_only] @@ -102,30 +102,30 @@ special_icons = { output_names=['icon_add'], theme_output_names=['icon_add', 'icon_zoom_more'] ), - 'icon_new': dict( output_names=['icon_file'] ), - 'icon_animation_tree_player': dict( output_names=['icon_animation_tree'] ), + 'icon_new': dict(output_names=['icon_file']), + 'icon_animation_tree_player': dict(output_names=['icon_animation_tree']), 'icon_tool_rotate': dict( output_names=['icon_reload'], - theme_output_names= ['icon_reload'] + theme_output_names=['icon_reload'] ), - 'icon_multi_edit': dict( output_names=['icon_multi_node_edit'] ), + 'icon_multi_edit': dict(output_names=['icon_multi_node_edit']), 'icon_folder': dict( output_names=['icon_load', 'icon_open'], - theme_output_names= ['icon_folder'] + theme_output_names=['icon_folder'] ), - 'icon_file_list': dict( output_names=['icon_enum'] ), - 'icon_collision_2d': dict( output_names=['icon_collision_polygon_2d', 'icon_polygon_2d'] ), - 'icon_class_list': dict( output_names=['icon_filesystem'] ), - 'icon_color_ramp': dict( output_names=['icon_graph_color_ramp'] ), - 'icon_translation': dict( output_names=['icon_p_hash_translation'] ), - 'icon_shader': dict( output_names=['icon_shader_material', 'icon_material_shader'] ), - 'icon_canvas_item_shader_graph': dict( output_names=['icon_material_shader_graph'] ), + 'icon_file_list': dict(output_names=['icon_enum']), + 'icon_collision_2d': dict(output_names=['icon_collision_polygon_2d', 'icon_polygon_2d']), + 'icon_class_list': dict(output_names=['icon_filesystem']), + 'icon_color_ramp': dict(output_names=['icon_graph_color_ramp']), + 'icon_translation': dict(output_names=['icon_p_hash_translation']), + 'icon_shader': dict(output_names=['icon_shader_material', 'icon_material_shader']), + 'icon_canvas_item_shader_graph': dict(output_names=['icon_material_shader_graph']), - 'icon_color_pick': dict( theme_output_names= ['icon_color_pick'], avoid_self=True ), - 'icon_play': dict( theme_output_names= ['icon_play'] ), - 'icon_stop': dict( theme_output_names= ['icon_stop'] ), - 'icon_zoom_less': dict( theme_output_names= ['icon_zoom_less'], avoid_self=True ), - 'icon_zoom_reset': dict( theme_output_names= ['icon_zoom_reset'], avoid_self=True ), + 'icon_color_pick': dict(theme_output_names=['icon_color_pick'], avoid_self=True), + 'icon_play': dict(theme_output_names=['icon_play']), + 'icon_stop': dict(theme_output_names=['icon_stop']), + 'icon_zoom_less': dict(theme_output_names=['icon_zoom_less'], avoid_self=True), + 'icon_zoom_reset': dict(theme_output_names=['icon_zoom_reset'], avoid_self=True), 'icon_snap': dict(theme_output_names=['icon_snap']) } diff --git a/tools/translations/extract.py b/tools/translations/extract.py index f2ee1ecb1..bd6f03237 100755 --- a/tools/translations/extract.py +++ b/tools/translations/extract.py @@ -78,7 +78,7 @@ for fname in matches: msg += l[pos] pos += 1 - location = os.path.relpath(fname).replace('\\','/') + location = os.path.relpath(fname).replace('\\', '/') if (line_nb): location += ":" + str(lc) @@ -115,7 +115,7 @@ shutil.move("tools.pot", "tools/translations/tools.pot") # TODO: Make that in a portable way, if we care; if not, kudos to Unix users if (os.name == "posix"): - added = subprocess.check_output("git diff tools/translations/tools.pot | grep \+msgid | wc -l", shell = True) - removed = subprocess.check_output("git diff tools/translations/tools.pot | grep \\\-msgid | wc -l", shell = True) + added = subprocess.check_output("git diff tools/translations/tools.pot | grep \+msgid | wc -l", shell=True) + removed = subprocess.check_output("git diff tools/translations/tools.pot | grep \\\-msgid | wc -l", shell=True) print("\n# Template changes compared to the staged status:") print("# Additions: %s msgids.\n# Deletions: %s msgids." % (int(added), int(removed))) |
