Skip to content

Commit

Permalink
Refine the code a bit
Browse files Browse the repository at this point in the history
Signed-off-by: Xiangce Liu <[email protected]>
  • Loading branch information
xiangce committed Sep 29, 2022
1 parent ce4d339 commit 36eb9e1
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions insights/core/dr.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,29 +395,27 @@ def get_dependency_specs(component):
`at_least_one` specs in the same at least one set.
"""
def get_requires(comp):
comp_delegate = get_delegate(comp)
req = list()
for cmp in comp_delegate.requires:
for cmp in get_delegate(comp).requires:
if get_name(cmp).startswith("insights.specs."):
req.append(get_simple_name(cmp))
else:
req.extend(get_requires(cmp) + get_at_least_one(cmp))
return req

def get_at_least_one(comp):
comp_delegate = get_delegate(comp)
alo = list()
for cmps in comp_delegate.at_least_one:
for cmps in get_delegate(comp).at_least_one:
salo = list()
for cmp in cmps:
ssreq = get_requires(cmp)
ssalo = get_at_least_one(cmp)
if ssreq and ssalo:
# they are mixed and in the same `requires` level
salo.append([ss for ss in ssreq + ssalo])
elif ssreq:
salo.extend(ssreq)
else:
salo.extend(ssalo)
# no mixed, just add them one by one
salo.extend(ssreq or ssalo)
alo.append(tuple(salo))
return alo

Expand Down

0 comments on commit 36eb9e1

Please sign in to comment.