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/make_glwrapper.py | 100 ++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 50 deletions(-) (limited to 'tools/scripts/make_glwrapper.py') diff --git a/tools/scripts/make_glwrapper.py b/tools/scripts/make_glwrapper.py index b4c582f1eb..8da4e28c89 100644 --- a/tools/scripts/make_glwrapper.py +++ b/tools/scripts/make_glwrapper.py @@ -2,8 +2,8 @@ import sys if (len(sys.argv)<2): - print("usage: make_glwrapper.py ") - sys.exit(255) + print("usage: make_glwrapper.py ") + sys.exit(255) functions=[] @@ -17,16 +17,16 @@ READ_CONSTANTS=2 read_what=READ_TYPES for x in (range(len(sys.argv)-1)): - f=open(sys.argv[x+1],"r") + f=open(sys.argv[x+1],"r") - while(True): + while(True): - line=f.readline() - if (line==""): - break + 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 continue @@ -38,53 +38,53 @@ 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): - 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): - continue - types.append(line) - elif (line.find("APIENTRY")!=-1 and line.find("GLAPI")!=-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): + continue + types.append(line) + 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): - continue + 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): - continue + 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): - continue + if (namepos==-1): + continue - name=line[:namepos].strip() - line=line[namepos:] + name=line[:namepos].strip() + line=line[namepos:] - argpos=line.rfind(")") - if (argpos==-1): - continue + 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) + functions.append(funcdata) + print(funcdata) @@ -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"); @@ -165,14 +165,14 @@ 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") -- 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/make_glwrapper.py | 100 ++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 50 deletions(-) (limited to 'tools/scripts/make_glwrapper.py') diff --git a/tools/scripts/make_glwrapper.py b/tools/scripts/make_glwrapper.py index 8da4e28c89..9f26f8430e 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 ") 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") -- 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/make_glwrapper.py | 5 ----- 1 file changed, 5 deletions(-) (limited to 'tools/scripts/make_glwrapper.py') diff --git a/tools/scripts/make_glwrapper.py b/tools/scripts/make_glwrapper.py index 9f26f8430e..bae0eeeadc 100644 --- a/tools/scripts/make_glwrapper.py +++ b/tools/scripts/make_glwrapper.py @@ -87,7 +87,6 @@ for x in (range(len(sys.argv) - 1)): print(funcdata) - # print(types) # print(constants) # print(functions) @@ -177,7 +176,3 @@ for x in functions: f.write("\n\n") f.write("}\n") f.write("\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/make_glwrapper.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'tools/scripts/make_glwrapper.py') diff --git a/tools/scripts/make_glwrapper.py b/tools/scripts/make_glwrapper.py index bae0eeeadc..5694d2327e 100644 --- a/tools/scripts/make_glwrapper.py +++ b/tools/scripts/make_glwrapper.py @@ -61,7 +61,7 @@ for x in (range(len(sys.argv) - 1)): if (glpos == -1): continue - ret = line[:glpos].strip(); + ret = line[:glpos].strip() line = line[glpos:].strip() namepos = line.find("(") @@ -127,14 +127,14 @@ header_code = """\ f.write("#include \n\n\n") -f.write(header_code); +f.write(header_code) f.write("#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\n") f.write("#if defined(_WIN32) && !defined(__CYGWIN__)\n") f.write("#define GLWRP_APIENTRY __stdcall\n") -f.write("#else\n"); +f.write("#else\n") f.write("#define GLWRP_APIENTRY \n") -f.write("#endif\n\n"); +f.write("#endif\n\n") for x in types: f.write(x + "\n") @@ -150,7 +150,7 @@ for x in functions: f.write("#define " + x["name"] + " __wrapper_" + x["name"] + "\n") f.write("\n\n") -f.write("typedef void (*GLWrapperFuncPtr)(void);\n\n"); +f.write("typedef void (*GLWrapperFuncPtr)(void);\n\n") f.write("void glWrapperInit( GLWrapperFuncPtr (*wrapperFunc)(const char*) );\n") f.write("#ifdef __cplusplus\n}\n#endif\n") -- cgit v1.2.3