Exemple #1
0
 def create_loader(pack_name, filepath):
     ext = filepath.ext
     if ext in ilm.SOURCE_SUFFIXES:
         return ilm.SourceFileLoader(pack_name, str(filepath))
     if ext in ilm.BYTECODE_SUFFIXES:
         return ilm.SourcelessFileLoader(pack_name, str(filepath))
     if ext in ilm.EXTENSION_SUFFIXES:
         return ilm.ExtensionFileLoader(pack_name, str(filepath))
Exemple #2
0
def load_project_from_file(filepath):

    mod_name, file_ext = os.path.splitext(os.path.split(filepath)[-1])

    if file_ext.lower() == '.py':
        #py_mod = imp.load_source(mod_name, filepath)
        py_mod = loader.SourceFileLoader(mod_name, filepath).load_module()
    elif file_ext.lower() == '.pyc':
        #py_mod = imp.load_compiled(mod_name, filepath)
        py_mod = loader.SourcelessFileLoader(mod_name, filepath).load_module()

    return py_mod
Exemple #3
0
 def load_module_pyc(module_id, path):
     return machinery.SourcelessFileLoader(
         module_id, path).load_module(module_id)