nausheenfatma / python-wikitools

Automatically exported from code.google.com/p/python-wikitools
0 stars 0 forks source link

Opensearch query doesn't work #28

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Reported by email on 2/7:

Thanks for putting together this library. I noticed that query=opensearch
breaks, because you use the default __init__ from dict for APIResult, and
query=opensearch returns a list.  All I do here is check if the data is a
list, and if so, I turn it into a dictionary in a very naive way. 
Certainly could be done better, but hey, it's 2am :D.

--- python-wikitools-read-only/api.py    2010-02-07 00:47:35.000000000 -0500
+++ wikitools-dev-wrapper/wikitools/api.py    2010-02-07 01:25:38.000000000
-0500
@@ -230,7 +230,12 @@
         while maxlag:
             try:
                 maxlag = False
-                content = APIResult(json.loads(data.read()))
+                json_data = json.loads(data.read())
+                if isinstance(json_data,list):
+                    #if here, then query=opensearch
+                    json_data = { 'query'   : json_data[0],
+                                  'results' : json_data[1]  }
+                content = APIResult(json_data)
                 content.response = self.response.items()
                 if 'error' in content:
                     error = content['error']['code']

Original issue reported on code.google.com by MrZmanwiki@gmail.com on 15 Feb 2010 at 12:52

GoogleCodeExporter commented 8 years ago
Fixed in r313

Original comment by MrZmanwiki@gmail.com on 20 Feb 2010 at 9:22