comparison contrib/check-code.py @ 29568:7825f6154a65

check-code: factor out boot procedure into main This is a part of preparation for adding check-code.py extra checks by another python script in subsequent patch. This is also useful for SkeletonExtensionPlan. https://www.mercurial-scm.org/wiki/SkeletonExtensionPlan
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Fri, 20 May 2016 09:47:35 +0900
parents 075146e85bb6
children 3d52e7c78a6b
comparison
equal deleted inserted replaced
29567:7e2b389418da 29568:7825f6154a65
620 print(" (too many errors, giving up)") 620 print(" (too many errors, giving up)")
621 break 621 break
622 622
623 return result 623 return result
624 624
625 if __name__ == "__main__": 625 def main():
626 parser = optparse.OptionParser("%prog [options] [files]") 626 parser = optparse.OptionParser("%prog [options] [files]")
627 parser.add_option("-w", "--warnings", action="store_true", 627 parser.add_option("-w", "--warnings", action="store_true",
628 help="include warning-level checks") 628 help="include warning-level checks")
629 parser.add_option("-p", "--per-file", type="int", 629 parser.add_option("-p", "--per-file", type="int",
630 help="max warnings per file") 630 help="max warnings per file")
648 for f in check: 648 for f in check:
649 if not checkfile(f, maxerr=options.per_file, warnings=options.warnings, 649 if not checkfile(f, maxerr=options.per_file, warnings=options.warnings,
650 blame=options.blame, debug=options.debug, 650 blame=options.blame, debug=options.debug,
651 lineno=options.lineno): 651 lineno=options.lineno):
652 ret = 1 652 ret = 1
653 sys.exit(ret) 653 return ret
654
655 if __name__ == "__main__":
656 sys.exit(main())