Actually keep track of listed titles and stop when duplicates are returned

https://github.com/WikiTeam/wikiteam/issues/309
pull/319/head
Federico Leva 6 years ago
parent 80288cf49e
commit 4bc41c3aa2

@ -306,13 +306,14 @@ def getPageTitlesAPI(config={}, session=None):
if isinstance(allpages, dict):
allpages = allpages.values()
for page in allpages:
yield page['title']
title = page['title']
titles.append(title)
yield title
c += len(allpages)
if len(titles) != len(set(titles)):
# probably we are in a loop, server returning dupe titles, stop
# it
print 'Probably a loop, finishing'
print 'Probably a loop, switching to next namespace. Duplicate title:'
print title
titles = list(set(titles))
apfrom = ''

Loading…
Cancel
Save