Skip to content
Open
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
10 changes: 10 additions & 0 deletions mcstasscript/interface/instr.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import subprocess
import copy
import warnings
import re

from IPython.display import IFrame

Expand Down Expand Up @@ -731,6 +732,15 @@ def add_parameter(self, *args, **kwargs):
raise NameError(f"A parameter or variable with name '{par.name}'"
f" already exists!")

# Sanitize and quote strings
if par.type == 'string':
if not par.value[0]=='"':
par.value = '"' + par.value
if not par.value[-1]=='"':
par.value = par.value + '"'
par.value = re.sub(";","\;",par.value);
par.value = re.sub("\n","\\n;",par.value);

self.parameters.add(par)

return par
Expand Down