Ejemplo n.º 1
0
def test_funcoutput(capfd, test_tuple):

    in_file, filename_expected = test_tuple
    disassemble_file(in_file)
    resout, reserr = capfd.readouterr()
    expected = open(filename_expected, "r").read()
    if resout != expected:
        with open(filename_expected + ".got", "w") as out:
            out.write(resout)
    assert resout == expected
Ejemplo n.º 2
0
def main():
    Usage_short = """usage: %s FILE...
Type -h for for full help.""" % program

    native = True

    if len(sys.argv) == 1:
        print("No file(s) given", file=sys.stderr)
        print(Usage_short, file=sys.stderr)
        sys.exit(1)

    try:
        opts, files = getopt.getopt(sys.argv[1:], 'hVU',
                                    ['help', 'version', 'uncompyle6'])
    except getopt.GetoptError as e:
        print('%s: %s' % (os.path.basename(sys.argv[0]), e),  file=sys.stderr)
        sys.exit(-1)

    for opt, val in opts:
        if opt in ('-h', '--help'):
            print(__doc__)
            sys.exit(1)
        elif opt in ('-V', '--version'):
            print("%s %s" % (program, VERSION))
            sys.exit(0)
        elif opt in ('-U', '--uncompyle6'):
            native = False
        else:
            print(opt)
            print(Usage_short, file=sys.stderr)
            sys.exit(1)


    for file in files:
        if os.path.exists(files[0]):
            disassemble_file(file, sys.stdout, native)
        else:
            print("Can't read %s - skipping" % files[0],
                  file=sys.stderr)
            pass
        pass
    return