From bd38700f671aaeb2a04a09b6acb0f0efe8bc195a Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Sat, 7 Mar 2026 11:15:16 +0100 Subject: [PATCH] lib.Distro: Add .id Allow to query the distribution ID a Distro was instantiated with via the .id property. Signed-off-by: Jan Lindemann --- src/python/jw/pkg/lib/Distro.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/python/jw/pkg/lib/Distro.py b/src/python/jw/pkg/lib/Distro.py index 9ca38549..34920f28 100644 --- a/src/python/jw/pkg/lib/Distro.py +++ b/src/python/jw/pkg/lib/Distro.py @@ -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