Skip to content

Commit

Permalink
fix _ in macro names for included templates
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Dec 16, 2024
1 parent 59c4d40 commit 0b4af2f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/vdct2template/expansion.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self, filename: Path, folder: Path) -> None:
self.vdb_path = filename.resolve()
self.folder = folder
self.template_path = filename.with_suffix(".template")
self.includes = []
self.includes: list[Macros] = []
self.text = filename.read_text()

Expansion.expansions.append(self)
Expand Down Expand Up @@ -92,6 +92,10 @@ def process_includes(self):
if include.vdb_path.name not in Expansion.processed:
yield include.process()
Expansion.processed.append(include.vdb_path.name)
# else:
# cur_macros = Expansion.processed[include.vdb_path.name]
# if cur_macros != include.macros:
# print(f"WARNING: inconsistent macros for {include.vdb_path.name}")

@classmethod
def validate_includes(cls) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion src/vdct2template/macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def process(self):
"""
text = self.vdb_path.read_text()
for name in self.macros.keys():
text = text.replace(f"${name}", f"$_{name}")
text = text.replace(f"$({name})", f"$(_{name})")

# remove redundant VDB things
text = DROP.sub("", text)
Expand Down

0 comments on commit 0b4af2f

Please sign in to comment.