Created
March 16, 2016 04:18
-
-
Save baljanak/9ad5ba48afce9d5f1991 to your computer and use it in GitHub Desktop.
decompile pyc to py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import ast | |
import marshal | |
import uuid | |
import meta | |
def pyc2py(pyc_file, path='/tmp'): | |
with open(pyc_file, 'rb') as fd: | |
magic, timestamp, source = fd.read(4), fd.read(4), meta.dump_python_source(meta.decompile(marshal.load(fd))) | |
with open(os.path.join(path, pyc_file.split('.')[0].split('/')[-1] + '.py'), 'w') as wfd: | |
wfd.write(source) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment