Initial commit (Cython implementation)

This commit is contained in:
Overwatch 2014-08-04 16:51:07 +02:00
commit 6f28ac0382
13 changed files with 1616 additions and 0 deletions

View file

@ -0,0 +1,31 @@
import imp
def import_module(path):
"""
Imports a python file as a module. The path can be relative or absolute.
Based on the work of Yuval Greenfield released into the public domain.
"""
# remove the .py suffix
mod_dn = os.path.dirname(path)
mod_fn = os.path.basename(path)
if mod_fn.endswith(".py"):
mod_name = mod_fn[:-3]
else:
# packages for example
mod_name = mod_fn
fd = None
try:
data = imp.find_module(mod_name, [mod_dn])
module = imp.load_module(mod_name, *data)
fd = data[0]
finally:
if fd is not None:
fd.close()
return module