From 3c8f57f636dc5bfe8472444e5b1b6e2f50d3cef3 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Tue, 17 Feb 2026 12:31:29 +0100 Subject: [PATCH] jw.pkg.cmds.distro.backend.Util: Add class Add a common base class for all jw.pkg.cmds.distro.backend.*.Util classes. Signed-off-by: Jan Lindemann --- src/python/jw/pkg/cmds/distro/backend/Util.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/python/jw/pkg/cmds/distro/backend/Util.py diff --git a/src/python/jw/pkg/cmds/distro/backend/Util.py b/src/python/jw/pkg/cmds/distro/backend/Util.py new file mode 100644 index 00000000..7a4fbc8d --- /dev/null +++ b/src/python/jw/pkg/cmds/distro/backend/Util.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +from __future__ import annotations +from typing import TYPE_CHECKING + +from ....lib.util import run_cmd, run_sudo + +if TYPE_CHECKING: + from ..Cmd import Cmd + +class Util: + + def __init__(self, parent: Cmd): + self.__parent = parent + + async def _sudo(self, cmd: list[str], mod_env: dict[str, str] = {}, opts: list[str]=[]): + return await run_sudo(cmd, mod_env=mod_env, opts=opts, interactive=self.interactive) + + @property + def parent(self): + return self.__parent + + @property + def interactive(self) -> bool: + return self.__parent.interactive