Ticket #711: 711.patch

File 711.patch, 3.9 KB (added by erikos, 15 years ago)

Move to simplejson (which is now standard -> import json in Python 2.6)

  • keyboard.py

    diff --git a/keyboard.py b/keyboard.py
    index 34a9da2..9a04d9d 100644
    a b import gtk 
    2222import rsvg
    2323import os, glob, re
    2424import pango
    25 import simplejson
     25import json
    2626
    2727# Tweaking variables.
    2828HAND_YOFFSET = -15
    class KeyboardData: 
    321321                pass
    322322
    323323    def load_letter_map(self, filename):
    324         self.letter_map = simplejson.loads(open(filename, 'r').read())
     324        self.letter_map = json.loads(open(filename, 'r').read())
    325325
    326326    def save_letter_map(self, filename):
    327         text = simplejson.dumps(self.letter_map, ensure_ascii=False, sort_keys=True, indent=4)
     327        text = json.dumps(self.letter_map, ensure_ascii=False, sort_keys=True, indent=4)
    328328        f = open(filename, 'w')
    329329        f.write(text)
    330330        f.close()
  • lessonbuilder.py

    diff --git a/lessonbuilder.py b/lessonbuilder.py
    index fa942b7..396ac86 100755
    a b  
    1616# You should have received a copy of the GNU General Public License
    1717# along with Typing Turtle.  If not, see <http://www.gnu.org/licenses/>.
    1818
    19 import os, sys, random, simplejson, locale, re, optparse
     19import os, sys, random, json, locale, re, optparse
    2020from gettext import gettext as _
    2121
    2222# For modifier constants.
    def main(): 
    561561            new_keys=options.keys, base_keys=options.base_keys,
    562562            words=words, bad_words=bad_words)
    563563
    564     text = simplejson.dumps(lesson, ensure_ascii=False, sort_keys=True, indent=4)
     564    text = json.dumps(lesson, ensure_ascii=False, sort_keys=True, indent=4)
    565565
    566566    open(options.output, 'w').write(text)
    567567
  • lessonscreen.py

    diff --git a/lessonscreen.py b/lessonscreen.py
    index 5b620cb..3177dd5 100644
    a b  
    1616# vi:sw=4 et
    1717
    1818# Import standard Python modules.
    19 import logging, os, math, time, copy, json, locale, datetime, random, re
     19import logging, os, math, time, copy, locale, datetime, random, re
    2020from gettext import gettext as _
    2121
    2222# Import PyGTK.
  • mainscreen.py

    diff --git a/mainscreen.py b/mainscreen.py
    index 56c105e..8af4f93 100644
    a b  
    1515# along with Typing Turtle.  If not, see <http://www.gnu.org/licenses/>.
    1616
    1717# Import standard Python modules.
    18 import logging, os, math, time, copy, simplejson, locale, datetime, random, re, glob
     18import logging, os, math, time, copy, cjson, locale, datetime, random, re, glob
    1919from gettext import gettext as _
    2020
    2121# Import PyGTK.
    class MainScreen(gtk.VBox): 
    126126        for f in glob.iglob(path + '/*.lesson'):
    127127            fd = open(f, 'r')
    128128            try:
    129                 lesson = simplejson.loads(fd.read())
     129                lesson = cjson.decode(fd.read())
    130130                self.lessons.append(lesson)
    131131            finally:
    132132                fd.close()
  • medalscreen.py

    diff --git a/medalscreen.py b/medalscreen.py
    index 42833bf..a1d881a 100644
    a b  
    1515# along with Typing Turtle.  If not, see <http://www.gnu.org/licenses/>.
    1616
    1717# Import standard Python modules.
    18 import logging, os, math, time, copy, json, locale, datetime, random, re
     18import logging, os, math, time, copy, locale, datetime, random, re
    1919from gettext import gettext as _
    2020
    2121# Import PyGTK.
  • typingturtle.py

    diff --git a/typingturtle.py b/typingturtle.py
    index e9c2f9e..e09fc71 100755
    a b class TypingTurtle(sugar.activity.activity.Activity): 
    115115        try:
    116116            text = fd.read()
    117117            print "read %s" % text
    118             self.data = json.read(text)
     118            self.data = json.loads(text)
    119119        finally:
    120120            fd.close()
    121121
    class TypingTurtle(sugar.activity.activity.Activity): 
    129129       
    130130        fd = open(file_path, 'w')
    131131        try:
    132             text = json.write(self.data)
     132            text = json.dumps(self.data)
    133133            fd.write(text)
    134134            print "wrote %s" % text
    135135        finally: