Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Issue #51 #52

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions mccode_antlr/reader/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Registry:
name = None
root = None
pooch = None
version = None

def __str__(self):
from mccode_antlr.common import TextWrapper
Expand Down Expand Up @@ -256,6 +257,7 @@ class LocalRegistry(Registry):
def __init__(self, name: str, root: str):
self.name = name
self.root = Path(root)
self.version = mccode_antlr_version()

def to_file(self, output, wrapper):
contents = '(' + ', '.join([
Expand Down Expand Up @@ -399,5 +401,6 @@ def _m_reg(name):
# 'libc-registry.txt'
# )


MCSTAS_REGISTRY, MCXTRACE_REGISTRY, LIBC_REGISTRY = [_m_reg(name) for name in ('mcstas', 'mcxtrace', 'libc')]
del _m_reg
9 changes: 5 additions & 4 deletions mccode_antlr/translators/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,11 @@ def configure_file(self, filename: str, flavor: str):
contents = file.read()

# It's not great to do this here. TODO Find a better place for this
# FIXME we're (possibly) mixing up McStas/McXtrace and Lib-C versions
for reg in self.registries:
# updates mccode_antlr.config.config
registry_defaults(reg, [reg.name])
reg = [reg for reg in self.registries if reg.unique(filename)]
if len(reg) != 1:
raise RuntimeError(f"Expected exactly one registry for file {filename}")
# updates mccode_antlr.config.config
registry_defaults(reg[0], [reg[0].name])

def replacement(match) -> str:
name = match.group(1).lower()
Expand Down
Loading