diff --git a/src/elironwars/entrypoints.py b/src/elironwars/entrypoints.py new file mode 100644 index 0000000..4278e02 --- /dev/null +++ b/src/elironwars/entrypoints.py @@ -0,0 +1,18 @@ +import logging +from importlib.metadata import entry_points + +logger = logging.getLogger(__name__) + + +class Entrypoints: + + def __init__(self): + self.ui = entry_points(group='elironwars.ui') + + def load_ui(self, ui): + logger.info('Loading ui %s', ui) + try: + ui_class = self.ui[ui].load() + return ui_class() + except KeyError: + logger.critical('Unable to load ui %s', ui)