diff options
author | Aleksey Lim <alsroot@member.fsf.org> | 2009-03-05 01:34:35 (GMT) |
---|---|---|
committer | Aleksey Lim <alsroot@member.fsf.org> | 2009-03-05 01:34:35 (GMT) |
commit | f234116215113c79bbaaec53c08ecee789504eb2 (patch) | |
tree | 3680a40b32ba632503ac74ee93d6b647ee8645c4 | |
parent | 34a2dc29b728f3d86ec5436096430cbcecfef3f3 (diff) |
Use simplejson instead of json-py to satisfy python26
-rwxr-xr-x | moon.py | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -58,9 +58,14 @@ from sugar.graphics.toolbutton import ToolButton from gettext import gettext as _ import math import time -import json import os +try: + import json + json.dumps +except (ImportError, AttributeError): + import simplejson as json + IMAGE_SIZE = 726 HALF_SIZE = IMAGE_SIZE / 2 @@ -154,7 +159,7 @@ class MoonActivity(activity.Activity): """Parse and set preference data from a given file.""" try: read_file = open(file_path, 'r') - self.activity_state = json.read(read_file.read()) + self.activity_state = json.loads(read_file.read()) if self.activity_state.has_key('hemisphereView'): self.hemisphere_view = self.activity_state['hemisphereView'] if self.activity_state.has_key('showGrid'): @@ -172,7 +177,7 @@ class MoonActivity(activity.Activity): """Write state to journal datastore and to persistent file system.""" self.activity_state['hemisphereView'] = self.hemisphere_view self.activity_state['showGrid'] = self.show_grid - serialised_data = json.write(self.activity_state) + serialised_data = json.dumps(self.activity_state) to_journal = file(file_path, 'w') try: |