Kaydet (Commit) ec5cf095 authored tarafından Nick Coghlan's avatar Nick Coghlan

Better control when dumping import state

üst 5fbd37e5
...@@ -7,27 +7,25 @@ from pprint import pprint ...@@ -7,27 +7,25 @@ from pprint import pprint
def _dump_state(args): def _dump_state(args):
print(sys.version) print(sys.version)
print("sys.path:") for name in args.attributes:
pprint(sys.path) print("sys.{}:".format(name))
print("sys.meta_path") pprint(getattr(sys, name))
pprint(sys.meta_path)
print("sys.path_hooks") def _add_dump_args(cmd):
pprint(sys.path_hooks) cmd.add_argument("attributes", metavar="ATTR", nargs="+",
print("sys.path_importer_cache") help="sys module attribute to display")
pprint(sys.path_importer_cache)
print("sys.modules:")
pprint(sys.modules)
COMMANDS = ( COMMANDS = (
("dump", "Dump import state", _dump_state), ("dump", "Dump import state", _dump_state, _add_dump_args),
) )
def _make_parser(): def _make_parser():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
sub = parser.add_subparsers(title="Commands") 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 = sub.add_parser(name, help=description)
cmd.set_defaults(command=implementation) cmd.set_defaults(command=implementation)
add_args(cmd)
return parser return parser
def main(args): def main(args):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment