✨ entrypoint class
This commit is contained in:
@@ -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)
|
||||||
Reference in New Issue
Block a user