jenkins-bot has submitted this change and it was merged.
Change subject: PreloadGenerators: clean up local dict handling ......................................................................
PreloadGenerators: clean up local dict handling
Improve dict handling and avoid if statements.
Change-Id: I83d6f4bee06938808ef52f4cf4f9cd0180123508 --- M pywikibot/pagegenerators.py 1 file changed, 10 insertions(+), 14 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py index 224f93a..5a43e26 100644 --- a/pywikibot/pagegenerators.py +++ b/pywikibot/pagegenerators.py @@ -1861,15 +1861,13 @@ sites.setdefault(site, []).append(page) if len(sites[site]) >= groupsize: # if this site is at the groupsize, process it - group = sites[site] - sites[site] = [] + group = sites.pop(site) for i in site.preloadpages(group, groupsize): yield i - for site in sites: - if sites[site]: - # process any leftover sites that never reached the groupsize - for i in site.preloadpages(sites[site], groupsize): - yield i + for site, pages in sites.items(): + # process any leftover sites that never reached the groupsize + for i in site.preloadpages(pages, groupsize): + yield i
@deprecated_args(step='groupsize') @@ -1914,15 +1912,13 @@ sites.setdefault(site, []).append(page) if len(sites[site]) >= groupsize: # if this site is at the groupsize, process it - group = sites[site] - sites[site] = [] + group = sites.pop(site) for i in site.preloaditempages(group, groupsize): yield i - for site in sites: - if sites[site]: - # process any leftover sites that never reached the groupsize - for i in site.preloaditempages(sites[site], groupsize): - yield i + for site, pages in sites.items(): + # process any leftover sites that never reached the groupsize + for i in site.preloaditempages(pages, groupsize): + yield i
@deprecated_args(number='total', step=None, repeat=None)
pywikibot-commits@lists.wikimedia.org