Mercurial > nagslang
changeset 383:e0d27a11f49a
Bleh.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Fri, 06 Sep 2013 23:39:22 +0200 |
parents | 70f6917cad07 (current diff) a106d7e1415b (diff) |
children | 9efc1ab833c8 |
files | |
diffstat | 2 files changed, 10 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/nagslang/tests/test_yamlish.py Fri Sep 06 23:37:55 2013 +0200 +++ b/nagslang/tests/test_yamlish.py Fri Sep 06 23:39:22 2013 +0200 @@ -108,6 +108,14 @@ 0.7: -0.7, }) + def test_dictish_string(self): + self.roundtrip({ + 'strings': [ + 'Foo: bar', + 'Baz: qux', + ], + }) + def test_tuples(self): if self.from_pyyaml: raise SkipTest("Can't parse PyYAML tuples")
--- a/nagslang/yamlish.py Fri Sep 06 23:37:55 2013 +0200 +++ b/nagslang/yamlish.py Fri Sep 06 23:39:22 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"(?:, (.*))?$")