diff options
author | Anthon van der Neut <anthon@mnt.org> | 2016-08-18 12:57:24 +0200 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2016-08-18 12:57:24 +0200 |
commit | c9331e372f1aeef155db22fe88efeec775507c67 (patch) | |
tree | eb9ba9df1e9eef7fa22dd9e737eae35e242b9ed3 /composer.py | |
parent | f21343115c0b7f2849766f741bbe64e6c170a556 (diff) | |
download | ruamel.yaml-c9331e372f1aeef155db22fe88efeec775507c67.tar.gz |
fix merge, iteration, reused anchors0.12.3
Diffstat (limited to 'composer.py')
-rw-r--r-- | composer.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/composer.py b/composer.py index 320fb22..791bf50 100644 --- a/composer.py +++ b/composer.py @@ -3,8 +3,9 @@ from __future__ import absolute_import from __future__ import print_function +import warnings -from ruamel.yaml.error import MarkedYAMLError +from ruamel.yaml.error import MarkedYAMLError, ReusedAnchorWarning from ruamel.yaml.compat import utf8 from ruamel.yaml.events import ( @@ -87,10 +88,14 @@ class Composer(object): anchor = event.anchor if anchor is not None: # have an anchor if anchor in self.anchors: - raise ComposerError( - "found duplicate anchor %r; first occurence" - % utf8(anchor), self.anchors[anchor].start_mark, - "second occurence", event.start_mark) + # raise ComposerError( + # "found duplicate anchor %r; first occurence" + # % utf8(anchor), self.anchors[anchor].start_mark, + # "second occurence", event.start_mark) + ws = "\nfound duplicate anchor {!r}\nfirst occurence {}\nsecond occurence "\ + "{}".format( + (anchor), self.anchors[anchor].start_mark, event.start_mark) + warnings.warn(ws, ReusedAnchorWarning) self.descend_resolver(parent, index) if self.check_event(ScalarEvent): node = self.compose_scalar_node(anchor) |