mininet-sample/experiments/__init__.py

21 lines
515 B
Python
Raw Permalink Normal View History

2020-06-24 14:11:54 +00:00
import importlib
import pkgutil
import os
2020-06-26 06:52:56 +00:00
from core.experiment import Experiment
2020-06-24 14:11:54 +00:00
pkg_dir = os.path.dirname(__file__)
for (module_loader, name, ispkg) in pkgutil.iter_modules([pkg_dir]):
importlib.import_module('.' + name, __package__)
2020-07-08 12:25:24 +00:00
# Track indirect inheritance
2020-06-26 06:52:56 +00:00
EXPERIMENTS = {}
2020-06-25 12:56:47 +00:00
def _get_all_subclasses(BaseClass):
for cls in BaseClass.__subclasses__():
if hasattr(cls, "NAME"):
2020-06-26 06:52:56 +00:00
EXPERIMENTS[cls.NAME] = cls
2020-06-25 12:56:47 +00:00
_get_all_subclasses(cls)
2020-06-26 06:52:56 +00:00
_get_all_subclasses(Experiment)