forked from SCM-NV/PLAMS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
21 lines (18 loc) · 882 Bytes
/
__init__.py
File metadata and controls
21 lines (18 loc) · 882 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
def __autoimport(path, folders):
import os
from os.path import join as opj
is_module = lambda x: x.endswith('.py') and not x.startswith('__init__')
ret = []
for folder in folders:
for dirpath, dirnames, filenames in os.walk(opj(path,folder)):
modules = [os.path.splitext(f)[0] for f in filter(is_module, filenames)]
relpath = os.path.relpath(dirpath, path).split(os.sep)
for module in modules:
imp = '.'.join(relpath + [module])
tmp = __import__(imp, globals=globals(), fromlist=['*'], level=1)
if hasattr(tmp, '__all__'):
ret += tmp.__all__
for name in tmp.__all__:
globals()[name] = vars(tmp)[name]
return ret
__all__ = __autoimport(__path__[0], ['core', 'mol', 'interfaces', 'tools', 'recipes'])