summaryrefslogtreecommitdiffstats
path: root/lib/utils.py
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-07-15 13:42:40 +0800
committerPeng Wu <alexepico@gmail.com>2011-07-15 13:42:40 +0800
commit76503e97efe8a70f1ce888427c1d4c0d2486548a (patch)
tree1fc059e5f22630c286cc684a05aa0226ecbf1091 /lib/utils.py
parent2c28a5c87d904f69dcc554070038995390903f76 (diff)
downloadtrainer-76503e97efe8a70f1ce888427c1d4c0d2486548a.tar.gz
trainer-76503e97efe8a70f1ce888427c1d4c0d2486548a.tar.xz
trainer-76503e97efe8a70f1ce888427c1d4c0d2486548a.zip
begin to write utils.py
Diffstat (limited to 'lib/utils.py')
-rw-r--r--lib/utils.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/utils.py b/lib/utils.py
new file mode 100644
index 0000000..b2e6f10
--- /dev/null
+++ b/lib/utils.py
@@ -0,0 +1,24 @@
+import json
+
+#Utils
+
+#File Load/Store
+def read_file(infile):
+ with open(infile, 'r') as f:
+ data = ''.join(f.readlines())
+ f.close()
+ return data
+
+def write_file(outfile, data):
+ with open(outfile, 'w') as f:
+ f.writelines([data])
+ f.close()
+ return
+
+#JSON Load/Store
+def load_status(infile):
+ return json.loads(read_file(infile))
+
+def store_status(outfile, obj):
+ write_file(outfile, json.dumps(obj))
+ return