jenkins-bot submitted this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[IMPR] reduce code complexity of pagegenerators.py

Change-Id: Ide9a5d1e93fa9149a109431075e827ed0456caa3
---
M pywikibot/pagegenerators.py
1 file changed, 20 insertions(+), 15 deletions(-)

diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py
index 3bae2b5..5b45c62 100644
--- a/pywikibot/pagegenerators.py
+++ b/pywikibot/pagegenerators.py
@@ -1162,13 +1162,16 @@
value = None

handler = getattr(self, '_handle_' + arg[1:], None)
- if handler:
- handler_result = handler(value)
- if isinstance(handler_result, bool):
- return handler_result
- if handler_result:
- self.gens.append(handler_result)
- return True
+ if not handler:
+ return False
+
+ handler_result = handler(value)
+ if isinstance(handler_result, bool):
+ return handler_result
+ if handler_result:
+ self.gens.append(handler_result)
+ return True
+
return False


@@ -1480,14 +1483,16 @@
# inadvertently change pages on another wiki!
yield pywikibot.Page(pywikibot.Link(linkmatch.group('title'),
site))
- if linkmatch is None:
- f.seek(0)
- for title in f:
- title = title.strip()
- if '|' in title:
- title = title[:title.index('|')]
- if title:
- yield pywikibot.Page(site, title)
+ if linkmatch is not None:
+ return
+
+ f.seek(0)
+ for title in f:
+ title = title.strip()
+ if '|' in title:
+ title = title[:title.index('|')]
+ if title:
+ yield pywikibot.Page(site, title)


def PagesFromTitlesGenerator(iterable, site=None):

To view, visit change 639589. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ide9a5d1e93fa9149a109431075e827ed0456caa3
Gerrit-Change-Number: 639589
Gerrit-PatchSet: 1
Gerrit-Owner: Mpaa <mpaa.wiki@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged