jenkins-bot merged this change.
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.