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/editor/icons/SCsub | 120 +++++++++++++++++++++++------------------------ 1 file changed, 60 insertions(+), 60 deletions(-) (limited to 'tools/editor/icons') diff --git a/tools/editor/icons/SCsub b/tools/editor/icons/SCsub index 9e05d8f391..4806a89df2 100644 --- a/tools/editor/icons/SCsub +++ b/tools/editor/icons/SCsub @@ -4,93 +4,93 @@ Import('env') def make_editor_icons_action(target, source, env): - import os - import cStringIO + import os + import cStringIO - dst = target[0].srcnode().abspath - pixmaps = source + dst = target[0].srcnode().abspath + pixmaps = source - s = cStringIO.StringIO() + s = cStringIO.StringIO() - s.write("#include \"editor_icons.h\"\n\n") - s.write("#include \"editor_scale.h\"\n\n") - s.write("#include \"scene/resources/theme.h\"\n\n") + s.write("#include \"editor_icons.h\"\n\n") + 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: + 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): - s.write(hex(ord(b))) - b=pngf.read(1); - if (len(b)==1): - s.write(",") + b=pngf.read(1); + while(len(b)==1): + s.write(hex(ord(b))) + b=pngf.read(1); + if (len(b)==1): + s.write(",") - s.write("\n};\n\n"); + s.write("\n};\n\n"); - pngf.close(); - var_str=os.path.basename(x)[:-4]+"_hidpi_png"; - try: + pngf.close(); + 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): - s.write(hex(ord(b))) - b=pngf.read(1); - if (len(b)==1): - s.write(",") + b=pngf.read(1); + while(len(b)==1): + s.write(hex(ord(b))) + b=pngf.read(1); + if (len(b)==1): + s.write(",") - s.write("\n};\n\n\n"); - hidpi_list.append(x) + s.write("\n};\n\n\n"); + hidpi_list.append(x) - except: - s.write("static const unsigned char* "+ var_str +"=NULL;\n\n\n"); + except: + s.write("static const unsigned char* "+ var_str +"=NULL;\n\n\n"); - s.write("static Ref make_icon(const uint8_t* p_png,const uint8_t* p_hidpi_png) {\n") - s.write("\tRef texture( memnew( ImageTexture ) );\n") - s.write("\tbool use_hidpi_image=(editor_get_scale()>1.0&&p_hidpi_png);\n") - s.write("\tImage img(use_hidpi_image?p_hidpi_png:p_png);\n") - s.write("\tif (editor_get_scale()>1.0 && !p_hidpi_png) { img.convert(Image::FORMAT_RGBA); img.expand_x2_hq2x(); use_hidpi_image=true;}\n") - s.write("\timg.resize(img.get_width()*EDSCALE/(use_hidpi_image?2:1),img.get_height()*EDSCALE/(use_hidpi_image?2:1));\n") - s.write("\ttexture->create_from_image( img,ImageTexture::FLAG_FILTER );\n") - s.write("\treturn texture;\n") - s.write("}\n\n") + s.write("static Ref make_icon(const uint8_t* p_png,const uint8_t* p_hidpi_png) {\n") + s.write("\tRef texture( memnew( ImageTexture ) );\n") + s.write("\tbool use_hidpi_image=(editor_get_scale()>1.0&&p_hidpi_png);\n") + s.write("\tImage img(use_hidpi_image?p_hidpi_png:p_png);\n") + s.write("\tif (editor_get_scale()>1.0 && !p_hidpi_png) { img.convert(Image::FORMAT_RGBA); img.expand_x2_hq2x(); use_hidpi_image=true;}\n") + s.write("\timg.resize(img.get_width()*EDSCALE/(use_hidpi_image?2:1),img.get_height()*EDSCALE/(use_hidpi_image?2:1));\n") + s.write("\ttexture->create_from_image( img,ImageTexture::FLAG_FILTER );\n") + s.write("\treturn texture;\n") + s.write("}\n\n") - s.write("void editor_register_icons(Ref p_theme) {\n\n") + s.write("void editor_register_icons(Ref p_theme) {\n\n") - for x in pixmaps: + 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"); + s.write("\n\n}\n\n"); - f = open(dst,"wb") - f.write(s.getvalue()) - f.close() - s.close() + 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') + 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"))]) -- 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/editor/icons/SCsub | 56 ++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'tools/editor/icons') diff --git a/tools/editor/icons/SCsub b/tools/editor/icons/SCsub index 4806a89df2..ac942b20e3 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') -- 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/editor/icons/SCsub | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'tools/editor/icons') diff --git a/tools/editor/icons/SCsub b/tools/editor/icons/SCsub index ac942b20e3..f27350a184 100644 --- a/tools/editor/icons/SCsub +++ b/tools/editor/icons/SCsub @@ -2,6 +2,7 @@ Import('env') + def make_editor_icons_action(target, source, env): import os @@ -58,9 +59,6 @@ def make_editor_icons_action(target, source, env): except: s.write("static const unsigned char* " + var_str + "=NULL;\n\n\n"); - - - s.write("static Ref make_icon(const uint8_t* p_png,const uint8_t* p_hidpi_png) {\n") s.write("\tRef texture( memnew( ImageTexture ) );\n") s.write("\tbool use_hidpi_image=(editor_get_scale()>1.0&&p_hidpi_png);\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/editor/icons/SCsub | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'tools/editor/icons') diff --git a/tools/editor/icons/SCsub b/tools/editor/icons/SCsub index f27350a184..af6ebd67fd 100644 --- a/tools/editor/icons/SCsub +++ b/tools/editor/icons/SCsub @@ -22,42 +22,42 @@ def make_editor_icons_action(target, source, env): for x in pixmaps: x = str(x) - var_str = os.path.basename(x)[:-4] + "_png"; + 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); + b = pngf.read(1) while(len(b) == 1): s.write(hex(ord(b))) - b = pngf.read(1); + b = pngf.read(1) if (len(b) == 1): s.write(",") - s.write("\n};\n\n"); + s.write("\n};\n\n") - pngf.close(); - var_str = os.path.basename(x)[:-4] + "_hidpi_png"; + pngf.close() + var_str = os.path.basename(x)[:-4] + "_hidpi_png" try: 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); + b = pngf.read(1) while(len(b) == 1): s.write(hex(ord(b))) - b = pngf.read(1); + b = pngf.read(1) if (len(b) == 1): s.write(",") - s.write("\n};\n\n\n"); + 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") s.write("static Ref make_icon(const uint8_t* p_png,const uint8_t* p_hidpi_png) {\n") s.write("\tRef texture( memnew( ImageTexture ) );\n") @@ -74,12 +74,12 @@ 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"); + 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"); + s.write("\n\n}\n\n") f = open(dst, "wb") f.write(s.getvalue()) -- cgit v1.2.3