From 5ac36ec2716002c667ae5a3d4f5b418d13fba579 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Thu, 12 Nov 2026 10:48:05 +0100 Subject: [PATCH] lib.Distro.pkg_files() -> .pkg_paths() "files" is a term that can be used for many aspects of a file, its path, its content, a handle, so better use "pkg_paths" instead of "pkg_files" for Distro's method to inform about which files a package holds. That also aligns better with the recent move from PackageFilter toward PathFilter. Signed-off-by: Jan Lindemann --- src/python/jw/pkg/cmds/pkg/CmdLs.py | 2 +- .../jw/pkg/cmds/secrets/lib/DistroContext.py | 2 +- src/python/jw/pkg/lib/Distro.py | 8 ++++---- src/python/jw/pkg/lib/distros/arch/Distro.py | 2 +- src/python/jw/pkg/lib/distros/debian/Distro.py | 2 +- src/python/jw/pkg/lib/distros/redhat/Distro.py | 2 +- src/python/jw/pkg/lib/distros/suse/Distro.py | 2 +- src/python/jw/pkg/lib/ec/secret_store/KvFile.py | 2 +- src/python/jw/pkg/lib/pf/Pkg.py | 2 +- test/integration/jw_pkg/secrets/test.py | 2 +- test/unit/python/jw/pkg/lib/Distro/test.py | 16 ++++++++-------- .../jw/pkg/lib/ec/secret_store/KvFile/test.py | 2 +- .../jw/pkg/lib/ec/secret_store/Sops/test.py | 2 +- .../jw/pkg/lib/ec/secret_store/TarGpg/test.py | 2 +- .../jw/pkg/lib/ec/secret_store/Vault/test.py | 2 +- test/unit/python/jw/pkg/lib/pf/Pkg/test.py | 2 +- 16 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/python/jw/pkg/cmds/pkg/CmdLs.py b/src/python/jw/pkg/cmds/pkg/CmdLs.py index b3a74d6f..c162eda8 100644 --- a/src/python/jw/pkg/cmds/pkg/CmdLs.py +++ b/src/python/jw/pkg/cmds/pkg/CmdLs.py @@ -21,4 +21,4 @@ class CmdLs(NamedPkgsCmd): # export @override async def _run(self, args: Namespace) -> None: for name in args.names: - print('\n'.join(await self.distro.pkg_files(name))) + print('\n'.join(await self.distro.pkg_paths(name))) diff --git a/src/python/jw/pkg/cmds/secrets/lib/DistroContext.py b/src/python/jw/pkg/cmds/secrets/lib/DistroContext.py index 8f5b8cf4..3006a1a2 100644 --- a/src/python/jw/pkg/cmds/secrets/lib/DistroContext.py +++ b/src/python/jw/pkg/cmds/secrets/lib/DistroContext.py @@ -35,7 +35,7 @@ class DistroContext(FilesContext): async def match_files(self, pkg_names: Collection[str], pattern: str) -> list[str]: ret: list[str] = [] for pkg_name in pkg_names: - for path in await self.__distro.pkg_files(pkg_name): + for path in await self.__distro.pkg_paths(pkg_name): if re.match(pattern, path): ret.append(path) return ret diff --git a/src/python/jw/pkg/lib/Distro.py b/src/python/jw/pkg/lib/Distro.py index b1f911c5..4e4a98f3 100644 --- a/src/python/jw/pkg/lib/Distro.py +++ b/src/python/jw/pkg/lib/Distro.py @@ -504,13 +504,13 @@ class Distro(abc.ABC): return return await self._delete(names) - # -- pkg_files + # -- pkg_paths @abc.abstractmethod - async def _pkg_files(self, names: list[str] | None) -> Iterable[str]: + async def _pkg_paths(self, names: list[str] | None) -> Iterable[str]: pass - async def pkg_files(self, names: str | list[str] | None = None) -> Iterable[str]: + async def pkg_paths(self, names: str | list[str] | None = None) -> Iterable[str]: # -- The file paths of the packages selected by the # argument: None, the default selection, filtered to the # app's packages when a filter is set, all installed @@ -521,7 +521,7 @@ class Distro(abc.ABC): names = [names] if names is None and self.default_path_filter is not None: names = [p.name for p in await self.select()] - return await self._pkg_files(names) + return await self._pkg_paths(names) # -- verify diff --git a/src/python/jw/pkg/lib/distros/arch/Distro.py b/src/python/jw/pkg/lib/distros/arch/Distro.py index cc31b9c4..362c5708 100644 --- a/src/python/jw/pkg/lib/distros/arch/Distro.py +++ b/src/python/jw/pkg/lib/distros/arch/Distro.py @@ -67,7 +67,7 @@ class Distro(Base): ) @override - async def _pkg_files(self, names: list[str] | None) -> Iterable[str]: + async def _pkg_paths(self, names: list[str] | None) -> Iterable[str]: raise NotImplementedError( 'distro pkg ls yet implemented for Arch-like distributions' ) diff --git a/src/python/jw/pkg/lib/distros/debian/Distro.py b/src/python/jw/pkg/lib/distros/debian/Distro.py index b6f472d0..a9d73fa9 100644 --- a/src/python/jw/pkg/lib/distros/debian/Distro.py +++ b/src/python/jw/pkg/lib/distros/debian/Distro.py @@ -156,7 +156,7 @@ class Distro(Base): await self.dpkg(['-P', *names], sudo = True) @override - async def _pkg_files(self, names: list[str] | None) -> Iterable[str]: + async def _pkg_paths(self, names: list[str] | None) -> Iterable[str]: return await list_files(names, ec = self.ctx) @override diff --git a/src/python/jw/pkg/lib/distros/redhat/Distro.py b/src/python/jw/pkg/lib/distros/redhat/Distro.py index b365c3ad..c8f6b77a 100644 --- a/src/python/jw/pkg/lib/distros/redhat/Distro.py +++ b/src/python/jw/pkg/lib/distros/redhat/Distro.py @@ -88,7 +88,7 @@ class Distro(Base): await self.rpm(['-e', *names], sudo = True) @override - async def _pkg_files(self, names: list[str] | None) -> Iterable[str]: + async def _pkg_paths(self, names: list[str] | None) -> Iterable[str]: return await list_files(names, ec = self.ctx) @override diff --git a/src/python/jw/pkg/lib/distros/suse/Distro.py b/src/python/jw/pkg/lib/distros/suse/Distro.py index b143d839..aae12133 100644 --- a/src/python/jw/pkg/lib/distros/suse/Distro.py +++ b/src/python/jw/pkg/lib/distros/suse/Distro.py @@ -107,7 +107,7 @@ class Distro(Base): await self.rpm(['-e', *names], sudo = True) @override - async def _pkg_files(self, names: list[str] | None) -> Iterable[str]: + async def _pkg_paths(self, names: list[str] | None) -> Iterable[str]: return await list_files(names, ec = self.ctx) @override diff --git a/src/python/jw/pkg/lib/ec/secret_store/KvFile.py b/src/python/jw/pkg/lib/ec/secret_store/KvFile.py index afcca673..039d4342 100644 --- a/src/python/jw/pkg/lib/ec/secret_store/KvFile.py +++ b/src/python/jw/pkg/lib/ec/secret_store/KvFile.py @@ -102,7 +102,7 @@ class KvFile(Base): async def __config_paths(self) -> list[str]: if self.___config_paths is None: ret: set[str] = set() - for f in await (await self.__distro()).pkg_files(): + for f in await (await self.__distro()).pkg_paths(): if not f.endswith('.jw-tmpl'): continue ret.add(f.lstrip('/')[:-len('.jw-tmpl')]) diff --git a/src/python/jw/pkg/lib/pf/Pkg.py b/src/python/jw/pkg/lib/pf/Pkg.py index b45dff44..be26db2e 100644 --- a/src/python/jw/pkg/lib/pf/Pkg.py +++ b/src/python/jw/pkg/lib/pf/Pkg.py @@ -66,7 +66,7 @@ class PackageFilter(FileContextFilter): # export if self.__space is None: distro = await self.distro() names = [p.name for p in await distro.select([], filter = self)] - self.__space = set(self.__add_parent_paths(await distro.pkg_files(names))) + self.__space = set(self.__add_parent_paths(await distro.pkg_paths(names))) return path in self.__space class Pkg(PackageFilter): # export diff --git a/test/integration/jw_pkg/secrets/test.py b/test/integration/jw_pkg/secrets/test.py index 3daed322..b61ed17d 100644 --- a/test/integration/jw_pkg/secrets/test.py +++ b/test/integration/jw_pkg/secrets/test.py @@ -72,7 +72,7 @@ class FakeDistro(SuseDistro): return [Package(name) for name in names if name in self.__files] @override - async def _pkg_files(self, names: list[str] | None) -> list[str]: + async def _pkg_paths(self, names: list[str] | None) -> list[str]: if names is None: names = list(self.__files) ret: list[str] = [] diff --git a/test/unit/python/jw/pkg/lib/Distro/test.py b/test/unit/python/jw/pkg/lib/Distro/test.py index 6af6c125..620bde88 100644 --- a/test/unit/python/jw/pkg/lib/Distro/test.py +++ b/test/unit/python/jw/pkg/lib/Distro/test.py @@ -63,7 +63,7 @@ class DummyDistro(Distro): pass @override - async def _pkg_files(self, names: list[str] | None) -> Iterable[str]: + async def _pkg_paths(self, names: list[str] | None) -> Iterable[str]: return [] @override @@ -97,7 +97,7 @@ vd.verified = None assert asyncio.run(vd.verify()) == [] assert vd.verified is None -# -- pkg_files -- +# -- pkg_paths -- # -- Without a filter, the selection is passed through as the # whole system; the paths come back unfiltered @@ -113,7 +113,7 @@ class TmplDistro(DummyDistro): return [Package(n) for n in self.files] @override - async def _pkg_files(self, names: list[str] | None) -> list[str]: + async def _pkg_paths(self, names: list[str] | None) -> list[str]: if names is None: names = list(self.files) ret: list[str] = [] @@ -126,12 +126,12 @@ t.files = { 'a': ['/usr/share/a/a.conf.jw-tmpl', '/usr/bin/a'], 'b': ['/etc/b/b.conf.jw-tmpl'], } -assert sorted(asyncio.run(t.pkg_files())) == [ +assert sorted(asyncio.run(t.pkg_paths())) == [ '/etc/b/b.conf.jw-tmpl', '/usr/bin/a', '/usr/share/a/a.conf.jw-tmpl' ] # -- A single package name as a str is accepted for compatibility -assert sorted(asyncio.run(t.pkg_files('a'))) == [ +assert sorted(asyncio.run(t.pkg_paths('a'))) == [ '/usr/bin/a', '/usr/share/a/a.conf.jw-tmpl', ] @@ -261,7 +261,7 @@ class CannedRpmLocal(Local): cl = CannedRpmLocal() sd = SuseDistro(cl, id = 'suse', os_release_str = OS_RELEASE_SUSE) -assert asyncio.run(sd.pkg_files()) == [ +assert asyncio.run(sd.pkg_paths()) == [ '/usr/bin/x', '/etc/a/a.conf.jw-tmpl', ] @@ -273,7 +273,7 @@ sdf = SuseDistro( os_release_str = OS_RELEASE_SUSE, default_path_filter = Pkg(spec = 'pkg:url=~jw.dev', file_context = cl) ) -assert asyncio.run(sdf.pkg_files()) == \ +assert asyncio.run(sdf.pkg_paths()) == \ ['/etc/a/a.conf.jw-tmpl', '/etc/b/b.conf.jw-tmpl'] assert cl.cmds[-1] == ['/usr/bin/rpm', '-ql', 'a', 'b'] @@ -283,7 +283,7 @@ sde = SuseDistro( os_release_str = OS_RELEASE_SUSE, default_path_filter = Pkg(spec = 'pkg:url=~zzz-nomatch', file_context = cl) ) -assert asyncio.run(sde.pkg_files()) == [] +assert asyncio.run(sde.pkg_paths()) == [] assert '--queryformat' in cl.cmds[-1] # -- _install_local_files -- diff --git a/test/unit/python/jw/pkg/lib/ec/secret_store/KvFile/test.py b/test/unit/python/jw/pkg/lib/ec/secret_store/KvFile/test.py index 7cbaebbc..c511b641 100644 --- a/test/unit/python/jw/pkg/lib/ec/secret_store/KvFile/test.py +++ b/test/unit/python/jw/pkg/lib/ec/secret_store/KvFile/test.py @@ -212,7 +212,7 @@ async def run_tests() -> None: self.queries = 0 @override - async def _pkg_files(self, names: list[str] | None) -> list[str]: + async def _pkg_paths(self, names: list[str] | None) -> list[str]: self.queries += 1 return self.files diff --git a/test/unit/python/jw/pkg/lib/ec/secret_store/Sops/test.py b/test/unit/python/jw/pkg/lib/ec/secret_store/Sops/test.py index a6d163cd..a8f4c8fd 100644 --- a/test/unit/python/jw/pkg/lib/ec/secret_store/Sops/test.py +++ b/test/unit/python/jw/pkg/lib/ec/secret_store/Sops/test.py @@ -336,7 +336,7 @@ async def run_tests() -> None: self.files = files @override - async def _pkg_files(self, names: list[str] | None) -> list[str]: + async def _pkg_paths(self, names: list[str] | None) -> list[str]: return self.files fake = FakeDistro( diff --git a/test/unit/python/jw/pkg/lib/ec/secret_store/TarGpg/test.py b/test/unit/python/jw/pkg/lib/ec/secret_store/TarGpg/test.py index b202b15a..b89de064 100644 --- a/test/unit/python/jw/pkg/lib/ec/secret_store/TarGpg/test.py +++ b/test/unit/python/jw/pkg/lib/ec/secret_store/TarGpg/test.py @@ -321,7 +321,7 @@ async def run_tests() -> None: self.files = files @override - async def _pkg_files(self, names: list[str] | None) -> list[str]: + async def _pkg_paths(self, names: list[str] | None) -> list[str]: return self.files fake = FakeDistro( diff --git a/test/unit/python/jw/pkg/lib/ec/secret_store/Vault/test.py b/test/unit/python/jw/pkg/lib/ec/secret_store/Vault/test.py index ff3892b6..1ae661a6 100644 --- a/test/unit/python/jw/pkg/lib/ec/secret_store/Vault/test.py +++ b/test/unit/python/jw/pkg/lib/ec/secret_store/Vault/test.py @@ -351,7 +351,7 @@ async def run_tests() -> None: self.files = files @override - async def _pkg_files(self, names: list[str] | None) -> list[str]: + async def _pkg_paths(self, names: list[str] | None) -> list[str]: return self.files fake = FakeDistro( diff --git a/test/unit/python/jw/pkg/lib/pf/Pkg/test.py b/test/unit/python/jw/pkg/lib/pf/Pkg/test.py index ad10bde0..6444e260 100644 --- a/test/unit/python/jw/pkg/lib/pf/Pkg/test.py +++ b/test/unit/python/jw/pkg/lib/pf/Pkg/test.py @@ -77,7 +77,7 @@ class _FakeDistro: filter: Any = None) -> list[Package]: return [p for p, _ in self.__pkgs if filter is None or filter.match_pkg(p)] - async def pkg_files(self, names: list[str] | None = None) -> list[str]: + async def pkg_paths(self, names: list[str] | None = None) -> list[str]: ret: list[str] = [] for p, files in self.__pkgs: if names is None or p.name in names: