do not let yamlutils emit alias references

We want the canonical data files to have repeated information to make
it easy for human readers to understand the content, so do not emit
aliases to blocks of repeated data.

Change-Id: Ib6bf3f3683fae2edb94910bea86971e591b5b87c
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann
2017-08-01 16:51:03 -04:00
parent 032675e6b4
commit 63291dbd84

View File

@ -38,14 +38,16 @@ class PrettySafeDumper(yaml.dumper.SafeDumper):
values = []
node = yaml.nodes.MappingNode(
'tag:yaml.org,2002:map', values, flow_style=None)
if self.alias_key is not None:
self.represented_objects[self.alias_key] = node
for key, value in data.items():
key_item = self.represent_data(key)
value_item = self.represent_data(value)
values.append((key_item, value_item))
return node
def ignore_aliases(self, data):
# Never output alias references; always repeat the data.
return True
def represent_bool(self, data):
if data:
value = 'yes'