diff --git a/src/Solver/CommandLine.py b/src/Solver/CommandLine.py index c908ffce..d5c68a43 100644 --- a/src/Solver/CommandLine.py +++ b/src/Solver/CommandLine.py @@ -158,11 +158,15 @@ class CommandLineSolver(AbstractSolver): txt = add_file.text txt = txt.replace("@version", get_version()) txt = txt.replace("@date", datetime.now().isoformat(sep=" ")) + txt = self._prepare_additional_file_text(add_file.path, txt) f.write(txt) return files + def _prepare_additional_file_text(self, path, text): + return text + def export_study_description(self, study, repertory, qlog, name="0"): files = [] diff --git a/src/Solver/Mage.py b/src/Solver/Mage.py index 3ad490ae..23e11719 100644 --- a/src/Solver/Mage.py +++ b/src/Solver/Mage.py @@ -679,6 +679,23 @@ class Mage(CommandLineSolver): 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"): files = [] @@ -729,9 +746,11 @@ class Mage(CommandLineSolver): name = bhs.name if name == "": name = f"HS_{bhs.id:>3}".replace(" ", "0") + else: + name = name.replace(" ", "_") f.write( - f"${name} clapet" + f"${name} clapet\n" ) return files