summaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2016-11-20 19:29:11 +0100
committerAnthon van der Neut <anthon@mnt.org>2016-11-20 19:29:11 +0100
commit39d3f0eb58e55c84592b07771a5f48503525d6cc (patch)
tree73e90db7810c9e563729b5d1a555ccf83be1f772 /main.py
parent3954b8bf203540dc69fa40c649c0db049d4ad938 (diff)
downloadruamel.yaml-39d3f0eb58e55c84592b07771a5f48503525d6cc.tar.gz
fix #6: non-safe load() now issues warning0.13.0
added method to add before/after comments on specific keys
Diffstat (limited to 'main.py')
-rw-r--r--main.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/main.py b/main.py
index fabe8a1..0792d71 100644
--- a/main.py
+++ b/main.py
@@ -70,12 +70,17 @@ def compose_all(stream, Loader=Loader):
loader.dispose()
-def load(stream, Loader=Loader, version=None, preserve_quotes=None):
+def load(stream, Loader=None, version=None, preserve_quotes=None):
# type: (StreamType, Any, VersionType, Any) -> Any
"""
Parse the first YAML document in a stream
and produce the corresponding Python object.
"""
+ if Loader is None:
+ from ruamel.yaml.loader import Loader as UnsafeLoader
+ import warnings
+ warnings.warn(UnsafeLoaderWarning.text, UnsafeLoaderWarning, stacklevel=2)
+ Loader = UnsafeLoader
loader = Loader(stream, version, preserve_quotes=preserve_quotes)
try:
return loader.get_single_data()
@@ -83,11 +88,16 @@ def load(stream, Loader=Loader, version=None, preserve_quotes=None):
loader.dispose()
-def load_all(stream, Loader=Loader, version=None, preserve_quotes=None):
+def load_all(stream, Loader=None, version=None, preserve_quotes=None):
"""
Parse all YAML documents in a stream
and produce corresponding Python objects.
"""
+ if Loader is None:
+ from ruamel.yaml.loader import Loader as UnsafeLoader
+ import warnings
+ warnings.warn(UnsafeLoaderWarning.text, UnsafeLoaderWarning, stacklevel=2)
+ Loader = UnsafeLoader
loader = Loader(stream, version, preserve_quotes=preserve_quotes)
try:
while loader.check_data():