diff options
author | Anthon van der Neut <anthon@mnt.org> | 2018-08-16 09:49:03 +0200 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2018-08-16 09:49:03 +0200 |
commit | 81fdb659f35a533c29fc163ac679d0c6068385d9 (patch) | |
tree | 20a5e6c809cd8931483e6065da34a5c8db0fd8ac /constructor.py | |
parent | 97ffa8425050d219b42a35e198302f8451f6e303 (diff) | |
download | ruamel.yaml-81fdb659f35a533c29fc163ac679d0c6068385d9.tar.gz |
allow simple mappings as mapping keys
Diffstat (limited to 'constructor.py')
-rw-r--r-- | constructor.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/constructor.py b/constructor.py index 8e1da70..9408c3c 100644 --- a/constructor.py +++ b/constructor.py @@ -17,10 +17,10 @@ from ruamel.yaml.nodes import * # NOQA from ruamel.yaml.nodes import (SequenceNode, MappingNode, ScalarNode) from ruamel.yaml.compat import (utf8, builtins_module, to_str, PY2, PY3, # NOQA ordereddict, text_type, nprint, version_tnf, Hashable, - MutableSequence) + MutableSequence, MutableMapping) from ruamel.yaml.comments import * # NOQA from ruamel.yaml.comments import (CommentedMap, CommentedOrderedMap, CommentedSet, - CommentedKeySeq, CommentedSeq, TaggedScalar) + CommentedKeySeq, CommentedSeq, TaggedScalar, CommentedKeyMap) from ruamel.yaml.scalarstring import * # NOQA from ruamel.yaml.scalarstring import (PreservedScalarString, SingleQuotedScalarString, DoubleQuotedScalarString, ScalarString) @@ -1330,7 +1330,13 @@ class RoundTripConstructor(SafeConstructor): elif key_node.flow_style is False: key_a.fa.set_block_style() key = key_a - # key = tuple(key) + elif isinstance(key, MutableMapping): + key_a = CommentedKeyMap(key) + if key_node.flow_style is True: + key_a.fa.set_flow_style() + elif key_node.flow_style is False: + key_a.fa.set_block_style() + key = key_a if PY2: try: hash(key) |