mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-24 09:13:37 +02:00
cmds.projects.BaseCmdPkgRelations: Better variables
Make variable names a little more readable and searchable within the long pkg_relations_list() method by making their names longer and truer to what they actually mean. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
8c34dae526
commit
a0dcf59277
1 changed files with 24 additions and 26 deletions
|
|
@ -20,7 +20,7 @@ class BaseCmdPkgRelations(Cmd):
|
|||
self,
|
||||
rel_type: str,
|
||||
flavours: list[str],
|
||||
modules: list[str],
|
||||
seed_pkgs: list[str],
|
||||
subsections: list[str]|None=None,
|
||||
delimiter: str=' ',
|
||||
no_subpackages: bool=False,
|
||||
|
|
@ -36,35 +36,33 @@ class BaseCmdPkgRelations(Cmd):
|
|||
) -> list[str]:
|
||||
|
||||
if subsections is None:
|
||||
subsecs = self.app.os_cascade()
|
||||
subsecs.append('jw')
|
||||
else:
|
||||
subsecs = subsections
|
||||
subsections = self.app.os_cascade()
|
||||
subsections.append('jw')
|
||||
|
||||
expand_semver_revision_range = expand_semver_revision_range
|
||||
if syntax == self.Syntax.debian:
|
||||
expand_semver_revision_range = True
|
||||
|
||||
if skip_excluded:
|
||||
excluded = self.app.get_project_refs(modules, ['build'], 'exclude',
|
||||
excluded = self.app.get_project_refs(seed_pkgs, ['build'], 'exclude',
|
||||
scope = Scope.One, add_self=False, names_only=True)
|
||||
ignore |= set(excluded)
|
||||
|
||||
log(DEBUG, f'flavours="{", ".join(flavours)}", subsecs="{", ".join(subsecs)}", "ignore="{", ".join(ignore)}"')
|
||||
log(DEBUG, f'flavours="{", ".join(flavours)}", subsections="{", ".join(subsections)}", "ignore="{", ".join(ignore)}"')
|
||||
|
||||
version_pattern = re.compile("[0-9-.]*")
|
||||
r: list[str] = []
|
||||
for flavour in flavours:
|
||||
for s in subsecs:
|
||||
section = 'pkg.' + rel_type + '.' + s
|
||||
ret: list[str] = []
|
||||
for flavour in flavours: # build / release / run / devel
|
||||
for subsec in subsections:
|
||||
section = 'pkg.' + rel_type + '.' + subsec
|
||||
visited = set()
|
||||
sec_modules = modules.copy()
|
||||
while len(sec_modules):
|
||||
m = sec_modules.pop(0)
|
||||
if m in visited or m in ignore:
|
||||
cur_pkgs = seed_pkgs.copy()
|
||||
while len(cur_pkgs):
|
||||
cur_pkg = cur_pkgs.pop(0)
|
||||
if cur_pkg in visited or cur_pkg in ignore:
|
||||
continue
|
||||
visited.add(m)
|
||||
value = self.app.get_value(m, section, flavour)
|
||||
visited.add(cur_pkg)
|
||||
value = self.app.get_value(cur_pkg, section, flavour)
|
||||
if not value:
|
||||
continue
|
||||
deps = value.split(',')
|
||||
|
|
@ -80,11 +78,11 @@ class BaseCmdPkgRelations(Cmd):
|
|||
dep[0] = dep_name
|
||||
for i, item in enumerate(dep):
|
||||
dep[i] = item.strip()
|
||||
if s == 'jw':
|
||||
if recursive and not dep_name in visited and not dep_name in sec_modules:
|
||||
sec_modules.append(dep_name)
|
||||
if subsec == 'jw':
|
||||
if recursive and not dep_name in visited and not dep_name in cur_pkgs:
|
||||
cur_pkgs.append(dep_name)
|
||||
if len(dep) == 3:
|
||||
if dont_expand_version_macros and dep_name in sec_modules:
|
||||
if dont_expand_version_macros and dep_name in cur_pkgs:
|
||||
version = dep[2]
|
||||
else:
|
||||
version = self.app.get_value(dep_name, 'version', '')
|
||||
|
|
@ -122,7 +120,7 @@ class BaseCmdPkgRelations(Cmd):
|
|||
case _:
|
||||
raise NotImplementedError(f'Expanding SemVer range "{dep[0]} {dep[1]} {dep[3]}" is not yet implemented')
|
||||
for expanded_dep in expanded_deps:
|
||||
if hide_self and dep_name in modules:
|
||||
if hide_self and dep_name in seed_pkgs:
|
||||
continue
|
||||
match syntax:
|
||||
case self.Syntax.semver:
|
||||
|
|
@ -139,10 +137,10 @@ class BaseCmdPkgRelations(Cmd):
|
|||
dep_str = ' '.join(expanded_dep)
|
||||
if quote:
|
||||
dep_str = '"' + dep_str + '"'
|
||||
if not dep_str in r:
|
||||
if not dep_str in ret:
|
||||
log(DEBUG, f'Appending dependency >{dep_str}<')
|
||||
r.append(dep_str)
|
||||
return r
|
||||
ret.append(dep_str)
|
||||
return ret
|
||||
|
||||
def pkg_relations(self, rel_type: str, args: Namespace) -> str:
|
||||
|
||||
|
|
@ -150,7 +148,7 @@ class BaseCmdPkgRelations(Cmd):
|
|||
self.pkg_relations_list(
|
||||
rel_type=rel_type,
|
||||
flavours = args.flavours.split(','),
|
||||
modules = args.modules,
|
||||
seed_pkgs = args.modules,
|
||||
subsections = None if args.subsections is None else args.subsections.split(','),
|
||||
no_subpackages = args.no_subpackages,
|
||||
dont_strip_revision = args.dont_strip_revision,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue