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. --- doc/tools/doc_merge.py | 260 ++++++++++++++++++++++++------------------------- 1 file changed, 130 insertions(+), 130 deletions(-) (limited to 'doc/tools/doc_merge.py') diff --git a/doc/tools/doc_merge.py b/doc/tools/doc_merge.py index 536770bee4..27f46960be 100644 --- a/doc/tools/doc_merge.py +++ b/doc/tools/doc_merge.py @@ -17,195 +17,195 @@ tab=0 old_classes={} def write_string(_f, text,newline=True): - for t in range(tab): - _f.write("\t") - _f.write(text) - if (newline): - _f.write("\n") + for t in range(tab): + _f.write("\t") + _f.write(text) + if (newline): + _f.write("\n") def escape(ret): - ret=ret.replace("&","&"); - ret=ret.replace("<",">"); - ret=ret.replace(">","<"); - ret=ret.replace("'","'"); - ret=ret.replace("\"","""); - return ret + ret=ret.replace("&","&"); + ret=ret.replace("<",">"); + ret=ret.replace(">","<"); + ret=ret.replace("'","'"); + ret=ret.replace("\"","""); + return ret def inc_tab(): - global tab - tab+=1 + global tab + tab+=1 def dec_tab(): - global tab - tab-=1 + global tab + tab-=1 write_string(f,'') write_string(f,'') def get_tag(node,name): - tag="" - if (name in node.attrib): - tag=' '+name+'="'+escape(node.attrib[name])+'" ' - return tag + tag="" + if (name in node.attrib): + tag=' '+name+'="'+escape(node.attrib[name])+'" ' + return tag def find_method_descr(old_class,name): - methods = old_class.find("methods") - if(methods!=None and len(list(methods))>0): - for m in list(methods): - if (m.attrib["name"]==name): - description=m.find("description") - if (description!=None and description.text.strip()!=""): - return description.text + methods = old_class.find("methods") + if(methods!=None and len(list(methods))>0): + for m in list(methods): + if (m.attrib["name"]==name): + description=m.find("description") + if (description!=None and description.text.strip()!=""): + return description.text - return None + return None def find_signal_descr(old_class,name): - signals = old_class.find("signals") - if(signals!=None and len(list(signals))>0): - for m in list(signals): - if (m.attrib["name"]==name): - description=m.find("description") - if (description!=None and description.text.strip()!=""): - return description.text + signals = old_class.find("signals") + if(signals!=None and len(list(signals))>0): + for m in list(signals): + if (m.attrib["name"]==name): + description=m.find("description") + if (description!=None and description.text.strip()!=""): + return description.text - return None + return None def find_constant_descr(old_class,name): - if (old_class==None): - return None - constants = old_class.find("constants") - if(constants!=None and len(list(constants))>0): - for m in list(constants): - if (m.attrib["name"]==name): - if (m.text.strip()!=""): - return m.text - return None + if (old_class==None): + return None + constants = old_class.find("constants") + if(constants!=None and len(list(constants))>0): + for m in list(constants): + if (m.attrib["name"]==name): + if (m.text.strip()!=""): + return m.text + return None def write_class(c): - class_name = c.attrib["name"] - print("Parsing Class: "+class_name) - if (class_name in old_classes): - old_class=old_classes[class_name] - else: - old_class=None + class_name = c.attrib["name"] + print("Parsing Class: "+class_name) + if (class_name in old_classes): + old_class=old_classes[class_name] + else: + old_class=None - category=get_tag(c,"category") - inherits=get_tag(c,"inherits") - write_string(f,'') - inc_tab() + category=get_tag(c,"category") + inherits=get_tag(c,"inherits") + write_string(f,'') + inc_tab() - write_string(f,"") + write_string(f,"") - if (old_class!=None): - old_brief_descr=old_class.find("brief_description") - if (old_brief_descr!=None): - write_string(f,escape(old_brief_descr.text.strip())) + if (old_class!=None): + old_brief_descr=old_class.find("brief_description") + if (old_brief_descr!=None): + write_string(f,escape(old_brief_descr.text.strip())) - write_string(f,"") + write_string(f,"") - write_string(f,"") - if (old_class!=None): - old_descr=old_class.find("description") - if (old_descr!=None): - write_string(f,escape(old_descr.text.strip())) + write_string(f,"") + if (old_class!=None): + old_descr=old_class.find("description") + if (old_descr!=None): + write_string(f,escape(old_descr.text.strip())) - write_string(f,"") + write_string(f,"") - methods = c.find("methods") - if(methods!=None and len(list(methods))>0): + methods = c.find("methods") + if(methods!=None and len(list(methods))>0): - write_string(f,"") - inc_tab() + write_string(f,"") + inc_tab() - for m in list(methods): - qualifiers=get_tag(m,"qualifiers") + for m in list(methods): + qualifiers=get_tag(m,"qualifiers") - write_string(f,'') - inc_tab() + write_string(f,'') + inc_tab() - for a in list(m): - if (a.tag=="return"): - typ=get_tag(a,"type") - write_string(f,''); - write_string(f,''); - elif (a.tag=="argument"): + for a in list(m): + if (a.tag=="return"): + typ=get_tag(a,"type") + write_string(f,''); + write_string(f,''); + elif (a.tag=="argument"): - default=get_tag(a,"default") + default=get_tag(a,"default") - write_string(f,''); - write_string(f,''); + write_string(f,''); + write_string(f,''); - write_string(f,''); - if (old_class!=None): - old_method_descr=find_method_descr(old_class,m.attrib["name"]) - if (old_method_descr): - write_string(f,escape(escape(old_method_descr.strip()))) + write_string(f,''); + if (old_class!=None): + old_method_descr=find_method_descr(old_class,m.attrib["name"]) + if (old_method_descr): + write_string(f,escape(escape(old_method_descr.strip()))) - write_string(f,''); - dec_tab() - write_string(f,"") - dec_tab() - write_string(f,"") + write_string(f,''); + dec_tab() + write_string(f,"") + dec_tab() + write_string(f,"") - signals = c.find("signals") - if(signals!=None and len(list(signals))>0): + signals = c.find("signals") + if(signals!=None and len(list(signals))>0): - write_string(f,"") - inc_tab() + write_string(f,"") + inc_tab() - for m in list(signals): + for m in list(signals): - write_string(f,'') - inc_tab() + write_string(f,'') + inc_tab() - for a in list(m): - if (a.tag=="argument"): + for a in list(m): + if (a.tag=="argument"): - write_string(f,''); - write_string(f,''); + write_string(f,''); + write_string(f,''); - write_string(f,''); - if (old_class!=None): - old_signal_descr=find_signal_descr(old_class,m.attrib["name"]) - if (old_signal_descr): - write_string(f,escape(old_signal_descr.strip())) - write_string(f,''); - dec_tab() - write_string(f,"") - dec_tab() - write_string(f,"") + write_string(f,''); + if (old_class!=None): + old_signal_descr=find_signal_descr(old_class,m.attrib["name"]) + if (old_signal_descr): + write_string(f,escape(old_signal_descr.strip())) + write_string(f,''); + dec_tab() + write_string(f,"") + dec_tab() + write_string(f,"") - constants = c.find("constants") - if(constants!=None and len(list(constants))>0): + constants = c.find("constants") + if(constants!=None and len(list(constants))>0): - write_string(f,"") - inc_tab() + write_string(f,"") + inc_tab() - for m in list(constants): + for m in list(constants): - write_string(f,'') - old_constant_descr=find_constant_descr(old_class,m.attrib["name"]) - if (old_constant_descr): - write_string(f,escape(old_constant_descr.strip())) - write_string(f,"") + write_string(f,'') + old_constant_descr=find_constant_descr(old_class,m.attrib["name"]) + if (old_constant_descr): + write_string(f,escape(old_constant_descr.strip())) + write_string(f,"") - dec_tab() - write_string(f,"") + dec_tab() + write_string(f,"") - dec_tab() - write_string(f,"") + dec_tab() + write_string(f,"") for c in list(old_doc): - old_classes[c.attrib["name"]]=c + old_classes[c.attrib["name"]]=c for c in list(new_doc): - write_class(c) + write_class(c) write_string(f,'\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. --- doc/tools/doc_merge.py | 186 ++++++++++++++++++++++++------------------------- 1 file changed, 93 insertions(+), 93 deletions(-) (limited to 'doc/tools/doc_merge.py') diff --git a/doc/tools/doc_merge.py b/doc/tools/doc_merge.py index 27f46960be..747a870378 100644 --- a/doc/tools/doc_merge.py +++ b/doc/tools/doc_merge.py @@ -6,17 +6,17 @@ import xml.etree.ElementTree as ET tree = ET.parse(sys.argv[1]) -old_doc=tree.getroot() +old_doc = tree.getroot() tree = ET.parse(sys.argv[2]) -new_doc=tree.getroot() +new_doc = tree.getroot() -f = file(sys.argv[3],"wb") -tab=0 +f = file(sys.argv[3], "wb") +tab = 0 -old_classes={} +old_classes = {} -def write_string(_f, text,newline=True): +def write_string(_f, text, newline=True): for t in range(tab): _f.write("\t") _f.write(text) @@ -24,188 +24,188 @@ def write_string(_f, text,newline=True): _f.write("\n") def escape(ret): - ret=ret.replace("&","&"); - ret=ret.replace("<",">"); - ret=ret.replace(">","<"); - ret=ret.replace("'","'"); - ret=ret.replace("\"","""); + ret = ret.replace("&", "&"); + ret = ret.replace("<", ">"); + ret = ret.replace(">", "<"); + ret = ret.replace("'", "'"); + ret = ret.replace("\"", """); return ret def inc_tab(): global tab - tab+=1 + tab += 1 def dec_tab(): global tab - tab-=1 + tab -= 1 -write_string(f,'') -write_string(f,'') +write_string(f, '') +write_string(f, '') -def get_tag(node,name): - tag="" +def get_tag(node, name): + tag = "" if (name in node.attrib): - tag=' '+name+'="'+escape(node.attrib[name])+'" ' + tag = ' ' + name + '="' + escape(node.attrib[name]) + '" ' return tag -def find_method_descr(old_class,name): +def find_method_descr(old_class, name): methods = old_class.find("methods") - if(methods!=None and len(list(methods))>0): + if(methods != None and len(list(methods)) > 0): for m in list(methods): - if (m.attrib["name"]==name): - description=m.find("description") - if (description!=None and description.text.strip()!=""): + if (m.attrib["name"] == name): + description = m.find("description") + if (description != None and description.text.strip() != ""): return description.text return None -def find_signal_descr(old_class,name): +def find_signal_descr(old_class, name): signals = old_class.find("signals") - if(signals!=None and len(list(signals))>0): + if(signals != None and len(list(signals)) > 0): for m in list(signals): - if (m.attrib["name"]==name): - description=m.find("description") - if (description!=None and description.text.strip()!=""): + if (m.attrib["name"] == name): + description = m.find("description") + if (description != None and description.text.strip() != ""): return description.text return None -def find_constant_descr(old_class,name): +def find_constant_descr(old_class, name): - if (old_class==None): + if (old_class == None): return None constants = old_class.find("constants") - if(constants!=None and len(list(constants))>0): + if(constants != None and len(list(constants)) > 0): for m in list(constants): - if (m.attrib["name"]==name): - if (m.text.strip()!=""): + if (m.attrib["name"] == name): + if (m.text.strip() != ""): return m.text return None def write_class(c): class_name = c.attrib["name"] - print("Parsing Class: "+class_name) + print("Parsing Class: " + class_name) if (class_name in old_classes): - old_class=old_classes[class_name] + old_class = old_classes[class_name] else: - old_class=None + old_class = None - category=get_tag(c,"category") - inherits=get_tag(c,"inherits") - write_string(f,'') + category = get_tag(c, "category") + inherits = get_tag(c, "inherits") + write_string(f, '') inc_tab() - write_string(f,"") + write_string(f, "") - if (old_class!=None): - old_brief_descr=old_class.find("brief_description") - if (old_brief_descr!=None): - write_string(f,escape(old_brief_descr.text.strip())) + if (old_class != None): + old_brief_descr = old_class.find("brief_description") + if (old_brief_descr != None): + write_string(f, escape(old_brief_descr.text.strip())) - write_string(f,"") + write_string(f, "") - write_string(f,"") - if (old_class!=None): - old_descr=old_class.find("description") - if (old_descr!=None): - write_string(f,escape(old_descr.text.strip())) + write_string(f, "") + if (old_class != None): + old_descr = old_class.find("description") + if (old_descr != None): + write_string(f, escape(old_descr.text.strip())) - write_string(f,"") + write_string(f, "") methods = c.find("methods") - if(methods!=None and len(list(methods))>0): + if(methods != None and len(list(methods)) > 0): - write_string(f,"") + write_string(f, "") inc_tab() for m in list(methods): - qualifiers=get_tag(m,"qualifiers") + qualifiers = get_tag(m, "qualifiers") - write_string(f,'') + write_string(f, '') inc_tab() for a in list(m): - if (a.tag=="return"): - typ=get_tag(a,"type") - write_string(f,''); - write_string(f,''); - elif (a.tag=="argument"): + if (a.tag == "return"): + typ = get_tag(a, "type") + write_string(f, ''); + write_string(f, ''); + elif (a.tag == "argument"): - default=get_tag(a,"default") + default = get_tag(a, "default") - write_string(f,''); - write_string(f,''); + write_string(f, ''); + write_string(f, ''); - write_string(f,''); - if (old_class!=None): - old_method_descr=find_method_descr(old_class,m.attrib["name"]) + write_string(f, ''); + if (old_class != None): + old_method_descr = find_method_descr(old_class, m.attrib["name"]) if (old_method_descr): - write_string(f,escape(escape(old_method_descr.strip()))) + write_string(f, escape(escape(old_method_descr.strip()))) - write_string(f,''); + write_string(f, ''); dec_tab() - write_string(f,"") + write_string(f, "") dec_tab() - write_string(f,"") + write_string(f, "") signals = c.find("signals") - if(signals!=None and len(list(signals))>0): + if(signals != None and len(list(signals)) > 0): - write_string(f,"") + write_string(f, "") inc_tab() for m in list(signals): - write_string(f,'') + write_string(f, '') inc_tab() for a in list(m): - if (a.tag=="argument"): + if (a.tag == "argument"): - write_string(f,''); - write_string(f,''); + write_string(f, ''); + write_string(f, ''); - write_string(f,''); - if (old_class!=None): - old_signal_descr=find_signal_descr(old_class,m.attrib["name"]) + write_string(f, ''); + if (old_class != None): + old_signal_descr = find_signal_descr(old_class, m.attrib["name"]) if (old_signal_descr): - write_string(f,escape(old_signal_descr.strip())) - write_string(f,''); + write_string(f, escape(old_signal_descr.strip())) + write_string(f, ''); dec_tab() - write_string(f,"") + write_string(f, "") dec_tab() - write_string(f,"") + write_string(f, "") constants = c.find("constants") - if(constants!=None and len(list(constants))>0): + if(constants != None and len(list(constants)) > 0): - write_string(f,"") + write_string(f, "") inc_tab() for m in list(constants): - write_string(f,'') - old_constant_descr=find_constant_descr(old_class,m.attrib["name"]) + write_string(f, '') + old_constant_descr = find_constant_descr(old_class, m.attrib["name"]) if (old_constant_descr): - write_string(f,escape(old_constant_descr.strip())) - write_string(f,"") + write_string(f, escape(old_constant_descr.strip())) + write_string(f, "") dec_tab() - write_string(f,"") + write_string(f, "") dec_tab() - write_string(f,"") + write_string(f, "") for c in list(old_doc): - old_classes[c.attrib["name"]]=c + old_classes[c.attrib["name"]] = c for c in list(new_doc): write_class(c) -write_string(f,'\n') +write_string(f, '\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. --- doc/tools/doc_merge.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'doc/tools/doc_merge.py') diff --git a/doc/tools/doc_merge.py b/doc/tools/doc_merge.py index 747a870378..d9f7cc9daa 100644 --- a/doc/tools/doc_merge.py +++ b/doc/tools/doc_merge.py @@ -16,6 +16,7 @@ tab = 0 old_classes = {} + def write_string(_f, text, newline=True): for t in range(tab): _f.write("\t") @@ -23,6 +24,7 @@ def write_string(_f, text, newline=True): if (newline): _f.write("\n") + def escape(ret): ret = ret.replace("&", "&"); ret = ret.replace("<", ">"); @@ -36,6 +38,7 @@ def inc_tab(): global tab tab += 1 + def dec_tab(): global tab tab -= 1 @@ -43,12 +46,14 @@ def dec_tab(): write_string(f, '') write_string(f, '') + def get_tag(node, name): tag = "" if (name in node.attrib): tag = ' ' + name + '="' + escape(node.attrib[name]) + '" ' return tag + def find_method_descr(old_class, name): methods = old_class.find("methods") @@ -61,6 +66,7 @@ def find_method_descr(old_class, name): return None + def find_signal_descr(old_class, name): signals = old_class.find("signals") @@ -73,6 +79,7 @@ def find_signal_descr(old_class, name): return None + def find_constant_descr(old_class, name): if (old_class == None): @@ -85,6 +92,7 @@ def find_constant_descr(old_class, name): return m.text return None + def write_class(c): class_name = c.attrib["name"] print("Parsing Class: " + class_name) @@ -93,7 +101,6 @@ def write_class(c): else: old_class = None - category = get_tag(c, "category") inherits = get_tag(c, "inherits") write_string(f, '') @@ -106,7 +113,6 @@ def write_class(c): if (old_brief_descr != None): write_string(f, escape(old_brief_descr.text.strip())) - write_string(f, "") write_string(f, "") @@ -207,5 +213,3 @@ for c in list(old_doc): for c in list(new_doc): write_class(c) write_string(f, '\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). --- doc/tools/doc_merge.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'doc/tools/doc_merge.py') diff --git a/doc/tools/doc_merge.py b/doc/tools/doc_merge.py index d9f7cc9daa..57ac4bdcdd 100644 --- a/doc/tools/doc_merge.py +++ b/doc/tools/doc_merge.py @@ -26,11 +26,11 @@ def write_string(_f, text, newline=True): def escape(ret): - ret = ret.replace("&", "&"); - ret = ret.replace("<", ">"); - ret = ret.replace(">", "<"); - ret = ret.replace("'", "'"); - ret = ret.replace("\"", """); + ret = ret.replace("&", "&") + ret = ret.replace("<", ">") + ret = ret.replace(">", "<") + ret = ret.replace("'", "'") + ret = ret.replace("\"", """) return ret @@ -138,22 +138,22 @@ def write_class(c): for a in list(m): if (a.tag == "return"): typ = get_tag(a, "type") - write_string(f, ''); - write_string(f, ''); + write_string(f, '') + write_string(f, '') elif (a.tag == "argument"): default = get_tag(a, "default") - write_string(f, ''); - write_string(f, ''); + write_string(f, '') + write_string(f, '') - write_string(f, ''); + write_string(f, '') if (old_class != None): old_method_descr = find_method_descr(old_class, m.attrib["name"]) if (old_method_descr): write_string(f, escape(escape(old_method_descr.strip()))) - write_string(f, ''); + write_string(f, '') dec_tab() write_string(f, "") dec_tab() @@ -173,15 +173,15 @@ def write_class(c): for a in list(m): if (a.tag == "argument"): - write_string(f, ''); - write_string(f, ''); + write_string(f, '') + write_string(f, '') - write_string(f, ''); + write_string(f, '') if (old_class != None): old_signal_descr = find_signal_descr(old_class, m.attrib["name"]) if (old_signal_descr): write_string(f, escape(old_signal_descr.strip())) - write_string(f, ''); + write_string(f, '') dec_tab() write_string(f, "") dec_tab() -- cgit v1.2.3