lib.Distro.pkg_files(): Take list[str] | None

Distro.pkg_files() takes a package name and returns a list of files in that
package. This commit generalizes that - pass None to it and get the list of
all packaged files in the system, and pass a list of strings to retrieve
all files belonging to the named packages.

The same arguments are propagated to _pkg_files(), which in turn propagates
them to list_files().

This allows faster generation of file lists than before. Having to retrieve
a list of matching packages and query each package for its contained files
can be collapsed into one or two backend calls.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-10-15 14:29:17 +02:00
commit 2fad5d189c
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61

View file

@ -71,8 +71,13 @@ class FakeDistro(SuseDistro):
return [Package(name) for name in names if name in self.__files]
@override
async def _pkg_files(self, name: str) -> list[str]:
return list(self.__files.get(name, []))
async def _pkg_files(self, names: list[str] | None) -> list[str]:
if names is None:
names = list(self.__files)
ret: list[str] = []
for n in names:
ret.extend(self.__files.get(n, []))
return ret
def run_cli(distro: FakeDistro, argv: list[str]) -> tuple[list[str], list[str]]:
"""Run the real jw-pkg CLI in-process, return stdout and stderr