Ticket #3142: 0001-Use-json-as-included-in-Python-SL-3142.2.patch

File 0001-Use-json-as-included-in-Python-SL-3142.2.patch, 2.4 KB (added by humitos, 12 years ago)

Speak Activity Patch

  • activity.py

    From 3f63a84bc78001a4df00fa777f5bc02756baed0a Mon Sep 17 00:00:00 2001
    From: Manuel Kaufmann <humitos@gmail.com>
    Date: Thu, 9 Aug 2012 10:19:01 -0300
    Subject: [PATCH Speak] Use json as included in Python SL #3142
    
    We use json as included in Python. This will make Sugar dependent on
    Python 2.6 and Python 2.7 to have the highest JSON performance.
    
    Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
    ---
     activity.py | 6 +++---
     face.py     | 6 +++---
     2 files changed, 6 insertions(+), 6 deletions(-)
    
    diff --git a/activity.py b/activity.py
    index d4f0e2a..257365f 100644
    a b import logging 
    2828import gtk
    2929import gobject
    3030import pango
    31 import cjson
     31import json
    3232from gettext import gettext as _
    3333
    3434from sugar.graphics.toolbarbox import ToolbarButton
    class SpeakActivity(SharedActivity): 
    283283                % xoOwner.props.nick)
    284284
    285285    def resume_instance(self, file_path):
    286         cfg = cjson.decode(file(file_path, 'r').read())
     286        cfg = json.loads(file(file_path, 'r').read())
    287287
    288288        status = self.face.status = face.Status().deserialize(cfg['status'])
    289289        self.voices.select(status.voice)
    class SpeakActivity(SharedActivity): 
    305305                'history': [unicode(i[0], 'utf-8', 'ignore') \
    306306                        for i in self.entrycombo.get_model()],
    307307                }
    308         file(file_path, 'w').write(cjson.encode(cfg))
     308        file(file_path, 'w').write(json.dumps(cfg))
    309309
    310310    def share_instance(self, connection, is_initiator):
    311311        self.chat.messenger = Messenger(connection, is_initiator, self.chat)
  • face.py

    diff --git a/face.py b/face.py
    index b7e3372..f5e0d00 100644
    a b  
    2424
    2525import logging
    2626import gtk
    27 import cjson
     27import json
    2828
    2929import sugar.graphics.style as style
    3030
    class Status: 
    5757                  fft_mouth.FFTMouth: 2,
    5858                  waveform_mouth.WaveformMouth: 3}
    5959
    60         return cjson.encode({
     60        return json.dumps({
    6161            'voice': {'language': self.voice.language,
    6262                      'name': self.voice.name},
    6363            'pitch': self.pitch,
    class Status: 
    7272                  2: fft_mouth.FFTMouth,
    7373                  3: waveform_mouth.WaveformMouth}
    7474
    75         data = cjson.decode(buf)
     75        data = json.loads(buf)
    7676        self.voice = voice.Voice(data['voice']['language'],
    7777                data['voice']['name'])
    7878        self.pitch = data['pitch']