|
|
@@ -1,15 +1,17 @@ |
|
|
|
import importlib |
|
|
|
import os |
|
|
|
import codearchiver.core |
|
|
|
import pkgutil |
|
|
|
|
|
|
|
|
|
|
|
__all__ = [] |
|
|
|
|
|
|
|
|
|
|
|
def _import_modules(): |
|
|
|
files = os.listdir(__path__[0]) |
|
|
|
for fn in files: |
|
|
|
if fn.endswith('.py') and fn != '__init__.py': |
|
|
|
# Import module if not already imported |
|
|
|
moduleName = f'codearchiver.modules.{fn[:-3]}' |
|
|
|
module = importlib.import_module(moduleName) |
|
|
|
prefixLen = len(__name__) + 1 |
|
|
|
for importer, moduleName, isPkg in pkgutil.iter_modules(__path__, prefix = f'{__name__}.'): |
|
|
|
assert not isPkg |
|
|
|
moduleNameWithoutPrefix = moduleName[prefixLen:] |
|
|
|
__all__.append(moduleNameWithoutPrefix) |
|
|
|
module = importer.find_module(moduleName).load_module(moduleName) |
|
|
|
globals()[moduleNameWithoutPrefix] = module |
|
|
|
|
|
|
|
|
|
|
|
_import_modules() |