Skip to content

Commit

Permalink
Merge pull request #623 from linsword13/minor-opt-anti-match
Browse files Browse the repository at this point in the history
Minor optimization for success_criteria processing
  • Loading branch information
douglasjacobsen authored Aug 23, 2024
2 parents 4195c08 + be66e21 commit 5cbd8b7
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions lib/ramble/ramble/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -1605,17 +1605,23 @@ def format_context(context_match, context_format):
logger.debug(f"Skipping analysis of non-existent file: {file}")
continue

per_file_crit_objs = [
criteria_list.find_criteria(c) for c in file_conf["success_criteria"]
]

with open(file) as f:
for line in f.readlines():
logger.debug(f"Line: {line}")

for criteria in file_conf["success_criteria"]:
logger.debug("Looking for criteria %s" % criteria)
criteria_obj = criteria_list.find_criteria(criteria)
if criteria_obj.passed(line, self):
criteria_obj.mark_found()
if criteria_obj.anti_matched(line):
criteria_obj.mark_anti_found()
new_per_file_crit_objs = []
for crit_obj in per_file_crit_objs:
logger.debug(f"Looking for criteria {crit_obj.name}")
if crit_obj.passed(line, self):
crit_obj.mark_found()
elif crit_obj.anti_matched(line):
crit_obj.mark_anti_found()
else:
new_per_file_crit_objs.append(crit_obj)
per_file_crit_objs = new_per_file_crit_objs

for context in file_conf["contexts"]:
context_conf = contexts[context]
Expand Down

0 comments on commit 5cbd8b7

Please sign in to comment.