for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
#!/usr/bin/env python
import marshal
import os
from assert_exists import assert_exists
from public import public
# # http://nedbatchelder.com/blog/200804/the_structure_of_pyc_files.html
def code(path):
"""return marshal.load(file)"""
if os.path.exists(path):
h = open(path, "rb")
return marshal.load(h)
def is_loaded(path):
try:
code(path)
return True
except Exception:
return False
@public
def ispythoncompiled(path):
"""return True if file compiled"""
if not path or path[-1] != "c":
if os.path.splitext(path)[1] == ".pyc":
assert_exists(path)
return is_loaded(path)