App.get_project_refs(): Fix multi-section results #117

Merged
Jan Lindemann merged 1 commit from jan/fix/20260922-app-get-project-refs-fix-multi-section-results into master 2026-09-22 05:07:54 +02:00 AGit

View file

@ -203,7 +203,7 @@ class App(Base):
buf: list[str], buf: list[str],
visited: set[str], visited: set[str],
spec: str, spec: str,
section: str, sections: list[str],
key: str, key: str,
add_self: bool, add_self: bool,
scope: Scope, scope: Scope,
@ -230,6 +230,8 @@ class App(Base):
f'Unmet dependency on {mod}: the -{needed_subpackage} package ' f'Unmet dependency on {mod}: the -{needed_subpackage} package '
f'of project {name} is not installed' f'of project {name} is not installed'
) )
vals_list: list[str] = []
for section in sections:
vals = self.get_value(name, section, key) vals = self.get_value(name, section, key)
log( log(
DEBUG, DEBUG,
@ -238,21 +240,23 @@ class App(Base):
f'scope={scope.name}, visited={visited}' f'scope={scope.name}, visited={visited}'
), ),
) )
vals_list = vals.split(',') if vals else [] if not vals:
continue
for val in vals.split(','):
val = val.strip()
if (len(val)) and (val not in vals_list):
vals_list.append(val)
match scope: match scope:
case Scope.Self: case Scope.Self:
buf += vals_list buf += vals_list
case Scope.One | Scope.Subtree: case Scope.One | Scope.Subtree:
subscope = scope.Self if scope == Scope.One else scope subscope = scope.Self if scope == Scope.One else scope
for val in vals_list: for val in vals_list:
val = val.strip()
if not (len(val)):
continue
self.__get_project_refs( self.__get_project_refs(
buf, buf,
visited, visited,
val, val,
section, sections,
key, key,
add_self = True, add_self = True,
scope = subscope, scope = subscope,
@ -559,13 +563,12 @@ class App(Base):
if isinstance(keys, str): if isinstance(keys, str):
keys = [keys] keys = [keys]
ret: list[str] = [] ret: list[str] = []
for section in sections:
for key in keys: for key in keys:
visited: set[str] = set() visited: set[str] = set()
for name in projects: for name in projects:
rr: list[str] = [] rr: list[str] = []
self.__get_project_refs( self.__get_project_refs(
rr, visited, name, section, key, add_self, scope, names_only rr, visited, name, sections, key, add_self, scope, names_only
) )
# TODO: this looks like a performance hogger # TODO: this looks like a performance hogger
for m in rr: for m in rr: