Diff comments:
> diff --git a/cloudinit/util.py b/cloudinit/util.py
> index a8a232b..446b7b9 100644
> --- a/cloudinit/util.py
> +++ b/cloudinit/util.py
> @@ -1596,14 +1596,22 @@ def json_dumps(data):
> separators=(',', ': '), default=json_serialize_default)
>
>
> -def yaml_dumps(obj, explicit_start=True, explicit_end=True):
> +def yaml_dumps(obj, explicit_start=True, explicit_end=True, noalias=False):
> """Return data in nicely formatted yaml."""
> - return yaml.safe_dump(obj,
> - line_break="\n",
> - indent=4,
> - explicit_start=explicit_start,
> - explicit_end=explicit_end,
> - default_flow_style=False)
> +
> + class CIDumper(yaml.dumper.SafeDumper):
> + pass
> + dumper = CIDumper
That's an artifact of the yaml dumps method which doesn't take instances of
dumpers, AFAICT.
What I wanted to do here is not change the default dumper that would be used by
calls to yaml.dump()
Which is what happens if you change the value on yaml.dumper.SafeDumper
directly.
so, I've created a subclass object so I can set the attribute on that object
rather than the
the yaml.dumper.SafeDumper.
> + if noalias:
> + dumper.ignore_aliases = lambda self, data: True
> +
> + return yaml.dump(obj,
> + line_break="\n",
> + indent=4,
> + explicit_start=explicit_start,
> + explicit_end=explicit_end,
> + default_flow_style=False,
> + Dumper=dumper)
>
>
> def ensure_dir(path, mode=None):
--
https://code.launchpad.net/~raharper/cloud-init/+git/cloud-init/+merge/362877
Your team cloud-init commiters is requested to review the proposed merge of
~raharper/cloud-init:fix/netplan-nameserver-alias into cloud-init:master.
_______________________________________________
Mailing list: https://launchpad.net/~cloud-init-dev
Post to : [email protected]
Unsubscribe : https://launchpad.net/~cloud-init-dev
More help : https://help.launchpad.net/ListHelp