Exemplo n.º 1
0
def depyc(args):

    binary = args.input.read()
    modtime, code = extract(binary)

    print("Decompiling module %r compiled on %s" % (args.input.name, modtime), file=sys.stderr)

    if args.output_type == "pyc":
        if py3 and args.output is sys.stdout:
            args.output = sys.stdout.buffer
        args.output.write(binary)
        return

    if args.output_type == "opcode":
        print_code(code)
        return

    mod_ast = make_module(code)

    if args.output_type == "ast":
        print_ast(mod_ast, file=args.output)
        return

    if args.output_type == "python":
        python_source(mod_ast, file=args.output)
        return

    raise Exception("unknow output type %r" % args.output_type)
Exemplo n.º 2
0
def depyc(args):

    binary = args.input.read()
    modtime, code = extract(binary)

    print("Decompiling module %r compiled on %s" % (
        args.input.name,
        modtime,
    ),
          file=sys.stderr)

    if args.output_type == 'pyc':
        if py3 and args.output is sys.stdout:
            args.output = sys.stdout.buffer
        args.output.write(binary)
        return

    if args.output_type == 'opcode':
        print_code(code)
        return

    mod_ast = make_module(code)

    if args.output_type == 'ast':
        print_ast(mod_ast, file=args.output)
        return

    if args.output_type == 'python':
        python_source(mod_ast, file=args.output)
        return

    raise Exception("unknow output type %r" % args.output_type)
Exemplo n.º 3
0
def decompile_pyc(bin_pyc, output=sys.stdout):
    '''
    decompile apython pyc or pyo binary file.
    
    :param bin_pyc: input file objects
    :param output: output file objects
    '''
    
    from graphlab.meta.asttools import python_source
    
    bin = bin_pyc.read()
    
    code = marshal.loads(bin[8:])
    
    mod_ast = make_module(code)
    
    python_source(mod_ast, file=output)
Exemplo n.º 4
0
def decompile_pyc(bin_pyc, output=sys.stdout):
    '''
    decompile apython pyc or pyo binary file.
    
    :param bin_pyc: input file objects
    :param output: output file objects
    '''

    from graphlab.meta.asttools import python_source

    bin = bin_pyc.read()

    code = marshal.loads(bin[8:])

    mod_ast = make_module(code)

    python_source(mod_ast, file=output)