/usr/lib/python3/dist-packages/tango/codec.py is in python3-tango 9.2.2-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | __all__ = ["loads", "dumps"]
def loads(fmt, data):
if fmt.startswith("pickle"):
import pickle
loads = pickle.loads
elif fmt.startswith("json"):
import json
loads = json.loads
else:
raise TypeError("Format '{0}' not supported".format(fmt))
return loads(data)
def dumps(fmt, obj):
if fmt.startswith("pickle"):
import pickle
ret = fmt, pickle.dumps(obj, protocol=pickle.HIGHEST_PROTOCOL)
return ret
elif fmt.startswith("json"):
import json
return fmt, json.dumps(obj)
raise TypeError("Format '{0}' not supported".format(fmt))
|