Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tautils.py
diff options
context:
space:
mode:
authorWalter Bender <walter@walter-laptop.(none)>2010-02-02 14:26:43 (GMT)
committer Walter Bender <walter@walter-laptop.(none)>2010-02-02 14:26:43 (GMT)
commit1b5b6af91b260dc90620baafae25fb2d0d396a06 (patch)
tree6df0a9c47640125abdbaf33f35412f03f8b8c1be /tautils.py
parentb37468eb683bf91b363c8fcd17e7c0542937ded7 (diff)
clean up of load code
Diffstat (limited to 'tautils.py')
-rw-r--r--tautils.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/tautils.py b/tautils.py
index a97aa52..3cad9c8 100644
--- a/tautils.py
+++ b/tautils.py
@@ -38,6 +38,10 @@ except (ImportError, AttributeError):
from StringIO import StringIO
import os.path
+def magnitude(pos):
+ x, y = pos
+ return x*x+y*y
+
def json_load(text):
if _old_Sugar_system is True:
listdata = json.read(text)
@@ -98,13 +102,16 @@ def data_from_file(ta_file):
# Rewind necessary because of failed pickle.load attempt
f.seek(0)
text = f.read()
- data = json_load(text)
+ data = data_from_string(text)
f.close()
return data
+def data_from_string(text):
+ return json_load(text)
+
def data_to_file(data, ta_file):
f = file(ta_file, "w")
- f.write(json_dump(data))
+ f.write(data_to_string(data))
f.close()
def data_to_string(data):