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

File 0001-Use-json-as-included-in-Python-SL-3142.3.patch, 2.3 KB (added by humitos, 9 years ago)

Read Activity patch

  • readbookmark.py

    From ecee40a5cf25466d483bda4b2f61177ca30973b5 Mon Sep 17 00:00:00 2001
    From: Manuel Kaufmann <humitos@gmail.com>
    Date: Thu, 9 Aug 2012 10:22:12 -0300
    Subject: [PATCH Read] 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>
    ---
     readbookmark.py | 6 +++---
     readdialog.py   | 6 +++---
     2 files changed, 6 insertions(+), 6 deletions(-)
    
    diff --git a/readbookmark.py b/readbookmark.py
    index 6a8e96c..c0afe4f 100644
    a b  
    1515# along with this program; if not, write to the Free Software
    1616# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    1717
    18 import cjson
     18import json
    1919
    2020
    2121class Bookmark:
    class Bookmark: 
    3939        if self.content == '' or self.content is None:
    4040            return ''
    4141
    42         note = cjson.decode(self.content)
     42        note = json.loads(self.content)
    4343        return note['title']
    4444
    4545    def get_note_body(self):
    4646        if self.content == '' or self.content is None:
    4747            return ''
    4848
    49         note = cjson.decode(self.content)
     49        note = json.loads(self.content)
    5050        return note['body']
  • readdialog.py

    diff --git a/readdialog.py b/readdialog.py
    index b6366bf..4c868d5 100644
    a b from sugar3.graphics import style 
    99from sugar3.graphics.toolbutton import ToolButton
    1010
    1111from gettext import gettext as _
    12 import cjson
     12import json
    1313
    1414
    1515class BaseReadDialog(Gtk.Window):
    class BookmarkAddDialog(BookmarkDialog): 
    180180        content = {'title': title.decode('utf-8'),
    181181                'body': details.decode('utf-8')}
    182182        self._sidebarinstance._real_add_bookmark(self._page,
    183                 cjson.encode(content))
     183                json.dumps(content))
    184184        self.destroy()
    185185
    186186    def cancel_clicked_cb(self, widget):
    class BookmarkEditDialog(BookmarkDialog): 
    202202                'body': details.decode('utf-8')}
    203203        self._sidebarinstance.del_bookmark(self._page)
    204204        self._sidebarinstance._real_add_bookmark(self._page,
    205                 cjson.encode(content))
     205                json.dumps(content))
    206206        self.destroy()