.. todo:: should whitespace (incl. '\n') be allowed (almost) everywhere?
can comment be anywhere whitespace can?
-.. note:: ';' or '\n' is currently required even after CONDITION and SUBTREE block
+.. note:: ';' or '\\n' is currently required even after CONDITION and SUBTREE block
.. note:: Formula can contain additional/unnecessary parentheses
"""
import moe.config as cf
+def config_escape(s):
+ """
+ Escape any ``{``, ``}``, ``"`` and ``\\`` in the given string, making it safe for parsing.
+ """
+ s = s.replace('\\', '\\\\')
+ s = s.replace('{', '\\{')
+ s = s.replace('}', '\\}')
+ s = s.replace('"', '\\"')
+ return s
+
class ConfigSyntaxError(cf.ConfigError):
def __init__(self, msg, source='<unknown>', line=None, column=None):