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
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):
......
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