jenkins-bot merged this change.

View Change

Approvals: Framawiki: Looks good to me, approved jenkins-bot: Verified
Correctly handle invalid titles in harvest_template.py

Neither of those constructors raises that exception.

Bug: T200224
Change-Id: I002be74cd9590b06cb72df7c4e0476fb9ee9d76d
---
M scripts/harvest_template.py
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/scripts/harvest_template.py b/scripts/harvest_template.py
index bef2894..b0ff2fd 100755
--- a/scripts/harvest_template.py
+++ b/scripts/harvest_template.py
@@ -182,14 +182,15 @@

def _template_link_target(self, item, link_text):
link = pywikibot.Link(link_text)
+ linked_page = pywikibot.Page(link)
try:
- linked_page = pywikibot.Page(link)
+ exists = linked_page.exists()
except pywikibot.exceptions.InvalidTitle:
- pywikibot.error('%s is not a valid title so it cannot be linked. '
- 'Skipping.' % link_text)
+ pywikibot.error('"%s" is not a valid title so it cannot be linked.'
+ ' Skipping.' % link_text)
return None

- if not linked_page.exists():
+ if not exists:
pywikibot.output('%s does not exist so it cannot be linked. '
'Skipping.' % (linked_page))
return None

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

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I002be74cd9590b06cb72df7c4e0476fb9ee9d76d
Gerrit-Change-Number: 447591
Gerrit-PatchSet: 2
Gerrit-Owner: Matěj Suchánek <matejsuchanek97@gmail.com>
Gerrit-Reviewer: Framawiki <framawiki@tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb@gmail.com>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444@gmail.com>
Gerrit-Reviewer: jenkins-bot (75)