Skip to content

Commit

Permalink
fix recursion error on circular placeholders (important bug found and…
Browse files Browse the repository at this point in the history
… fixed :p )
  • Loading branch information
JavierCladellas committed Dec 12, 2024
1 parent d0c5adf commit eb2a3f5
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/feelpp/benchmarking/reframe/config/configReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,20 @@ def flattenDict(nested_json, parent_key='', separator='.'):
items.append((new_key, value))
return dict(items)

def replacePlaceholders(self,target,flattened_source):
def replacePlaceholders(self,target,flattened_source,processed_placeholders=None):
if processed_placeholders is None:
processed_placeholders = set()

def replaceMatch(match):
placeholder = match.group(1).strip()
if placeholder in processed_placeholders:
return match.group(0)

processed_placeholders.add(placeholder)
resolved = flattened_source.get(match.group(1).strip(),match.group(0))
if match.group(1) in flattened_source:
if isinstance(resolved,str) and "{{" in resolved and "}}" in resolved:
resolved = self.replacePlaceholders(resolved,flattened_source)
resolved = self.replacePlaceholders(resolved,flattened_source,processed_placeholders)
return resolved

replaced = self.template_pattern.sub(replaceMatch,target)
Expand Down

0 comments on commit eb2a3f5

Please sign in to comment.