summaryrefslogtreecommitdiff
path: root/emitter.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2017-08-13 13:16:06 +0200
committerAnthon van der Neut <anthon@mnt.org>2017-08-13 13:16:06 +0200
commita29127076c536d0009b2556a4a2081e8cad83032 (patch)
tree7c97a6ca1f75bfd76c66ed4dd0475672a93d3198 /emitter.py
parent56a22f859d4fa1a0be6a6335fb7e9232ea9e9239 (diff)
downloadruamel.yaml-a29127076c536d0009b2556a4a2081e8cad83032.tar.gz
fix issue #62: not allowing : or ? in flow style plain scalar0.15.27
also fix list withing list comment dropping, as it happened to occur in the example
Diffstat (limited to 'emitter.py')
-rw-r--r--emitter.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/emitter.py b/emitter.py
index 52a5c82..09d3419 100644
--- a/emitter.py
+++ b/emitter.py
@@ -152,6 +152,16 @@ class Emitter(object):
raise YAMLStreamError('stream argument needs to have a write() method')
self._stream = val
+ @property
+ def serializer(self):
+ # type: () -> Any
+ try:
+ if hasattr(self.dumper, 'typ'):
+ return self.dumper.serializer # type: ignore
+ return self.dumper._serializer # type: ignore
+ except AttributeError:
+ return self # cyaml
+
def dispose(self):
# type: () -> None
# Reset the state attributes (to clear self-references)
@@ -850,8 +860,9 @@ class Emitter(object):
if ch in u'#,[]{}&*!|>\'\"%@`':
flow_indicators = True
block_indicators = True
- if ch in u'?:':
- flow_indicators = True
+ if ch in u'?:': # ToDo
+ if self.serializer.use_version == (1, 1):
+ flow_indicators = True
if followed_by_whitespace:
block_indicators = True
if ch == u'-' and followed_by_whitespace:
@@ -859,7 +870,9 @@ class Emitter(object):
block_indicators = True
else:
# Some indicators cannot appear within a scalar as well.
- if ch in u',?[]{}':
+ if ch in u',[]{}': # http://yaml.org/spec/1.2/spec.html#id2788859
+ flow_indicators = True
+ if ch == u'?' and self.serializer.use_version == (1, 1):
flow_indicators = True
if ch == u':':
if followed_by_whitespace: