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:
parent
63f0fef12e
commit
2fad5d189c
2 changed files with 73 additions and 30 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class DummyDistro(Distro):
|
|||
pass
|
||||
|
||||
@override
|
||||
async def _pkg_files(self, name: str) -> Iterable[str]:
|
||||
async def _pkg_files(self, names: list[str] | None) -> Iterable[str]:
|
||||
return []
|
||||
|
||||
def distro(os_release_str: str) -> Distro:
|
||||
|
|
|
|||
Loading…
Reference in a new issue