summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2012-04-29 07:58:24 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2012-04-29 07:58:24 (GMT)
commitec5cf095a9d658fad092d77fe7825933abd3cc5b (patch)
tree604158bde34fe2f5882106478c0203346a18f3f9 /Tools
parent5fbd37e57a21b15def7550c5649600531d82030d (diff)
downloadcpython-ec5cf095a9d658fad092d77fe7825933abd3cc5b.zip
cpython-ec5cf095a9d658fad092d77fe7825933abd3cc5b.tar.gz
cpython-ec5cf095a9d658fad092d77fe7825933abd3cc5b.tar.bz2
Better control when dumping import state
Diffstat (limited to 'Tools')
-rwxr-xr-xTools/scripts/import_diagnostics.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/Tools/scripts/import_diagnostics.py b/Tools/scripts/import_diagnostics.py
index 1aa12b3..c907221 100755
--- a/Tools/scripts/import_diagnostics.py
+++ b/Tools/scripts/import_diagnostics.py
@@ -7,27 +7,25 @@ from pprint import pprint
def _dump_state(args):
print(sys.version)
- print("sys.path:")
- pprint(sys.path)
- print("sys.meta_path")
- pprint(sys.meta_path)
- print("sys.path_hooks")
- pprint(sys.path_hooks)
- print("sys.path_importer_cache")
- pprint(sys.path_importer_cache)
- print("sys.modules:")
- pprint(sys.modules)
+ for name in args.attributes:
+ print("sys.{}:".format(name))
+ pprint(getattr(sys, name))
+
+def _add_dump_args(cmd):
+ cmd.add_argument("attributes", metavar="ATTR", nargs="+",
+ help="sys module attribute to display")
COMMANDS = (
- ("dump", "Dump import state", _dump_state),
+ ("dump", "Dump import state", _dump_state, _add_dump_args),
)
def _make_parser():
parser = argparse.ArgumentParser()
sub = parser.add_subparsers(title="Commands")
- for name, description, implementation in COMMANDS:
+ for name, description, implementation, add_args in COMMANDS:
cmd = sub.add_parser(name, help=description)
cmd.set_defaults(command=implementation)
+ add_args(cmd)
return parser
def main(args):