Add load and dump to pylorax.api.toml
This commit is contained in:
parent
a2c67385e4
commit
584a2d2076
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user