From 5d4059dc96ce04ae86643cc9ae735fc856272b12 Mon Sep 17 00:00:00 2001 From: Caroline Russell Date: Tue, 12 Mar 2024 15:49:35 -0400 Subject: [PATCH] Improve jmespath expression. Signed-off-by: Caroline Russell --- atom_tools/lib/converter.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/atom_tools/lib/converter.py b/atom_tools/lib/converter.py index 0b050a7..90f191d 100644 --- a/atom_tools/lib/converter.py +++ b/atom_tools/lib/converter.py @@ -131,9 +131,9 @@ def _identify_target_line_nums(self, methods): if not file_names: return conditional = [f'fileName==`{json.dumps(i)}`' for i in file_names] - conditional = 'objectSlices[?' + ' || '.join(conditional) + ( - '].{file_name: fileName, methods: usages[?targetObj.resolvedMethod].targetObj[].{' - 'resolved_method: resolvedMethod, line_number: lineNumber}}') + conditional = '*[?' + ' || '.join(conditional) + ( + '][].{file_name: fileName, methods: usages[].targetObj[].{resolved_method: ' + 'resolvedMethod || callName || code || name, line_number: lineNumber}}') pattern = jmespath.compile(conditional) result = pattern.search(self.usages.content) result = {i['file_name']: i['methods'] for i in result if i['methods']}