nausheenfatma / python-wikitools

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

query for links can get stuck if there are no links in page #50

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I create a query to get the redirect links in a page using the following:

params = {'action':'query',
        'generator':'links',
        'gpllimit':'10',
        'pageids':pageid,
        'redirects':''
    }
req = api.APIRequest(globalsite, params)
res = req.query(querycontinue=True)

This works fine as long as the page has any links, but it gets in an endless 
loop in api.py if there are no links in the page.

Basically the problem is the following lines. The data is initially false, and 
following the call to __parseJSON it is an empty list []. Because and empty 
list counts as true for the loop, this continues forever.

while not data:
  rawdata = self.__getRaw()
  data = self.__parseJSON(rawdata)

Version is relatively recent - sorry, can't tell you exactly what 

Original issue reported on code.google.com by hamishwi...@gmail.com on 25 Jul 2012 at 4:44

GoogleCodeExporter commented 8 years ago

Original comment by MrZmanwiki@gmail.com on 7 Dec 2013 at 10:41