summaryrefslogtreecommitdiff
path: root/morphlib/yamlparse.py
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2013-02-11 11:06:32 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2013-02-11 11:10:44 +0000
commit1f389a9bee22f00bddec865d5044a10c7d465c03 (patch)
treea47ea42ee660717611f923d2bff0a7edb09f4ac8 /morphlib/yamlparse.py
parent876a11cebfe4821c34dd451789aaf4f55f409c41 (diff)
downloadmorph-1f389a9bee22f00bddec865d5044a10c7d465c03.tar.gz
yaml: use Safe Loaders and Dumpers
This is equivalent to using yaml.safe_load(), but lets us customise how yaml is parsed.
Diffstat (limited to 'morphlib/yamlparse.py')
-rw-r--r--morphlib/yamlparse.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/morphlib/yamlparse.py b/morphlib/yamlparse.py
index 7e591b08..99599618 100644
--- a/morphlib/yamlparse.py
+++ b/morphlib/yamlparse.py
@@ -23,7 +23,7 @@ if morphlib.got_yaml: # pragma: no cover
if morphlib.got_yaml: # pragma: no cover
- class OrderedDictYAMLLoader(yaml.Loader):
+ class OrderedDictYAMLLoader(yaml.SafeLoader):
"""A YAML loader that loads mappings into ordered dictionaries.
When YAML is loaded with this Loader, it loads mappings as ordered
@@ -35,7 +35,7 @@ if morphlib.got_yaml: # pragma: no cover
"""
def __init__(self, *args, **kwargs):
- yaml.Loader.__init__(self, *args, **kwargs)
+ yaml.SafeLoader.__init__(self, *args, **kwargs)
# When YAML encounters a mapping (which YAML identifies with
# the given tag), it will use construct_yaml_map to read it as
@@ -72,7 +72,7 @@ if morphlib.got_yaml: # pragma: no cover
mapping[key] = value
return mapping
- class OrderedDictYAMLDumper(yaml.Dumper):
+ class OrderedDictYAMLDumper(yaml.SafeDumper):
"""A YAML dumper that will dump OrderedDicts as mappings.
When YAML is dumped with this Dumper, it dumps OrderedDicts as
@@ -85,7 +85,7 @@ if morphlib.got_yaml: # pragma: no cover
"""
def __init__(self, *args, **kwargs):
- yaml.Dumper.__init__(self, *args, **kwargs)
+ yaml.SafeDumper.__init__(self, *args, **kwargs)
# When YAML sees an OrderedDict, use represent_ordered_dict to
# dump it