]> mj.ucw.cz Git - moe.git/blobdiff - t/moe/config_parser.py
Minor updates (docs, status.py)
[moe.git] / t / moe / config_parser.py
index b3131cccf78e7e8ed616b0d03ae2faa4aa0dbe4f..2da6facfa2daa9062c78b2cfc9d9fe52cdddaf16 100644 (file)
@@ -37,7 +37,7 @@ The configuration syntax is the following::
 
 .. 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
 """
 
@@ -47,6 +47,16 @@ import traceback
 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):