jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/639919 )
Change subject: [IMPR] reduce code complexity of pagegenerators.py ......................................................................
[IMPR] reduce code complexity of pagegenerators.py
Change-Id: I4fa1a4d6c9dc2ae5d425505eb3742d3c512bbfdf --- M pywikibot/pagegenerators.py 1 file changed, 10 insertions(+), 9 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py index 5b45c62..2bf059b 100644 --- a/pywikibot/pagegenerators.py +++ b/pywikibot/pagegenerators.py @@ -1604,18 +1604,19 @@
""" def is_ignored(page): - if page.site.code in ignore_list.get(page.site.family.name, {}): - for ig in ignore_list[page.site.family.name][page.site.code]: - if re.search(ig, page.title()): - return True - return False + try: + site_ig_list = ignore_list[page.site.family.name][page.site.code] + except KeyError: + return False + return any(re.search(ig, page.title()) for ig in site_ig_list)
for page in generator: - if is_ignored(page): - if config.verbose_output: - pywikibot.output('Ignoring page %s' % page.title()) - else: + if not is_ignored(page): yield page + continue + + if config.verbose_output: + pywikibot.output('Ignoring page %s' % page.title())
def RedirectFilterPageGenerator(generator, no_redirects: bool = True,