From 91389ed8b9fd942feb35fe4b9ef5fb8c148d9682 Mon Sep 17 00:00:00 2001 From: persianpros Date: Tue, 13 Apr 2021 23:18:01 +0430 Subject: [PATCH 1/5] PEP8 double aggressive E701, E70 and E502 --- contrib/oe-stylize.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/contrib/oe-stylize.py b/contrib/oe-stylize.py index ba4b87a74cb..6f2b96c381f 100755 --- a/contrib/oe-stylize.py +++ b/contrib/oe-stylize.py @@ -353,7 +353,8 @@ def follow_rule(i, line): # ignore empty lines if line.isspace() or line is '': # flush comments into the olines - for c in commentBloc: olines.append(c) + for c in commentBloc: + olines.append(c) commentBloc = [] continue @@ -370,7 +371,8 @@ def follow_rule(i, line): continue if var in seen_vars: - for c in commentBloc: seen_vars[var].append(c) + for c in commentBloc: + seen_vars[var].append(c) commentBloc = [] seen_vars[var].append(line) else: @@ -389,24 +391,29 @@ def follow_rule(i, line): if not in_routine: print ("## Warning: unknown variable/routine \"%s\"" % originalLine.rstrip('\n')) var = 'others' - for c in commentBloc: seen_vars[var].append(c) + for c in commentBloc: + seen_vars[var].append(c) commentBloc = [] seen_vars[var].append(line) - if not keep and not in_routine: var = "" + if not keep and not in_routine: + var = "" # -- dump the sanitized .bb file -- addEmptyLine = False # write comments that are not related to variables nor routines - for l in commentBloc: olines.append(l) + for l in commentBloc: + olines.append(l) # write variables and routines previourVarPrefix = "unknown" for k in OE_vars: - if k=='SRC_URI': addEmptyLine = True + if k=='SRC_URI': + addEmptyLine = True if seen_vars[k] != []: if addEmptyLine and not k.startswith(previourVarPrefix): olines.append("") for l in seen_vars[k]: olines.append(l) previourVarPrefix = k.split('_')[0]=='' and "unknown" or k.split('_')[0] - for line in olines: print(line) + for line in olines: + print(line) From 86d2ce6c48fe7586f379976d9ccf59ae03801df2 Mon Sep 17 00:00:00 2001 From: persianpros Date: Tue, 13 Apr 2021 23:18:03 +0430 Subject: [PATCH 2/5] PEP8 double aggressive E20 and E211 --- contrib/oe-stylize.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/oe-stylize.py b/contrib/oe-stylize.py index 6f2b96c381f..7958797059a 100755 --- a/contrib/oe-stylize.py +++ b/contrib/oe-stylize.py @@ -312,10 +312,10 @@ def follow_rule(i, line): # if the line still does not respect the rule if not rules[i][0](line): # this is a rule disgression - print ("## Disgression: ", rules[i][2], " in: '", oldline, "'") + print("## Disgression: ", rules[i][2], " in: '", oldline, "'") else: # just remind user about his/her errors - print ("## Reminder: ", rules[i][2], " in : '", oldline, "'") + print("## Reminder: ", rules[i][2], " in : '", oldline, "'") return line @@ -389,7 +389,7 @@ def follow_rule(i, line): line = follow_rule(5, line) if var == "": if not in_routine: - print ("## Warning: unknown variable/routine \"%s\"" % originalLine.rstrip('\n')) + print("## Warning: unknown variable/routine \"%s\"" % originalLine.rstrip('\n')) var = 'others' for c in commentBloc: seen_vars[var].append(c) From 02246d39433d87f41238845eccc9d2b180b5bd76 Mon Sep 17 00:00:00 2001 From: persianpros Date: Tue, 13 Apr 2021 23:18:04 +0430 Subject: [PATCH 3/5] PEP8 double aggressive E22, E224, E241, E242 and E27 --- contrib/oe-stylize.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/contrib/oe-stylize.py b/contrib/oe-stylize.py index 7958797059a..9d95911ae6e 100755 --- a/contrib/oe-stylize.py +++ b/contrib/oe-stylize.py @@ -222,7 +222,7 @@ # No spaces are allowed at the beginning of lines that define a variable or # a do_ routine def respect_rule0(line): - return line.lstrip()==line + return line.lstrip() == line def conformTo_rule0(line): return line.lstrip() @@ -239,7 +239,7 @@ def conformTo_rule1(line): # _Format guideline #2_: # Tabs should not be used (use spaces instead). def respect_rule2(line): - return line.count('\t')==0 + return line.count('\t') == 0 def conformTo_rule2(line): return line.expandtabs() @@ -261,7 +261,7 @@ def respect_rule4(line): if r is not None: r2 = re.search(r'("?)([^"\\]*)(["\\]?)', r.group(5)) # do not test for None it because always match - return r2.group(1)=='"' and r2.group(3)!='' + return r2.group(1) == '"' and r2.group(3) != '' return False def conformTo_rule4(line): r = re.search(varRegexp, line) @@ -271,7 +271,7 @@ def conformTo_rule4(line): # The correct spacing for a variable is FOO = "BAR". def respect_rule5(line): r = re.search(varRegexp, line) - return r is not None and r.group(2)==" " and r.group(4)==" " + return r is not None and r.group(2) == " " and r.group(4) == " " def conformTo_rule5(line): r = re.search(varRegexp, line) return ''.join([r.group(1), ' ', r.group(3), ' ', r.group(5)]) @@ -279,7 +279,7 @@ def conformTo_rule5(line): # _Format guideline #6_: # Don't use spaces or tabs on empty lines def respect_rule6(line): - return not line.isspace() or line=="\n" + return not line.isspace() or line == "\n" def conformTo_rule6(line): return "" @@ -359,7 +359,7 @@ def follow_rule(i, line): continue if line.startswith('}'): - in_routine=False + in_routine = False keep = line.endswith('\\') or in_routine # handles commented lines @@ -381,7 +381,7 @@ def follow_rule(i, line): var = k break if re.match(routineRegexp, line) is not None: - in_routine=True + in_routine = True line = follow_rule(0, line) elif re.match(varRegexp, line) is not None: line = follow_rule(0, line) @@ -406,14 +406,14 @@ def follow_rule(i, line): # write variables and routines previourVarPrefix = "unknown" for k in OE_vars: - if k=='SRC_URI': + if k == 'SRC_URI': addEmptyLine = True if seen_vars[k] != []: if addEmptyLine and not k.startswith(previourVarPrefix): olines.append("") for l in seen_vars[k]: olines.append(l) - previourVarPrefix = k.split('_')[0]=='' and "unknown" or k.split('_')[0] + previourVarPrefix = k.split('_')[0] == '' and "unknown" or k.split('_')[0] for line in olines: print(line) From 4e068d1aac6f773ad4a273807fc5cbae79a2a3a9 Mon Sep 17 00:00:00 2001 From: persianpros Date: Tue, 13 Apr 2021 23:18:05 +0430 Subject: [PATCH 4/5] PEP8 double aggressive E301 ~ E306 --- contrib/oe-stylize.py | 35 +++++++++++++++++++ .../oeqa/selftest/cases/meta_oe_sources.py | 1 + 2 files changed, 36 insertions(+) diff --git a/contrib/oe-stylize.py b/contrib/oe-stylize.py index 9d95911ae6e..cfabb90b10f 100755 --- a/contrib/oe-stylize.py +++ b/contrib/oe-stylize.py @@ -221,41 +221,59 @@ # _Format guideline #0_: # No spaces are allowed at the beginning of lines that define a variable or # a do_ routine + + def respect_rule0(line): return line.lstrip() == line + + def conformTo_rule0(line): return line.lstrip() # _Format guideline #1_: # No spaces are allowed behind the line continuation symbol '\' + + def respect_rule1(line): if line.rstrip().endswith('\\'): return line.endswith('\\') else: return True + + def conformTo_rule1(line): return line.rstrip() # _Format guideline #2_: # Tabs should not be used (use spaces instead). + + def respect_rule2(line): return line.count('\t') == 0 + + def conformTo_rule2(line): return line.expandtabs() # _Format guideline #3_: # Comments inside bb files are allowed using the '#' character at the # beginning of a line. + + def respect_rule3(line): if line.lstrip().startswith('#'): return line.startswith('#') else: return True + + def conformTo_rule3(line): return line.lstrip() # _Format guideline #4_: # Use quotes on the right hand side of assignments FOO = "BAR" + + def respect_rule4(line): r = re.search(varRegexp, line) if r is not None: @@ -263,33 +281,48 @@ def respect_rule4(line): # do not test for None it because always match return r2.group(1) == '"' and r2.group(3) != '' return False + + def conformTo_rule4(line): r = re.search(varRegexp, line) return ''.join([r.group(1), ' ', r.group(3), ' "', r.group(5), r.group(5).endswith('"') and '' or '"']) # _Format guideline #5_: # The correct spacing for a variable is FOO = "BAR". + + def respect_rule5(line): r = re.search(varRegexp, line) return r is not None and r.group(2) == " " and r.group(4) == " " + + def conformTo_rule5(line): r = re.search(varRegexp, line) return ''.join([r.group(1), ' ', r.group(3), ' ', r.group(5)]) # _Format guideline #6_: # Don't use spaces or tabs on empty lines + + def respect_rule6(line): return not line.isspace() or line == "\n" + + def conformTo_rule6(line): return "" # _Format guideline #7_: # Indentation of multiline variables such as SRC_URI is desireable. + + def respect_rule7(line): return True + + def conformTo_rule7(line): return line + rules = ( (respect_rule0, conformTo_rule0, "No spaces are allowed at the beginning of lines that define a variable or a do_ routine"), (respect_rule1, conformTo_rule1, "No spaces are allowed behind the line continuation symbol '\\'"), @@ -303,6 +336,8 @@ def conformTo_rule7(line): # Function to check that a line respects a rule. If not, it tries to conform # the line to the rule. Reminder or Disgression message are dump accordingly. + + def follow_rule(i, line): oldline = line # if the line does not respect the rule diff --git a/meta-oe/lib/oeqa/selftest/cases/meta_oe_sources.py b/meta-oe/lib/oeqa/selftest/cases/meta_oe_sources.py index b17c7950c7e..c5a9a279465 100644 --- a/meta-oe/lib/oeqa/selftest/cases/meta_oe_sources.py +++ b/meta-oe/lib/oeqa/selftest/cases/meta_oe_sources.py @@ -6,6 +6,7 @@ from oeqa.selftest.case import OESelftestTestCase from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars + class MetaOESourceMirroring(OESelftestTestCase): # Can we download everything from the OpenEmbedded Sources Mirror over http only def test_oe_source_mirror(self): From 1f63da4dced9caf0a2372878028a910ab3b54721 Mon Sep 17 00:00:00 2001 From: persianpros Date: Tue, 13 Apr 2021 23:18:06 +0430 Subject: [PATCH 5/5] PEP8 double aggressive W291 ~ W293 and W391 --- contrib/oe-stylize.py | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/contrib/oe-stylize.py b/contrib/oe-stylize.py index cfabb90b10f..e1ba1b32188 100755 --- a/contrib/oe-stylize.py +++ b/contrib/oe-stylize.py @@ -2,12 +2,12 @@ """\ Sanitize a bitbake file following the OpenEmbedded style guidelines, -see http://openembedded.org/wiki/StyleGuide +see http://openembedded.org/wiki/StyleGuide (C) 2006 Cyril Romain MIT license -TODO: +TODO: - add the others OpenEmbedded variables commonly used: - parse command arguments and print usage on misuse . prevent giving more than one .bb file in arguments @@ -19,7 +19,7 @@ - count rule breaks and displays them in the order frequence """ -from __future__ import print_function +from __future__ import print_function import fileinput import string import re @@ -65,7 +65,7 @@ 'RSUGGESTS', 'RPROVIDES', 'RCONFLICTS', - 'FILES', + 'FILES', 'do_package', 'do_stage', 'addhandler', @@ -215,36 +215,36 @@ # Variables seen in the processed .bb seen_vars = {} -for v in OE_vars: +for v in OE_vars: seen_vars[v] = [] -# _Format guideline #0_: -# No spaces are allowed at the beginning of lines that define a variable or +# _Format guideline #0_: +# No spaces are allowed at the beginning of lines that define a variable or # a do_ routine -def respect_rule0(line): +def respect_rule0(line): return line.lstrip() == line -def conformTo_rule0(line): +def conformTo_rule0(line): return line.lstrip() -# _Format guideline #1_: +# _Format guideline #1_: # No spaces are allowed behind the line continuation symbol '\' def respect_rule1(line): if line.rstrip().endswith('\\'): return line.endswith('\\') - else: + else: return True def conformTo_rule1(line): return line.rstrip() -# _Format guideline #2_: +# _Format guideline #2_: # Tabs should not be used (use spaces instead). @@ -256,14 +256,14 @@ def conformTo_rule2(line): return line.expandtabs() # _Format guideline #3_: -# Comments inside bb files are allowed using the '#' character at the +# Comments inside bb files are allowed using the '#' character at the # beginning of a line. def respect_rule3(line): if line.lstrip().startswith('#'): return line.startswith('#') - else: + else: return True @@ -364,8 +364,8 @@ def follow_rule(i, line): if True: lines.append(line) else: - # expandtabs on each line so that rule2 is always respected - # rstrip each line so that rule1 is always respected + # expandtabs on each line so that rule2 is always respected + # rstrip each line so that rule1 is always respected line = line.expandtabs().rstrip() # ignore empty lines (or line filled with spaces or tabs only) # so that rule6 is always respected @@ -377,7 +377,7 @@ def follow_rule(i, line): in_routine = False commentBloc = [] olines = [] - for line in lines: + for line in lines: originalLine = line # rstrip line to remove line breaks characters line = line.rstrip() @@ -393,7 +393,7 @@ def follow_rule(i, line): commentBloc = [] continue - if line.startswith('}'): + if line.startswith('}'): in_routine = False keep = line.endswith('\\') or in_routine @@ -415,7 +415,7 @@ def follow_rule(i, line): if line.startswith(k): var = k break - if re.match(routineRegexp, line) is not None: + if re.match(routineRegexp, line) is not None: in_routine = True line = follow_rule(0, line) elif re.match(varRegexp, line) is not None: @@ -443,12 +443,11 @@ def follow_rule(i, line): for k in OE_vars: if k == 'SRC_URI': addEmptyLine = True - if seen_vars[k] != []: + if seen_vars[k] != []: if addEmptyLine and not k.startswith(previourVarPrefix): olines.append("") - for l in seen_vars[k]: + for l in seen_vars[k]: olines.append(l) previourVarPrefix = k.split('_')[0] == '' and "unknown" or k.split('_')[0] for line in olines: print(line) -