Looks like a good improvement, I like that this also sorts out the
confusion over whether to use dump/load or safe_dump/safe_load at the
same time.
I would have been tempted to name the wrapper module juju.lib.yaml to
avoid touching most lines, but this way means you did look at all the
callers at least.
There are several callsites that still use the yaml module functions and
pass in a Loader or Dumper, apart from the one noted below, shouldn't
they all be changed to using juju.lib for consistency?
https://codereview.appspot.com/6493100/diff/1/juju/charm/config.py#newcode80
juju/charm/config.py:80: raw_data = yaml.load(data,
Loader=yaml.CSafeLoader)
Why not use dump from juju.lib here rather than specifying the loader?
Will need the yaml import for the Mark below anyway, but seems best to
consistently use the same loader.
Looks like a good improvement, I like that this also sorts out the
confusion over whether to use dump/load or safe_dump/safe_load at the
same time.
I would have been tempted to name the wrapper module juju.lib.yaml to
avoid touching most lines, but this way means you did look at all the
callers at least.
There are several callsites that still use the yaml module functions and
pass in a Loader or Dumper, apart from the one noted below, shouldn't
they all be changed to using juju.lib for consistency?
https:/ /codereview. appspot. com/6493100/ diff/1/ juju/charm/ config. py config. py (right):
File juju/charm/
https:/ /codereview. appspot. com/6493100/ diff/1/ juju/charm/ config. py#newcode80 config. py:80: raw_data = yaml.load(data, yaml.CSafeLoade r)
juju/charm/
Loader=
Why not use dump from juju.lib here rather than specifying the loader?
Will need the yaml import for the Mark below anyway, but seems best to
consistently use the same loader.
https:/ /codereview. appspot. com/6493100/ diff/1/ juju/control/ constraints_ get.py constraints_ get.py (right):
File juju/control/
https:/ /codereview. appspot. com/6493100/ diff/1/ juju/control/ constraints_ get.py# newcode73 constraints_ get.py: 73: yaml.dump(result, sys.stdout, yaml.CSafeDumpe r)
juju/control/
Dumper=
I'd dump using the juju.lib function and write to stout separately
afterwards here.
https:/ /codereview. appspot. com/6493100/ diff/1/ juju/control/ status. py status. py (right):
File juju/control/
https:/ /codereview. appspot. com/6493100/ diff/1/ juju/control/ status. py#newcode581 status. py:581: data, filelike, default_ flow_style= False, yaml.CSafeDumpe r)
juju/control/
Dumper=
This looks like the only place that really wants extra args to dump,
leaving this as a special case seems fine.
https:/ /codereview. appspot. com/6493100/ diff/1/ juju/lib/ serializer. py serializer. py (right):
File juju/lib/
https:/ /codereview. appspot. com/6493100/ diff/1/ juju/lib/ serializer. py#newcode5 serializer. py:5: def dump(*args, **kw):
juju/lib/
I'd be tempted to make this just take a dict rather than passing through
args and kwargs.
https:/ /codereview. appspot. com/6493100/ diff/1/ juju/lib/ serializer. py#newcode9 serializer. py:9: def load(*args, **kw):
juju/lib/
Likewise, would make this just take a string.
https:/ /codereview. appspot. com/6493100/