@@ -2838,9 +2838,6 @@ def __init__(self, value):
28382838 'disassembler_memo_test' : _memo_test ,
28392839 }
28402840
2841- def _test ():
2842- import doctest
2843- return doctest .testmod ()
28442841
28452842if __name__ == "__main__" :
28462843 import argparse
@@ -2865,36 +2862,27 @@ def _test():
28652862 '-p' , '--preamble' , default = "==> {name} <==" ,
28662863 help = 'if more than one pickle file is specified, print this before'
28672864 ' each disassembly' )
2868- parser .add_argument (
2869- '-t' , '--test' , action = 'store_true' ,
2870- help = 'run self-test suite' )
2871- parser .add_argument (
2872- '-v' , action = 'store_true' ,
2873- help = 'run verbosely; only affects self-test run' )
28742865 args = parser .parse_args ()
2875- if args .test :
2876- _test ()
2866+ if not args .pickle_file :
2867+ parser . print_help ()
28772868 else :
2878- if not args .pickle_file :
2879- parser .print_help ()
2869+ annotate = 30 if args .annotate else 0
2870+ memo = {} if args .memo else None
2871+ if args .output is None :
2872+ output = sys .stdout
28802873 else :
2881- annotate = 30 if args .annotate else 0
2882- memo = {} if args .memo else None
2883- if args .output is None :
2884- output = sys .stdout
2885- else :
2886- output = open (args .output , 'w' )
2887- try :
2888- for arg in args .pickle_file :
2889- if len (args .pickle_file ) > 1 :
2890- name = '<stdin>' if arg == '-' else arg
2891- preamble = args .preamble .format (name = name )
2892- output .write (preamble + '\n ' )
2893- if arg == '-' :
2894- dis (sys .stdin .buffer , output , memo , args .indentlevel , annotate )
2895- else :
2896- with open (arg , 'rb' ) as f :
2897- dis (f , output , memo , args .indentlevel , annotate )
2898- finally :
2899- if output is not sys .stdout :
2900- output .close ()
2874+ output = open (args .output , 'w' )
2875+ try :
2876+ for arg in args .pickle_file :
2877+ if len (args .pickle_file ) > 1 :
2878+ name = '<stdin>' if arg == '-' else arg
2879+ preamble = args .preamble .format (name = name )
2880+ output .write (preamble + '\n ' )
2881+ if arg == '-' :
2882+ dis (sys .stdin .buffer , output , memo , args .indentlevel , annotate )
2883+ else :
2884+ with open (arg , 'rb' ) as f :
2885+ dis (f , output , memo , args .indentlevel , annotate )
2886+ finally :
2887+ if output is not sys .stdout :
2888+ output .close ()
0 commit comments