From c20091d7acd2599e0065d0778a1f2a4c704db426 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Thu, 16 Apr 2026 14:18:55 +0200 Subject: [PATCH] App.distro_info(): Accept and return lists App.distro_info() accepts and returns str instances, interpret anything passed as fmt parameter which is not a str as iterable, and return lists of expanded strings in that case. Signed-off-by: Jan Lindemann --- src/python/jw/pkg/App.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/python/jw/pkg/App.py b/src/python/jw/pkg/App.py index 62b2aef8..f58698fc 100644 --- a/src/python/jw/pkg/App.py +++ b/src/python/jw/pkg/App.py @@ -5,7 +5,7 @@ from __future__ import annotations -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, Iterable if TYPE_CHECKING: from typing import TypeAlias @@ -418,7 +418,12 @@ class App(Base): self.__distro = ret return self.__distro - def distro_info(self, fmt: str) -> str: + def distro_info(self, fmt: str|Iterable) -> str|Iterable: + if not isinstance(fmt, str): + ret: list[str] = [] + for entry in fmt: + ret.append(self.distro_info(entry)) + return ret ret = fmt for macro in re.findall("%{([A-Za-z_-]+)}", fmt): try: