MCPcopy Index your code
hub / github.com/python/cpython / _main

Function _main

Lib/pickletools.py:2842–2887  ·  view source on GitHub ↗
(args=None)

Source from the content-addressed store, hash-verified

2840
2841
2842def _main(args=None):
2843 import argparse
2844 parser = argparse.ArgumentParser(
2845 description='disassemble one or more pickle files',
2846 color=True,
2847 )
2848 parser.add_argument(
2849 'pickle_file',
2850 nargs='+', help='the pickle file')
2851 parser.add_argument(
2852 '-o', '--output',
2853 help='the file where the output should be written')
2854 parser.add_argument(
2855 '-m', '--memo', action='store_true',
2856 help='preserve memo between disassemblies')
2857 parser.add_argument(
2858 '-l', '--indentlevel', default=4, type=int,
2859 help='the number of blanks by which to indent a new MARK level')
2860 parser.add_argument(
2861 '-a', '--annotate', action='store_true',
2862 help='annotate each line with a short opcode description')
2863 parser.add_argument(
2864 '-p', '--preamble', default="==> {name} <==",
2865 help='if more than one pickle file is specified, print this before'
2866 ' each disassembly')
2867 args = parser.parse_args(args)
2868 annotate = 30 if args.annotate else 0
2869 memo = {} if args.memo else None
2870 if args.output is None:
2871 output = sys.stdout
2872 else:
2873 output = open(args.output, 'w')
2874 try:
2875 for arg in args.pickle_file:
2876 if len(args.pickle_file) > 1:
2877 name = '<stdin>' if arg == '-' else arg
2878 preamble = args.preamble.format(name=name)
2879 output.write(preamble + '\n')
2880 if arg == '-':
2881 dis(sys.stdin.buffer, output, memo, args.indentlevel, annotate)
2882 else:
2883 with open(arg, 'rb') as f:
2884 dis(f, output, memo, args.indentlevel, annotate)
2885 finally:
2886 if output is not sys.stdout:
2887 output.close()
2888
2889
2890if __name__ == "__main__":

Callers 1

pickletools.pyFile · 0.70

Calls 7

parse_argsMethod · 0.95
openFunction · 0.70
disFunction · 0.70
add_argumentMethod · 0.45
formatMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…