diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2012-04-25 12:17:54 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2012-04-25 12:17:54 (GMT) |
commit | d0bb6aa27507fede6cde3e536bd5edec5cd5dfa4 (patch) | |
tree | 9e6d9e648a7bd219ffe66da9169520224287c2b8 /Tools/scripts/import_diagnostics.py | |
parent | c94871a5c076e7fd82ccc5f055065d3911f46d40 (diff) | |
download | cpython-d0bb6aa27507fede6cde3e536bd5edec5cd5dfa4.zip cpython-d0bb6aa27507fede6cde3e536bd5edec5cd5dfa4.tar.gz cpython-d0bb6aa27507fede6cde3e536bd5edec5cd5dfa4.tar.bz2 |
Start a shared utility script for poking around at the import internals
Diffstat (limited to 'Tools/scripts/import_diagnostics.py')
-rwxr-xr-x | Tools/scripts/import_diagnostics.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/Tools/scripts/import_diagnostics.py b/Tools/scripts/import_diagnostics.py new file mode 100755 index 0000000..1aa12b3 --- /dev/null +++ b/Tools/scripts/import_diagnostics.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +"""Miscellaneous diagnostics for the import system""" + +import sys +import argparse +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) + +COMMANDS = ( + ("dump", "Dump import state", _dump_state), +) + +def _make_parser(): + parser = argparse.ArgumentParser() + sub = parser.add_subparsers(title="Commands") + for name, description, implementation in COMMANDS: + cmd = sub.add_parser(name, help=description) + cmd.set_defaults(command=implementation) + return parser + +def main(args): + parser = _make_parser() + args = parser.parse_args(args) + return args.command(args) + +if __name__ == "__main__": + sys.exit(main(sys.argv[1:])) |