jenkins-bot has submitted this change and it was merged.

Change subject: Print a warning message if the target template does not exist
......................................................................


Print a warning message if the target template does not exist

While replaceing templates the target template should exist.
Print a warning and ask for proceed the current replacement.

Change-Id: I0c217b985957e7cb9a2b07005eea384419fcc462
---
M scripts/template.py
1 file changed, 8 insertions(+), 0 deletions(-)

Approvals:
  Merlijn van Deen: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/scripts/template.py b/scripts/template.py
index a2432c3..843965d 100755
--- a/scripts/template.py
+++ b/scripts/template.py
@@ -272,6 +272,14 @@
             elif self.remove:
                 replacements.append((templateRegex, ''))
             else:
+                template = pywikibot.Page(site, new)
+                if not template.exists():
+                    pywikibot.warning(u'Template "%s" does not exist.' % new)
+                    choice = pywikibot.inputChoice(
+                        u'Do you want to proceed anyway?',
+                        ['Yes', 'No'], ['y', 'N'], 'N')
+                    if choice == 'n':
+                        continue
                 replacements.append((templateRegex,
                                      '{{%s\g<parameters>}}' % new))
 

-- 
To view, visit https://gerrit.wikimedia.org/r/119741
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I0c217b985957e7cb9a2b07005eea384419fcc462
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Merlijn van Deen <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to