cmds.secrets.lib.DistroContext: packages -> pkg_names

Cosmetics: The "packages" parameter to some DistroContext's methods
has a confusing name in same contexts, notably when mixed with a list
of Package instances, so rename it to "pkg_names".

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-04-21 11:22:51 +02:00
commit 655b17bfec
Signed by: jan
GPG key ID: 3750640C9E25DD61

View file

@ -25,37 +25,37 @@ class DistroContext(FilesContext):
super().__init__(distro.ctx) super().__init__(distro.ctx)
self.__distro = distro self.__distro = distro
async def match_files(self, packages: Iterable[str], pattern: str) -> list[str]: async def match_files(self, pkg_names: Iterable[str], pattern: str) -> list[str]:
ret: list[str] = [] ret: list[str] = []
for package_name in packages: for pkg_name in pkg_names:
for path in await self.__distro.pkg_files(package_name): for path in await self.__distro.pkg_files(pkg_name):
if re.match(pattern, path): if re.match(pattern, path):
ret.append(path) ret.append(path)
return ret return ret
async def list_template_files(self, packages: Iterable[str]) -> list[str]: async def list_template_files(self, pkg_names: Iterable[str]) -> list[str]:
return await self.match_files(packages, pattern=r'.*\.jw-tmpl$') return await self.match_files(pkg_names, pattern=r'.*\.jw-tmpl$')
async def list_secret_paths(self, packages: Iterable[str], ignore_missing: bool=False) -> list[str]: async def list_secret_paths(self, pkg_names: Iterable[str], ignore_missing: bool=False) -> list[str]:
ret = [] ret = []
for tmpl in await self.list_template_files(packages): for tmpl in await self.list_template_files(pkg_names):
path = str(Path(tmpl).with_suffix(".jw-secret")) path = str(Path(tmpl).with_suffix(".jw-secret"))
if ignore_missing and not await self.ctx.file_exists(path): if ignore_missing and not await self.ctx.file_exists(path):
continue continue
ret.append(path) ret.append(path)
return ret return ret
async def list_compilation_targets(self, packages: Iterable[str], ignore_missing: bool=False) -> list[str]: async def list_compilation_targets(self, pkg_names: Iterable[str], ignore_missing: bool=False) -> list[str]:
ret = [] ret = []
for tmpl in await self.list_template_files(packages): for tmpl in await self.list_template_files(pkg_names):
path = tmpl.removesuffix('.jw-tmpl') path = tmpl.removesuffix('.jw-tmpl')
if ignore_missing and not await self.ctx.file_exists(path): if ignore_missing and not await self.ctx.file_exists(path):
continue continue
ret.append(path) ret.append(path)
return ret return ret
async def remove_compilation_targets(self, packages: Iterable[str]) -> list[str]: async def remove_compilation_targets(self, pkg_names: Iterable[str]) -> list[str]:
for path in await self.list_compilation_targets(packages): for path in await self.list_compilation_targets(pkg_names):
try: try:
self.ctx.stat(path) self.ctx.stat(path)
log(NOTICE, f'Removing {path}') log(NOTICE, f'Removing {path}')
@ -64,9 +64,9 @@ class DistroContext(FilesContext):
log(DEBUG, f'Compilation target {path} doesn\'t exist (ignored)') log(DEBUG, f'Compilation target {path} doesn\'t exist (ignored)')
continue continue
async def compile_template_files(self, packages: Iterable[str], default_attrs: Attrs) -> list[str]: async def compile_template_files(self, pkg_names: Iterable[str], default_attrs: Attrs) -> list[str]:
missing = 0 missing = 0
for target in await self.list_compilation_targets(packages): for target in await self.list_compilation_targets(pkg_names):
if not await self.compile_template_file(target, default_attrs): if not await self.compile_template_file(target, default_attrs):
missing += 1 missing += 1
if missing > 0: if missing > 0: