PEP8 double aggressive E301 ~ E306

Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
persianpros 2021-04-13 23:18:05 +04:30 committed by Khem Raj
parent 144c107c42
commit af6838a62c
2 changed files with 36 additions and 0 deletions

View File

@ -221,41 +221,59 @@ for v in OE_vars:
# _Format guideline #0_: # _Format guideline #0_:
# No spaces are allowed at the beginning of lines that define a variable or # No spaces are allowed at the beginning of lines that define a variable or
# a do_ routine # a do_ routine
def respect_rule0(line): def respect_rule0(line):
return line.lstrip() == line return line.lstrip() == line
def conformTo_rule0(line): def conformTo_rule0(line):
return line.lstrip() return line.lstrip()
# _Format guideline #1_: # _Format guideline #1_:
# No spaces are allowed behind the line continuation symbol '\' # No spaces are allowed behind the line continuation symbol '\'
def respect_rule1(line): def respect_rule1(line):
if line.rstrip().endswith('\\'): if line.rstrip().endswith('\\'):
return line.endswith('\\') return line.endswith('\\')
else: else:
return True return True
def conformTo_rule1(line): def conformTo_rule1(line):
return line.rstrip() return line.rstrip()
# _Format guideline #2_: # _Format guideline #2_:
# Tabs should not be used (use spaces instead). # Tabs should not be used (use spaces instead).
def respect_rule2(line): def respect_rule2(line):
return line.count('\t') == 0 return line.count('\t') == 0
def conformTo_rule2(line): def conformTo_rule2(line):
return line.expandtabs() return line.expandtabs()
# _Format guideline #3_: # _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. # beginning of a line.
def respect_rule3(line): def respect_rule3(line):
if line.lstrip().startswith('#'): if line.lstrip().startswith('#'):
return line.startswith('#') return line.startswith('#')
else: else:
return True return True
def conformTo_rule3(line): def conformTo_rule3(line):
return line.lstrip() return line.lstrip()
# _Format guideline #4_: # _Format guideline #4_:
# Use quotes on the right hand side of assignments FOO = "BAR" # Use quotes on the right hand side of assignments FOO = "BAR"
def respect_rule4(line): def respect_rule4(line):
r = re.search(varRegexp, line) r = re.search(varRegexp, line)
if r is not None: if r is not None:
@ -263,33 +281,48 @@ def respect_rule4(line):
# do not test for None it because always match # 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 return False
def conformTo_rule4(line): def conformTo_rule4(line):
r = re.search(varRegexp, line) r = re.search(varRegexp, line)
return ''.join([r.group(1), ' ', r.group(3), ' "', r.group(5), r.group(5).endswith('"') and '' or '"']) return ''.join([r.group(1), ' ', r.group(3), ' "', r.group(5), r.group(5).endswith('"') and '' or '"'])
# _Format guideline #5_: # _Format guideline #5_:
# The correct spacing for a variable is FOO = "BAR". # The correct spacing for a variable is FOO = "BAR".
def respect_rule5(line): def respect_rule5(line):
r = re.search(varRegexp, 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): def conformTo_rule5(line):
r = re.search(varRegexp, line) r = re.search(varRegexp, line)
return ''.join([r.group(1), ' ', r.group(3), ' ', r.group(5)]) return ''.join([r.group(1), ' ', r.group(3), ' ', r.group(5)])
# _Format guideline #6_: # _Format guideline #6_:
# Don't use spaces or tabs on empty lines # Don't use spaces or tabs on empty lines
def respect_rule6(line): def respect_rule6(line):
return not line.isspace() or line == "\n" return not line.isspace() or line == "\n"
def conformTo_rule6(line): def conformTo_rule6(line):
return "" return ""
# _Format guideline #7_: # _Format guideline #7_:
# Indentation of multiline variables such as SRC_URI is desireable. # Indentation of multiline variables such as SRC_URI is desireable.
def respect_rule7(line): def respect_rule7(line):
return True return True
def conformTo_rule7(line): def conformTo_rule7(line):
return line return line
rules = ( rules = (
(respect_rule0, conformTo_rule0, "No spaces are allowed at the beginning of lines that define a variable or a do_ routine"), (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 '\\'"), (respect_rule1, conformTo_rule1, "No spaces are allowed behind the line continuation symbol '\\'"),
@ -303,6 +336,8 @@ rules = (
# Function to check that a line respects a rule. If not, it tries to conform # 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. # the line to the rule. Reminder or Disgression message are dump accordingly.
def follow_rule(i, line): def follow_rule(i, line):
oldline = line oldline = line
# if the line does not respect the rule # if the line does not respect the rule

View File

@ -6,6 +6,7 @@ import tempfile
from oeqa.selftest.case import OESelftestTestCase from oeqa.selftest.case import OESelftestTestCase
from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars
class MetaOESourceMirroring(OESelftestTestCase): class MetaOESourceMirroring(OESelftestTestCase):
# Can we download everything from the OpenEmbedded Sources Mirror over http only # Can we download everything from the OpenEmbedded Sources Mirror over http only
def test_oe_source_mirror(self): def test_oe_source_mirror(self):