def main(args): exname, args = args[0], args[1:] if len(args) < 1: print("takes at least one argument") usage(exname) return try: opts, args = getopt.getopt(args, "h", [ "help", "debug", "show-sector-chain", "no-struct-output", "dump-text", "id-select=", "no-raw-dumps" ]) for opt, arg in opts: if opt in ['-h', '--help']: usage(exname) return elif opt in ['--debug']: globals.params.debug = True elif opt in ['--show-sector-chain']: globals.params.showSectorChain = True elif opt in ['--no-struct-output']: globals.params.noStructOutput = True elif opt in ['--dump-text']: globals.params.dumpText = True elif opt in ['--no-raw-dumps']: globals.params.noRawDumps = True elif opt in ['--id-select']: globals.params.dumpedIds = arg.split(",") globals.params.dumpedIds = \ set([int(val) for val in globals.params.dumpedIds if val]) else: error("unknown option %s\n" % opt) usage() except getopt.GetoptError: error("error parsing input options\n") usage(exname) return try: dumper = PPTDumper(args[0], globals.params) if not dumper.dump(): error("FAILURE\n") if globals.params.dumpText: globals.dumptext() except Exception as ex: traceback.print_exc() error("Could not parse") sys.exit(1)
def main (args): exname, args = args[0], args[1:] if len(args) < 1: print("takes at least one argument") usage(exname) return try: opts, args = getopt.getopt(args, "h", ["help", "debug", "show-sector-chain", "no-struct-output", "dump-text", "id-select=", "no-raw-dumps"]) for opt, arg in opts: if opt in ['-h', '--help']: usage(exname) return elif opt in ['--debug']: globals.params.debug = True elif opt in ['--show-sector-chain']: globals.params.showSectorChain = True elif opt in ['--no-struct-output']: globals.params.noStructOutput = True elif opt in ['--dump-text']: globals.params.dumpText = True elif opt in ['--no-raw-dumps']: globals.params.noRawDumps = True elif opt in ['--id-select']: globals.params.dumpedIds = arg.split(",") globals.params.dumpedIds = \ set([int(val) for val in globals.params.dumpedIds if val]) else: error("unknown option %s\n"%opt) usage() except getopt.GetoptError: error("error parsing input options\n") usage(exname) return dumper = PPTDumper(args[0], globals.params) if not dumper.dump(): error("FAILURE\n") if globals.params.dumpText: globals.dumptext()