Get a postprocessor, run the commands on the given arguments, split the output and return the number of non-OK'd warnings.
(args, cmds=_Cmds, OKd=_OKd, out=_Out, debug=_Debug,
recursive=_Recursive, x3=_X3)
| 521 | |
| 522 | |
| 523 | def main(args, cmds=_Cmds, OKd=_OKd, out=_Out, debug=_Debug, |
| 524 | recursive=_Recursive, x3=_X3): |
| 525 | '''Get a postprocessor, run the commands on the |
| 526 | given arguments, split the output and return |
| 527 | the number of non-OK'd warnings. |
| 528 | ''' |
| 529 | m = n = 0 |
| 530 | p = Processor(cmds, OKd, debug, out=out, x3=x3) |
| 531 | while args: |
| 532 | arg = args.pop(0) |
| 533 | if os.path.isdir(arg): |
| 534 | for d, ds, fs in os.walk(arg): |
| 535 | for f in fs: |
| 536 | if _Xpy and f.endswith(_Xpy): |
| 537 | pass # exclude |
| 538 | elif f.endswith('.py'): |
| 539 | f = os.path.join(d, f) |
| 540 | n += p.warnings(f) |
| 541 | m += 1 |
| 542 | if recursive: |
| 543 | args.extend(ds) |
| 544 | else: |
| 545 | n += p.warnings(arg) |
| 546 | m += 1 |
| 547 | if m != 1: |
| 548 | p.printf('%s%s total in %s', _NL, plural(n, 'error'), plural(m, 'module')) |
| 549 | return n # number of non-OK'd warnings |
| 550 | |
| 551 | |
| 552 | if __name__ == '__main__': |