Mage: fix missing $ markers in VAR rules and separate exported check valve entries

This commit is contained in:
Dylan Jeannin committed 2026-09-18 03:09:30 +02:00
1 parent 89c6e8bb29
commit ddb682dff6
2 files changed
+24 -1

No files matched your search

+4
View File
@@ -159,11 +159,15 @@ class CommandLineSolver(AbstractSolver):
txt = add_file.text txt = add_file.text
txt = txt.replace("@version", get_version()) txt = txt.replace("@version", get_version())
txt = txt.replace("@date", datetime.now().isoformat(sep=" ")) txt = txt.replace("@date", datetime.now().isoformat(sep=" "))
txt = self._prepare_additional_file_text(add_file.path, txt)
f.write(txt) f.write(txt)
return files return files
def _prepare_additional_file_text(self, path, text):
return text
def export_study_description(self, study, repertory, qlog, name="0"): def export_study_description(self, study, repertory, qlog, name="0"):
files = [] files = []
+20 -1
View File
@@ -694,6 +694,23 @@ class Mage(CommandLineSolver):
return res return res
def _prepare_additional_file_text(self, path, text):
if os.path.splitext(path)[1].lower() != ".var":
return text
lines = []
for line in text.splitlines(keepends=True):
stripped = line.lstrip()
fields = stripped.split()
if stripped.startswith("$"):
# MAGE only recognizes rule markers in the first column.
line = stripped
elif (not stripped.startswith("*") and len(fields) >= 2
and fields[1] == "W2Z"):
line = "$ " + stripped
lines.append(line)
return "".join(lines)
def _export_VAR(self, study, repertory, qlog, name="0"): def _export_VAR(self, study, repertory, qlog, name="0"):
files = [] files = []
@@ -744,9 +761,11 @@ class Mage(CommandLineSolver):
name = bhs.name name = bhs.name
if name == "": if name == "":
name = f"HS_{bhs.id:>3}".replace(" ", "0") name = f"HS_{bhs.id:>3}".replace(" ", "0")
else:
name = name.replace(" ", "_")
f.write( f.write(
f"${name} clapet" f"${name} clapet\n"
) )
return files return files