lib.Distro: Add .id

Allow to query the distribution ID a Distro was instantiated with via
the .id property.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-03-07 11:15:16 +01:00
commit bd38700f67

View file

@ -18,6 +18,10 @@ class Distro(abc.ABC):
def __init__(self, ec: ExecContext):
assert ec is not None
self.__exec_context = ec
self.__id: str|None = None
def __set_id(self, id: str) -> None:
self.__id = id
# == Load
@ -38,10 +42,16 @@ class Distro(abc.ABC):
log(ERR, f'Failed to import Distro module {module_path} ({str(e)})')
raise
cls = getattr(module, 'Distro')
return cls(*args, **kwargs)
ret = cls(*args, **kwargs)
ret.__set_id(backend_id)
return ret
# == Convenience methods
@property
def id(self) -> str:
return self.__id
@property
def ctx(self) -> ExecContext:
return self.__exec_context