diff options
author | Anthon van der Neut <anthon@mnt.org> | 2016-04-08 09:04:26 +0200 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2016-04-08 09:04:26 +0200 |
commit | d45d5223c8f9415a164a59b48dfb4b351c9b743a (patch) | |
tree | 14e52e2290a66b9f30e5546cf76c54112b259ecd /serializer.py | |
parent | f19e4f39004730a0999a01e9b49237d160826219 (diff) | |
download | ruamel.yaml-d45d5223c8f9415a164a59b48dfb4b351c9b743a.tar.gz |
support "X.Y" as dump version as well as tuple
Diffstat (limited to 'serializer.py')
-rw-r--r-- | serializer.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/serializer.py b/serializer.py index 7c6fcaa..7ed9ff9 100644 --- a/serializer.py +++ b/serializer.py @@ -8,12 +8,12 @@ try: from .error import YAMLError from .events import * # NOQA from .nodes import * # NOQA - from .compat import nprint, DBG_NODE, dbg + from .compat import nprint, DBG_NODE, dbg, string_types except (ImportError, ValueError): # for Jython from ruamel.yaml.error import YAMLError from ruamel.yaml.events import * # NOQA from ruamel.yaml.nodes import * # NOQA - from ruamel.yaml.compat import nprint, DBG_NODE, dbg + from ruamel.yaml.compat import nprint, DBG_NODE, dbg, string_types __all__ = ['Serializer', 'SerializerError'] @@ -33,7 +33,10 @@ class Serializer(object): self.use_encoding = encoding self.use_explicit_start = explicit_start self.use_explicit_end = explicit_end - self.use_version = version + if isinstance(version, string_types): + self.use_version = tuple(map(int, version.split('.'))) + else: + self.use_version = version self.use_tags = tags self.serialized_nodes = {} self.anchors = {} |