ยปCore Development>Code coverage>Tools/scripts/import_diagnostics.py

Python code coverage for Tools/scripts/import_diagnostics.py

#countcontent
1n/a#!/usr/bin/env python3
2n/a"""Miscellaneous diagnostics for the import system"""
3n/a
4n/aimport sys
5n/aimport argparse
6n/afrom pprint import pprint
7n/a
8n/adef _dump_state(args):
9n/a print(sys.version)
10n/a for name in args.attributes:
11n/a print("sys.{}:".format(name))
12n/a pprint(getattr(sys, name))
13n/a
14n/adef _add_dump_args(cmd):
15n/a cmd.add_argument("attributes", metavar="ATTR", nargs="+",
16n/a help="sys module attribute to display")
17n/a
18n/aCOMMANDS = (
19n/a ("dump", "Dump import state", _dump_state, _add_dump_args),
20n/a)
21n/a
22n/adef _make_parser():
23n/a parser = argparse.ArgumentParser()
24n/a sub = parser.add_subparsers(title="Commands")
25n/a for name, description, implementation, add_args in COMMANDS:
26n/a cmd = sub.add_parser(name, help=description)
27n/a cmd.set_defaults(command=implementation)
28n/a add_args(cmd)
29n/a return parser
30n/a
31n/adef main(args):
32n/a parser = _make_parser()
33n/a args = parser.parse_args(args)
34n/a return args.command(args)
35n/a
36n/aif __name__ == "__main__":
37n/a sys.exit(main(sys.argv[1:]))