2016-07-31 17:18:17 +02:00
|
|
|
import pkgutil
|
|
|
|
import inspect
|
|
|
|
import importlib
|
|
|
|
import boxes
|
2016-03-25 17:49:33 +01:00
|
|
|
|
|
|
|
def getAllBoxGenerators():
|
2016-07-31 17:18:17 +02:00
|
|
|
generators = {}
|
|
|
|
for importer, modname, ispkg in pkgutil.walk_packages(
|
|
|
|
path=__path__,
|
|
|
|
prefix=__name__+'.',
|
|
|
|
onerror=lambda x: None):
|
|
|
|
module = importlib.import_module(modname)
|
|
|
|
for k, v in module.__dict__.items():
|
|
|
|
if v is boxes.Boxes:
|
|
|
|
continue
|
|
|
|
if inspect.isclass(v) and issubclass(v, boxes.Boxes):
|
|
|
|
generators[modname + '.' + v.__name__] = v
|
|
|
|
return generators
|
|
|
|
|
|
|
|
def getAllGeneratorModules():
|
|
|
|
generators = {}
|
|
|
|
for importer, modname, ispkg in pkgutil.walk_packages(
|
|
|
|
path=__path__,
|
|
|
|
prefix=__name__+'.',
|
|
|
|
onerror=lambda x: None):
|
|
|
|
module = importlib.import_module(modname)
|
|
|
|
generators[modname.split('.')[-1]] = module
|
|
|
|
return generators
|
|
|
|
|