2017-10-22 16:50:20 +00:00
|
|
|
HIGHEST_PROTOCOL = 0
|
|
|
|
|
2021-05-27 05:50:04 +00:00
|
|
|
|
2017-10-22 16:50:20 +00:00
|
|
|
def dump(obj, f, proto=0):
|
2014-05-01 07:47:56 +00:00
|
|
|
f.write(repr(obj))
|
|
|
|
|
2021-05-27 05:50:04 +00:00
|
|
|
|
2017-10-22 16:50:20 +00:00
|
|
|
def dumps(obj, proto=0):
|
2018-01-21 12:49:24 +00:00
|
|
|
return repr(obj).encode()
|
2014-05-01 07:47:56 +00:00
|
|
|
|
2021-05-27 05:50:04 +00:00
|
|
|
|
2014-05-01 07:47:56 +00:00
|
|
|
def load(f):
|
|
|
|
s = f.read()
|
|
|
|
return loads(s)
|
|
|
|
|
2021-05-27 05:50:04 +00:00
|
|
|
|
2014-05-01 07:47:56 +00:00
|
|
|
def loads(s):
|
|
|
|
d = {}
|
2018-01-21 12:49:24 +00:00
|
|
|
s = s.decode()
|
2017-11-11 22:34:04 +00:00
|
|
|
if "(" in s:
|
|
|
|
qualname = s.split("(", 1)[0]
|
|
|
|
if "." in qualname:
|
|
|
|
pkg = qualname.rsplit(".", 1)[0]
|
|
|
|
mod = __import__(pkg)
|
|
|
|
d[pkg] = mod
|
2018-01-21 12:42:49 +00:00
|
|
|
return eval(s, d)
|