6
0
mirror of https://github.com/ChristianLight/tutor.git synced 2025-01-22 21:28:24 +00:00
tutor/tutor/serialize.py
Régis Behmo ddbcedab5a Fix pyyaml deprecated warning
We were getting the following warning with the latest version of pyyaml:

    YAMLLoadWarning: calling yaml.load() without Loader=... is
    deprecated, as the default Loader is unsafe. Please read
    https://msg.pyyaml.org/load for full details.
2019-03-24 14:43:17 -07:00

21 lines
476 B
Python

import yaml
def load(stream):
return yaml.load(stream, Loader=yaml.SafeLoader)
def dump(content, fileobj):
yaml.dump(content, fileobj, default_flow_style=False)
def parse_value(v):
"""
Parse a yaml-formatted string. This is fairly basic and should only be used
for parsing of elementary values.
"""
if v.isdigit():
v = int(v)
elif v == "null":
v = None
elif v in ["true", "false"]:
v = (v == "true")
return v