jenkins-bot submitted this change.
[IMPR] reduce code complexity of pagegenerators.py
Change-Id: I4fa1a4d6c9dc2ae5d425505eb3742d3c512bbfdf
---
M pywikibot/pagegenerators.py
1 file changed, 10 insertions(+), 9 deletions(-)
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,
To view, visit change 639919. To unsubscribe, or for help writing mail filters, visit settings.