diff options
author | Anthon van der Neut <anthon@mnt.org> | 2018-08-30 06:47:53 +0200 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2018-08-30 06:47:53 +0200 |
commit | 34d02af74473c82e25c9e152a24ffeea862454f0 (patch) | |
tree | b27b185d183890b5ad278ee0ebdc3f6a162d7a3d /representer.py | |
parent | 22ebda34b13607bd4516c36820552d5daa43df70 (diff) | |
download | ruamel.yaml-34d02af74473c82e25c9e152a24ffeea862454f0.tar.gz |
allow round trip of tagged sequences
Diffstat (limited to 'representer.py')
-rw-r--r-- | representer.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/representer.py b/representer.py index 3088139..6bd5651 100644 --- a/representer.py +++ b/representer.py @@ -1103,6 +1103,21 @@ class RoundTripRepresenter(SafeRepresenter): tag = u'tag:yaml.org,2002:map' return self.represent_mapping(tag, data) + def represent_list(self, data): + # type: (Any) -> Any + try: + t = data.tag.value + except AttributeError: + t = None + if t: + if t.startswith('!!'): + tag = 'tag:yaml.org,2002:' + t[2:] + else: + tag = t + else: + tag = u'tag:yaml.org,2002:seq' + return self.represent_sequence(tag, data) + def represent_datetime(self, data): # type: (Any) -> Any inter = 'T' if data._yaml['t'] else ' ' |