Xqt has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/119741

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(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/41/119741/1

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: newchange
Gerrit-Change-Id: I0c217b985957e7cb9a2b07005eea384419fcc462
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <[email protected]>

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

Reply via email to