diff options
author | Anthon van der Neut <anthon@mnt.org> | 2016-11-13 11:54:19 +0100 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2016-11-13 11:54:19 +0100 |
commit | 51dfde5d2dc2d568478387104ba0c6398ffa4b60 (patch) | |
tree | 58f064c690f27d65c5855c242ad1222b157b73b4 /emitter.py | |
parent | b96e72c24f8d3a9e2902ba70c653664aad18ec7b (diff) | |
download | ruamel.yaml-51dfde5d2dc2d568478387104ba0c6398ffa4b60.tar.gz |
fix for issue #72, dot allowed in anchor
Diffstat (limited to 'emitter.py')
-rw-r--r-- | emitter.py | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -12,7 +12,8 @@ from __future__ import print_function from ruamel.yaml.error import YAMLError from ruamel.yaml.events import * # NOQA -from ruamel.yaml.compat import utf8, text_type, PY2, nprint, dbg, DBG_EVENT +from ruamel.yaml.compat import utf8, text_type, PY2, nprint, dbg, DBG_EVENT, \ + check_anchorname_char __all__ = ['Emitter', 'EmitterError'] @@ -586,6 +587,9 @@ class Emitter(object): if (not self.flow_level and not self.simple_key_context and self.analysis.allow_block): return self.event.style + if not self.event.style and self.analysis.allow_double_quoted: + if "'" in self.event.value or '\n' in self.event.value: + return '"' if not self.event.style or self.event.style == '\'': if (self.analysis.allow_single_quoted and not (self.simple_key_context and self.analysis.multiline)): @@ -703,8 +707,7 @@ class Emitter(object): if not anchor: raise EmitterError("anchor must not be empty") for ch in anchor: - if not (u'0' <= ch <= u'9' or u'A' <= ch <= u'Z' or - u'a' <= ch <= u'z' or ch in u'-_'): + if not check_anchorname_char(ch): raise EmitterError("invalid character %r in the anchor: %r" % (utf8(ch), utf8(anchor))) return anchor |