summaryrefslogtreecommitdiff
path: root/emitter.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2018-08-16 09:49:03 +0200
committerAnthon van der Neut <anthon@mnt.org>2018-08-16 09:49:03 +0200
commit81fdb659f35a533c29fc163ac679d0c6068385d9 (patch)
tree20a5e6c809cd8931483e6065da34a5c8db0fd8ac /emitter.py
parent97ffa8425050d219b42a35e198302f8451f6e303 (diff)
downloadruamel.yaml-81fdb659f35a533c29fc163ac679d0c6068385d9.tar.gz
allow simple mappings as mapping keys
Diffstat (limited to 'emitter.py')
-rw-r--r--emitter.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/emitter.py b/emitter.py
index 7fb572a..9f4da23 100644
--- a/emitter.py
+++ b/emitter.py
@@ -621,7 +621,9 @@ class Emitter(object):
self.write_pre_comment(self.event)
self.write_indent()
if self.check_simple_key():
- if not isinstance(self.event, SequenceStartEvent): # sequence keys
+ if not isinstance(
+ self.event, (SequenceStartEvent, MappingStartEvent)
+ ): # sequence keys
if self.event.style == '?':
self.write_indicator(u'?', True, indention=True)
self.states.append(self.expect_block_mapping_simple_value)
@@ -703,6 +705,7 @@ class Emitter(object):
return length < self.MAX_SIMPLE_KEY_LENGTH and (
isinstance(self.event, AliasEvent)
or (isinstance(self.event, SequenceStartEvent) and self.event.flow_style is True)
+ or (isinstance(self.event, MappingStartEvent) and self.event.flow_style is True)
or (
isinstance(self.event, ScalarEvent)
and not self.analysis.empty