diff options
| -rwxr-xr-x | contrib/oe-stylize.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/contrib/oe-stylize.py b/contrib/oe-stylize.py index 7958797059..9d95911ae6 100755 --- a/contrib/oe-stylize.py +++ b/contrib/oe-stylize.py | |||
| @@ -222,7 +222,7 @@ for v in OE_vars: | |||
| 222 | # No spaces are allowed at the beginning of lines that define a variable or | 222 | # No spaces are allowed at the beginning of lines that define a variable or |
| 223 | # a do_ routine | 223 | # a do_ routine |
| 224 | def respect_rule0(line): | 224 | def respect_rule0(line): |
| 225 | return line.lstrip()==line | 225 | return line.lstrip() == line |
| 226 | def conformTo_rule0(line): | 226 | def conformTo_rule0(line): |
| 227 | return line.lstrip() | 227 | return line.lstrip() |
| 228 | 228 | ||
| @@ -239,7 +239,7 @@ def conformTo_rule1(line): | |||
| 239 | # _Format guideline #2_: | 239 | # _Format guideline #2_: |
| 240 | # Tabs should not be used (use spaces instead). | 240 | # Tabs should not be used (use spaces instead). |
| 241 | def respect_rule2(line): | 241 | def respect_rule2(line): |
| 242 | return line.count('\t')==0 | 242 | return line.count('\t') == 0 |
| 243 | def conformTo_rule2(line): | 243 | def conformTo_rule2(line): |
| 244 | return line.expandtabs() | 244 | return line.expandtabs() |
| 245 | 245 | ||
| @@ -261,7 +261,7 @@ def respect_rule4(line): | |||
| 261 | if r is not None: | 261 | if r is not None: |
| 262 | r2 = re.search(r'("?)([^"\\]*)(["\\]?)', r.group(5)) | 262 | r2 = re.search(r'("?)([^"\\]*)(["\\]?)', r.group(5)) |
| 263 | # do not test for None it because always match | 263 | # do not test for None it because always match |
| 264 | return r2.group(1)=='"' and r2.group(3)!='' | 264 | return r2.group(1) == '"' and r2.group(3) != '' |
| 265 | return False | 265 | return False |
| 266 | def conformTo_rule4(line): | 266 | def conformTo_rule4(line): |
| 267 | r = re.search(varRegexp, line) | 267 | r = re.search(varRegexp, line) |
| @@ -271,7 +271,7 @@ def conformTo_rule4(line): | |||
| 271 | # The correct spacing for a variable is FOO = "BAR". | 271 | # The correct spacing for a variable is FOO = "BAR". |
| 272 | def respect_rule5(line): | 272 | def respect_rule5(line): |
| 273 | r = re.search(varRegexp, line) | 273 | r = re.search(varRegexp, line) |
| 274 | return r is not None and r.group(2)==" " and r.group(4)==" " | 274 | return r is not None and r.group(2) == " " and r.group(4) == " " |
| 275 | def conformTo_rule5(line): | 275 | def conformTo_rule5(line): |
| 276 | r = re.search(varRegexp, line) | 276 | r = re.search(varRegexp, line) |
| 277 | return ''.join([r.group(1), ' ', r.group(3), ' ', r.group(5)]) | 277 | return ''.join([r.group(1), ' ', r.group(3), ' ', r.group(5)]) |
| @@ -279,7 +279,7 @@ def conformTo_rule5(line): | |||
| 279 | # _Format guideline #6_: | 279 | # _Format guideline #6_: |
| 280 | # Don't use spaces or tabs on empty lines | 280 | # Don't use spaces or tabs on empty lines |
| 281 | def respect_rule6(line): | 281 | def respect_rule6(line): |
| 282 | return not line.isspace() or line=="\n" | 282 | return not line.isspace() or line == "\n" |
| 283 | def conformTo_rule6(line): | 283 | def conformTo_rule6(line): |
| 284 | return "" | 284 | return "" |
| 285 | 285 | ||
| @@ -359,7 +359,7 @@ if __name__ == "__main__": | |||
| 359 | continue | 359 | continue |
| 360 | 360 | ||
| 361 | if line.startswith('}'): | 361 | if line.startswith('}'): |
| 362 | in_routine=False | 362 | in_routine = False |
| 363 | keep = line.endswith('\\') or in_routine | 363 | keep = line.endswith('\\') or in_routine |
| 364 | 364 | ||
| 365 | # handles commented lines | 365 | # handles commented lines |
| @@ -381,7 +381,7 @@ if __name__ == "__main__": | |||
| 381 | var = k | 381 | var = k |
| 382 | break | 382 | break |
| 383 | if re.match(routineRegexp, line) is not None: | 383 | if re.match(routineRegexp, line) is not None: |
| 384 | in_routine=True | 384 | in_routine = True |
| 385 | line = follow_rule(0, line) | 385 | line = follow_rule(0, line) |
| 386 | elif re.match(varRegexp, line) is not None: | 386 | elif re.match(varRegexp, line) is not None: |
| 387 | line = follow_rule(0, line) | 387 | line = follow_rule(0, line) |
| @@ -406,14 +406,14 @@ if __name__ == "__main__": | |||
| 406 | # write variables and routines | 406 | # write variables and routines |
| 407 | previourVarPrefix = "unknown" | 407 | previourVarPrefix = "unknown" |
| 408 | for k in OE_vars: | 408 | for k in OE_vars: |
| 409 | if k=='SRC_URI': | 409 | if k == 'SRC_URI': |
| 410 | addEmptyLine = True | 410 | addEmptyLine = True |
| 411 | if seen_vars[k] != []: | 411 | if seen_vars[k] != []: |
| 412 | if addEmptyLine and not k.startswith(previourVarPrefix): | 412 | if addEmptyLine and not k.startswith(previourVarPrefix): |
| 413 | olines.append("") | 413 | olines.append("") |
| 414 | for l in seen_vars[k]: | 414 | for l in seen_vars[k]: |
| 415 | olines.append(l) | 415 | olines.append(l) |
| 416 | previourVarPrefix = k.split('_')[0]=='' and "unknown" or k.split('_')[0] | 416 | previourVarPrefix = k.split('_')[0] == '' and "unknown" or k.split('_')[0] |
| 417 | for line in olines: | 417 | for line in olines: |
| 418 | print(line) | 418 | print(line) |
| 419 | 419 | ||
