From 33d889aaf8d0a28441f0112928754a1eea8d8c73 Mon Sep 17 00:00:00 2001 From: Damien Churchill Date: Mon, 10 Aug 2009 09:46:57 +0000 Subject: [PATCH] add dump and load methods to the json module if it isn't simplejson --- deluge/common.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/deluge/common.py b/deluge/common.py index 8e15ceca6..cae8222d9 100644 --- a/deluge/common.py +++ b/deluge/common.py @@ -53,6 +53,15 @@ if not hasattr(json, "dumps"): json.dumps = json.write json.loads = json.read + def dump(obj, fp, **kw): + fp.write(json.dumps(obj)) + + def load(fp, **kw): + return json.loads(fp.read()) + + json.dump = dump + json.load = load + import pkg_resources import xdg, xdg.BaseDirectory