mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-25 09:35:54 +02:00
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:
parent
72ac282b76
commit
bd38700f67
1 changed files with 11 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue