mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-24 09:13:37 +02:00
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:
parent
1646aaeb59
commit
655b17bfec
1 changed files with 13 additions and 13 deletions
|
|
@ -25,37 +25,37 @@ class DistroContext(FilesContext):
|
|||
super().__init__(distro.ctx)
|
||||
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] = []
|
||||
for package_name in packages:
|
||||
for path in await self.__distro.pkg_files(package_name):
|
||||
for pkg_name in pkg_names:
|
||||
for path in await self.__distro.pkg_files(pkg_name):
|
||||
if re.match(pattern, path):
|
||||
ret.append(path)
|
||||
return ret
|
||||
|
||||
async def list_template_files(self, packages: Iterable[str]) -> list[str]:
|
||||
return await self.match_files(packages, pattern=r'.*\.jw-tmpl$')
|
||||
async def list_template_files(self, pkg_names: Iterable[str]) -> list[str]:
|
||||
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 = []
|
||||
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"))
|
||||
if ignore_missing and not await self.ctx.file_exists(path):
|
||||
continue
|
||||
ret.append(path)
|
||||
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 = []
|
||||
for tmpl in await self.list_template_files(packages):
|
||||
for tmpl in await self.list_template_files(pkg_names):
|
||||
path = tmpl.removesuffix('.jw-tmpl')
|
||||
if ignore_missing and not await self.ctx.file_exists(path):
|
||||
continue
|
||||
ret.append(path)
|
||||
return ret
|
||||
|
||||
async def remove_compilation_targets(self, packages: Iterable[str]) -> list[str]:
|
||||
for path in await self.list_compilation_targets(packages):
|
||||
async def remove_compilation_targets(self, pkg_names: Iterable[str]) -> list[str]:
|
||||
for path in await self.list_compilation_targets(pkg_names):
|
||||
try:
|
||||
self.ctx.stat(path)
|
||||
log(NOTICE, f'Removing {path}')
|
||||
|
|
@ -64,9 +64,9 @@ class DistroContext(FilesContext):
|
|||
log(DEBUG, f'Compilation target {path} doesn\'t exist (ignored)')
|
||||
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
|
||||
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):
|
||||
missing += 1
|
||||
if missing > 0:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue