Merge lp:~stefanor/ibid/google-380918 into lp:~ibid-core/ibid/old-trunk-pack-0.92

Proposed by Stefano Rivera
Status: Merged
Approved by: Jonathan Hitchcock
Approved revision: 644
Merged at revision: 654
Proposed branch: lp:~stefanor/ibid/google-380918
Merge into: lp:~ibid-core/ibid/old-trunk-pack-0.92
Diff against target: None lines
To merge this branch: bzr merge lp:~stefanor/ibid/google-380918
Reviewer Review Type Date Requested Status
Jonathan Hitchcock Approve
Michael Gorven Approve
Review via email: mp+6910@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Michael Gorven (mgorven) wrote :

 review approve

review: Approve
Revision history for this message
Jonathan Hitchcock (vhata) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ibid/plugins/google.py'
--- ibid/plugins/google.py 2009-05-01 12:17:57 +0000
+++ ibid/plugins/google.py 2009-05-30 18:53:10 +0000
@@ -45,7 +45,12 @@
4545
46 @match(r'^google\s+(?:for\s+)?(.+?)$')46 @match(r'^google\s+(?:for\s+)?(.+?)$')
47 def search(self, event, query):47 def search(self, event, query):
48 items = self._google_api_search(query)48 try:
49 items = self._google_api_search(query)
50 except BadStatusLine:
51 event.addresponse(u"Google appears to be broken (or more likely, my connection to it)")
52 return
53
49 results = []54 results = []
50 for item in items["responseData"]["results"]:55 for item in items["responseData"]["results"]:
5156
@@ -60,8 +65,13 @@
6065
61 @match(r'^(?:rank|(?:google(?:fight|compare|cmp)))\s+(?:for\s+)?(.+?)\s+and\s+(.+?)$')66 @match(r'^(?:rank|(?:google(?:fight|compare|cmp)))\s+(?:for\s+)?(.+?)\s+and\s+(.+?)$')
62 def googlefight(self, event, term1, term2):67 def googlefight(self, event, term1, term2):
63 count1 = int(self._google_api_search(term1, "small")["responseData"]["cursor"].get("estimatedResultCount", 0))68 try:
64 count2 = int(self._google_api_search(term2, "small")["responseData"]["cursor"].get("estimatedResultCount", 0))69 count1 = int(self._google_api_search(term1, "small")["responseData"]["cursor"].get("estimatedResultCount", 0))
70 count2 = int(self._google_api_search(term2, "small")["responseData"]["cursor"].get("estimatedResultCount", 0))
71 except BadStatusLine:
72 event.addresponse(u"Google appears to be broken (or more likely, my connection to it)")
73 return
74
65 event.addresponse(u'%(firstterm)s wins with %(firsthits)i hits, %(secondterm)s had %(secondhits)i hits',75 event.addresponse(u'%(firstterm)s wins with %(firsthits)i hits, %(secondterm)s had %(secondhits)i hits',
66 (count1 > count2 and {76 (count1 > count2 and {
67 'firstterm': term1,77 'firstterm': term1,

Subscribers

People subscribed via source and target branches