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 <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-04-16 14:18:55 +02:00
commit c20091d7ac

View file

@ -5,7 +5,7 @@
from __future__ import annotations from __future__ import annotations
from typing import TYPE_CHECKING from typing import TYPE_CHECKING, Iterable
if TYPE_CHECKING: if TYPE_CHECKING:
from typing import TypeAlias from typing import TypeAlias
@ -418,7 +418,12 @@ class App(Base):
self.__distro = ret self.__distro = ret
return self.__distro 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 ret = fmt
for macro in re.findall("%{([A-Za-z_-]+)}", fmt): for macro in re.findall("%{([A-Za-z_-]+)}", fmt):
try: try: