deskbar-applet r2492 - in trunk: . deskbar/handlers
- From: sebp svn gnome org
- To: svn-commits-list gnome org
- Subject: deskbar-applet r2492 - in trunk: . deskbar/handlers
- Date: Mon, 1 Dec 2008 10:08:30 +0000 (UTC)
Author: sebp
Date: Mon Dec 1 10:08:30 2008
New Revision: 2492
URL: http://svn.gnome.org/viewvc/deskbar-applet?rev=2492&view=rev
Log:
Fixed bug #561181: Support both simplejson and json module
Patch by Steven Harms
Modified:
trunk/ChangeLog
trunk/deskbar/handlers/googlesearch.py
Modified: trunk/deskbar/handlers/googlesearch.py
==============================================================================
--- trunk/deskbar/handlers/googlesearch.py (original)
+++ trunk/deskbar/handlers/googlesearch.py Mon Dec 1 10:08:30 2008
@@ -10,10 +10,14 @@
import logging
import urllib
import gtk
+
try:
- import simplejson
+ import json
except:
- pass
+ try:
+ import simplejson as json
+ except:
+ pass
LOGGER = logging.getLogger(__name__)
@@ -152,8 +156,8 @@
LOGGER.debug('Got Google answer for: %s', qstring)
- json = simplejson.loads(stream.read())
- results = json['responseData']['results']
+ jsondata = json.loads(stream.read())
+ results = jsondata['responseData']['results']
stream.close()
LOGGER.debug("Returning Google answer for: %s", qstring)
@@ -173,12 +177,19 @@
@staticmethod
def has_requirements():
+ """
+ Check that required libraries are available for this module to work
+ """
+
try:
- import simplejson
- return True
+ import json
except:
- GoogleHandler.INSTRUCTIONS = _("Python module simplejson is not available")
- return False
+ try:
+ import simplejson as json
+ except:
+ GoogleHandler.INSTRUCTIONS = _("Python module json or simplejson are not available")
+ return False
+ return True
class OpenGoogleAction(ShowUrlAction):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]