20 lines
695 B
Python
20 lines
695 B
Python
from os import listdir
|
|
from os.path import isdir, isfile, dirname, abspath, basename, join
|
|
from importlib import import_module
|
|
from ..dispatcher import dispatcher
|
|
|
|
|
|
def load_services(modules=None,
|
|
validate: bool=True):
|
|
abs_here = dirname(abspath(__file__))
|
|
here = basename(abs_here)
|
|
module = basename(dirname(abs_here))
|
|
if not modules:
|
|
modules = listdir(abs_here)
|
|
for filename in modules:
|
|
absfilename = join(abs_here, filename)
|
|
if isdir(absfilename) and isfile(join(absfilename, '__init__.py')):
|
|
dispatcher.set_module(filename, import_module(f'.{here}.{filename}', module))
|
|
if validate:
|
|
dispatcher.validate()
|