Browse files

Multiple word, multiple definitions bugfix

  • Loading branch information...
1 parent 13debd9 commit 252c17e346897e159b623e0267ab4d9c42791dd9 @dpflug dpflug committed Sep 6, 2011
Showing with 10 additions and 1 deletion.
  1. +1 −1 Plugins/Google_Define.py
  2. +9 −0 Services/Google.py
View
2 Plugins/Google_Define.py
@@ -6,7 +6,7 @@
@requires("Google")
@prefers("Colors")
class Google_Define:
- @bindFunction(message="!gd (?P<term>[\w ]+) ?(?P<definition>\d*)")
+ @bindFunction(message="!gd (?P<term>[a-zA-Z ]+) ?(?P<definition>\d*)")
def g_define(self, term, response, target, colorize, gdefine, definition):
log.debug("g_define",term, response, target, colorize, gdefine, definition)
View
9 Services/Google.py
@@ -1,6 +1,13 @@
import urllib
import urllib2
import lxml.html
+
+try:
+ import simplejson
+ is_json = True
+except:
+ is_json = False
+
from Hook import bindFunction
from Logging import LogFile
log = LogFile("GoogleService")
@@ -14,6 +21,8 @@ def _buildResponse(self, url, is_json=False):
request = urllib2.Request(url, None, HEADERS)
response = urllib2.urlopen(request)
if is_json:
+ response = response.read()
+ # FIXME: simplejson doesn't like the callback, I think
response = simplejson.load(response)
if not 'responseData' in response:
log.warning("Json response was empty")

0 comments on commit 252c17e

Please sign in to comment.