diff nagslang/yamlish.py @ 380:a106d7e1415b

Colons are allowed in strings
author Stefano Rivera <stefano@rivera.za.net>
date Fri, 06 Sep 2013 23:36:08 +0200
parents 1d73867becbe
children 80c452f348dc
line wrap: on
line diff
--- a/nagslang/yamlish.py	Fri Sep 06 23:11:37 2013 +0200
+++ b/nagslang/yamlish.py	Fri Sep 06 23:36:08 2013 +0200
@@ -100,7 +100,7 @@
     def _dump_basestring(self, data):
         if data in ('true', 'false', 'null'):
             return "'%s'" % data
-        if "'" in data:
+        if "'" in data or ':' in data or data.startswith('['):
             return "'%s'" % data.replace("'", "''")
         if data == '':
             return "''"
@@ -123,7 +123,7 @@
 class Parser(object):
     _spaces_re = re.compile(r'^(\s*)(.*)')
     _list_re = re.compile(r'^(-\s+)(.*)')
-    _dict_re = re.compile(r'^((?![{[])[^-:]+):\s?(.*)')
+    _dict_re = re.compile(r"^((?![{['])[^-:]+):\s?(.*)")
     _inline_list_re = re.compile(r"^([^',]+|(?:'')+|'.+?[^'](?:'')*')"
                                  r"(?:, (.*))?$")