diff options
| author | persianpros <persianpros@yahoo.com> | 2021-04-13 23:18:06 +0430 |
|---|---|---|
| committer | Khem Raj <raj.khem@gmail.com> | 2021-04-15 09:28:44 -0700 |
| commit | e0b9cd57fab747a84b5dddc52b7efd64afeff6f2 (patch) | |
| tree | 8eef050bd5dfac13eb5a9cd1e919f6f1cc71ef20 /contrib | |
| parent | af6838a62c53dab71941b2cc31f0e32387cd30e0 (diff) | |
| download | meta-openembedded-e0b9cd57fab747a84b5dddc52b7efd64afeff6f2.tar.gz | |
PEP8 double aggressive W291 ~ W293 and W391
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'contrib')
| -rwxr-xr-x | contrib/oe-stylize.py | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/contrib/oe-stylize.py b/contrib/oe-stylize.py index cfabb90b10..e1ba1b3218 100755 --- a/contrib/oe-stylize.py +++ b/contrib/oe-stylize.py | |||
| @@ -2,12 +2,12 @@ | |||
| 2 | 2 | ||
| 3 | """\ | 3 | """\ |
| 4 | Sanitize a bitbake file following the OpenEmbedded style guidelines, | 4 | Sanitize a bitbake file following the OpenEmbedded style guidelines, |
| 5 | see http://openembedded.org/wiki/StyleGuide | 5 | see http://openembedded.org/wiki/StyleGuide |
| 6 | 6 | ||
| 7 | (C) 2006 Cyril Romain <cyril.romain@gmail.com> | 7 | (C) 2006 Cyril Romain <cyril.romain@gmail.com> |
| 8 | MIT license | 8 | MIT license |
| 9 | 9 | ||
| 10 | TODO: | 10 | TODO: |
| 11 | - add the others OpenEmbedded variables commonly used: | 11 | - add the others OpenEmbedded variables commonly used: |
| 12 | - parse command arguments and print usage on misuse | 12 | - parse command arguments and print usage on misuse |
| 13 | . prevent giving more than one .bb file in arguments | 13 | . prevent giving more than one .bb file in arguments |
| @@ -19,7 +19,7 @@ TODO: | |||
| 19 | - count rule breaks and displays them in the order frequence | 19 | - count rule breaks and displays them in the order frequence |
| 20 | """ | 20 | """ |
| 21 | 21 | ||
| 22 | from __future__ import print_function | 22 | from __future__ import print_function |
| 23 | import fileinput | 23 | import fileinput |
| 24 | import string | 24 | import string |
| 25 | import re | 25 | import re |
| @@ -65,7 +65,7 @@ OE_vars = [ | |||
| 65 | 'RSUGGESTS', | 65 | 'RSUGGESTS', |
| 66 | 'RPROVIDES', | 66 | 'RPROVIDES', |
| 67 | 'RCONFLICTS', | 67 | 'RCONFLICTS', |
| 68 | 'FILES', | 68 | 'FILES', |
| 69 | 'do_package', | 69 | 'do_package', |
| 70 | 'do_stage', | 70 | 'do_stage', |
| 71 | 'addhandler', | 71 | 'addhandler', |
| @@ -215,36 +215,36 @@ routineRegexp = r'^([a-zA-Z0-9_ ${}-]+?)\(' | |||
| 215 | 215 | ||
| 216 | # Variables seen in the processed .bb | 216 | # Variables seen in the processed .bb |
| 217 | seen_vars = {} | 217 | seen_vars = {} |
| 218 | for v in OE_vars: | 218 | for v in OE_vars: |
| 219 | seen_vars[v] = [] | 219 | seen_vars[v] = [] |
| 220 | 220 | ||
| 221 | # _Format guideline #0_: | 221 | # _Format guideline #0_: |
| 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 | 224 | ||
| 225 | 225 | ||
| 226 | def respect_rule0(line): | 226 | def respect_rule0(line): |
| 227 | return line.lstrip() == line | 227 | return line.lstrip() == line |
| 228 | 228 | ||
| 229 | 229 | ||
| 230 | def conformTo_rule0(line): | 230 | def conformTo_rule0(line): |
| 231 | return line.lstrip() | 231 | return line.lstrip() |
| 232 | 232 | ||
| 233 | # _Format guideline #1_: | 233 | # _Format guideline #1_: |
| 234 | # No spaces are allowed behind the line continuation symbol '\' | 234 | # No spaces are allowed behind the line continuation symbol '\' |
| 235 | 235 | ||
| 236 | 236 | ||
| 237 | def respect_rule1(line): | 237 | def respect_rule1(line): |
| 238 | if line.rstrip().endswith('\\'): | 238 | if line.rstrip().endswith('\\'): |
| 239 | return line.endswith('\\') | 239 | return line.endswith('\\') |
| 240 | else: | 240 | else: |
| 241 | return True | 241 | return True |
| 242 | 242 | ||
| 243 | 243 | ||
| 244 | def conformTo_rule1(line): | 244 | def conformTo_rule1(line): |
| 245 | return line.rstrip() | 245 | return line.rstrip() |
| 246 | 246 | ||
| 247 | # _Format guideline #2_: | 247 | # _Format guideline #2_: |
| 248 | # Tabs should not be used (use spaces instead). | 248 | # Tabs should not be used (use spaces instead). |
| 249 | 249 | ||
| 250 | 250 | ||
| @@ -256,14 +256,14 @@ def conformTo_rule2(line): | |||
| 256 | return line.expandtabs() | 256 | return line.expandtabs() |
| 257 | 257 | ||
| 258 | # _Format guideline #3_: | 258 | # _Format guideline #3_: |
| 259 | # Comments inside bb files are allowed using the '#' character at the | 259 | # Comments inside bb files are allowed using the '#' character at the |
| 260 | # beginning of a line. | 260 | # beginning of a line. |
| 261 | 261 | ||
| 262 | 262 | ||
| 263 | def respect_rule3(line): | 263 | def respect_rule3(line): |
| 264 | if line.lstrip().startswith('#'): | 264 | if line.lstrip().startswith('#'): |
| 265 | return line.startswith('#') | 265 | return line.startswith('#') |
| 266 | else: | 266 | else: |
| 267 | return True | 267 | return True |
| 268 | 268 | ||
| 269 | 269 | ||
| @@ -364,8 +364,8 @@ if __name__ == "__main__": | |||
| 364 | if True: | 364 | if True: |
| 365 | lines.append(line) | 365 | lines.append(line) |
| 366 | else: | 366 | else: |
| 367 | # expandtabs on each line so that rule2 is always respected | 367 | # expandtabs on each line so that rule2 is always respected |
| 368 | # rstrip each line so that rule1 is always respected | 368 | # rstrip each line so that rule1 is always respected |
| 369 | line = line.expandtabs().rstrip() | 369 | line = line.expandtabs().rstrip() |
| 370 | # ignore empty lines (or line filled with spaces or tabs only) | 370 | # ignore empty lines (or line filled with spaces or tabs only) |
| 371 | # so that rule6 is always respected | 371 | # so that rule6 is always respected |
| @@ -377,7 +377,7 @@ if __name__ == "__main__": | |||
| 377 | in_routine = False | 377 | in_routine = False |
| 378 | commentBloc = [] | 378 | commentBloc = [] |
| 379 | olines = [] | 379 | olines = [] |
| 380 | for line in lines: | 380 | for line in lines: |
| 381 | originalLine = line | 381 | originalLine = line |
| 382 | # rstrip line to remove line breaks characters | 382 | # rstrip line to remove line breaks characters |
| 383 | line = line.rstrip() | 383 | line = line.rstrip() |
| @@ -393,7 +393,7 @@ if __name__ == "__main__": | |||
| 393 | commentBloc = [] | 393 | commentBloc = [] |
| 394 | continue | 394 | continue |
| 395 | 395 | ||
| 396 | if line.startswith('}'): | 396 | if line.startswith('}'): |
| 397 | in_routine = False | 397 | in_routine = False |
| 398 | keep = line.endswith('\\') or in_routine | 398 | keep = line.endswith('\\') or in_routine |
| 399 | 399 | ||
| @@ -415,7 +415,7 @@ if __name__ == "__main__": | |||
| 415 | if line.startswith(k): | 415 | if line.startswith(k): |
| 416 | var = k | 416 | var = k |
| 417 | break | 417 | break |
| 418 | if re.match(routineRegexp, line) is not None: | 418 | if re.match(routineRegexp, line) is not None: |
| 419 | in_routine = True | 419 | in_routine = True |
| 420 | line = follow_rule(0, line) | 420 | line = follow_rule(0, line) |
| 421 | elif re.match(varRegexp, line) is not None: | 421 | elif re.match(varRegexp, line) is not None: |
| @@ -443,12 +443,11 @@ if __name__ == "__main__": | |||
| 443 | for k in OE_vars: | 443 | for k in OE_vars: |
| 444 | if k == 'SRC_URI': | 444 | if k == 'SRC_URI': |
| 445 | addEmptyLine = True | 445 | addEmptyLine = True |
| 446 | if seen_vars[k] != []: | 446 | if seen_vars[k] != []: |
| 447 | if addEmptyLine and not k.startswith(previourVarPrefix): | 447 | if addEmptyLine and not k.startswith(previourVarPrefix): |
| 448 | olines.append("") | 448 | olines.append("") |
| 449 | for l in seen_vars[k]: | 449 | for l in seen_vars[k]: |
| 450 | olines.append(l) | 450 | olines.append(l) |
| 451 | previourVarPrefix = k.split('_')[0] == '' and "unknown" or k.split('_')[0] | 451 | previourVarPrefix = k.split('_')[0] == '' and "unknown" or k.split('_')[0] |
| 452 | for line in olines: | 452 | for line in olines: |
| 453 | print(line) | 453 | print(line) |
| 454 | |||
