Closed bp4151 closed 1 year ago
I think you want something like this:
rule > [p for p in package.Package.impactPaths if [x for x in p if 'some_dependency' in x]]
result:
(('npm://some_package:1.0.0', 'npm://some_dependency:1.2.0'),)
If you wanted the result of the expression, I think you'd have to do it twice:
rule > [[x for x in p if 'some_dependency' in x][0] for p in package.Package.impactPaths if [x for x in p if 'some_dependency' in x]]
result:
('npm://some_dependency:1.2.0',)
FWIW, I was using the debug REPL to figure this out.
Thank you for the rapid response @zeroSteiner. I got around it temporarily by simply flattening the impact paths in my source data and changing the rules to go after the flattenedImpactPath instead. Definitely saving your approach for future updates.
Question for @zeroSteiner regarding nested lists. I have the following block of code:
and I am having a time of it trying to create the rule that checks the impact paths at package.Package.impactPaths. I have a scratch file with the following code
Both of those print True, but if I create a rule with the same code
I get the following errors:
Any suggestions? Any help is greatly appreciated