mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-10-01 06:21:56 -09:00
support/scripts/pycompile: add main entry point
Only run code when the script is executed directly (not imported).
Factorize command description by using the script's __doc__ variable.
Fix typo in --force help message.
Signed-off-by: Robin Jarry <robin.jarry@6wind.com>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
(cherry picked from commit 7b3025f93e)
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
This commit is contained in:
committed by
Peter Korsgaard
parent
04f541b88b
commit
17bcb6e157
@@ -58,12 +58,19 @@ class ReportProblem(int):
|
|||||||
return not self == other
|
return not self == other
|
||||||
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Compile Python source files in a directory tree.')
|
def main():
|
||||||
parser.add_argument("target", metavar='DIRECTORY',
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
help='Directory to scan')
|
parser.add_argument("target", metavar="TARGET",
|
||||||
parser.add_argument("--force", action='store_true',
|
help="Directory to scan")
|
||||||
help="Force compilation even if alread compiled")
|
parser.add_argument("--force", action="store_true",
|
||||||
|
help="Force compilation even if already compiled")
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
compileall.compile_dir(args.target, force=args.force, quiet=ReportProblem())
|
compileall.compile_dir(args.target, force=args.force, quiet=ReportProblem())
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
||||||
|
|||||||
Reference in New Issue
Block a user