diff options
author | Anthon van der Neut <anthon@mnt.org> | 2016-02-27 10:15:02 +0100 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2016-02-27 10:15:02 +0100 |
commit | 2f9cdc98cc0adea615cb2180481c7780eef48f97 (patch) | |
tree | ff710ad0913ced7c241f0445e95e6eefeb24ae1b /representer.py | |
parent | acc0b296466c5364569b1df8402d2cb95ca01915 (diff) | |
download | ruamel.yaml-2f9cdc98cc0adea615cb2180481c7780eef48f97.tar.gz |
pep8 compliance, util.load_yaml_guess_indent0.11.2
Diffstat (limited to 'representer.py')
-rw-r--r-- | representer.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/representer.py b/representer.py index 22cf720..9d471a2 100644 --- a/representer.py +++ b/representer.py @@ -1,9 +1,8 @@ +# coding: utf-8 + from __future__ import absolute_import from __future__ import print_function -__all__ = ['BaseRepresenter', 'SafeRepresenter', 'Representer', - 'RepresenterError', 'RoundTripRepresenter'] - try: from .error import * # NOQA from .nodes import * # NOQA @@ -26,6 +25,10 @@ else: import copy_reg as copyreg +__all__ = ['BaseRepresenter', 'SafeRepresenter', 'Representer', + 'RepresenterError', 'RoundTripRepresenter'] + + class RepresenterError(YAMLError): pass @@ -818,6 +821,17 @@ class RoundTripRepresenter(SafeRepresenter): best_style = best_style return node + def represent_dict(self, data): + """write out tag if safed on loading""" + t = data.tag.value + if t: + while t and t[0] == '!': + t = t[1:] + tag = 'tag:yaml.org,2002:' + t + else: + tag = u'tag:yaml.org,2002:map' + return self.represent_mapping(tag, data) + RoundTripRepresenter.add_representer(type(None), RoundTripRepresenter.represent_none) |