Add load and dump to pylorax.api.toml

This commit is contained in:
Evan Goode 2019-08-12 13:50:38 -04:00 committed by Brian C. Lane
parent a2c67385e4
commit 584a2d2076

View File

@ -31,3 +31,12 @@ def loads(s):
def dumps(o): def dumps(o):
# strip the result, because `toml.dumps` adds a lot of newlines # strip the result, because `toml.dumps` adds a lot of newlines
return toml.dumps(o, encoder=toml.TomlEncoder(dict)).strip() return toml.dumps(o, encoder=toml.TomlEncoder(dict)).strip()
def load(file):
try:
return toml.load(file)
except toml.TomlDecodeError as e:
raise TomlError(e.msg, e.doc, e.pos)
def dump(o, file):
return toml.dump(o, file)