jenkins-bot has submitted this change and it was merged.
Change subject: [bugfix] hastemplate() returns true for even one existing template ......................................................................
[bugfix] hastemplate() returns true for even one existing template
- Don't care about remove_tl. We may remove them anyway. - Care about the first item. It must exist because that one is added to the paqe.
bug: T98073 Change-Id: Ic9933c384233e58e03bca6404e5ba53f454976e4 --- M scripts/featured.py 1 file changed, 11 insertions(+), 8 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/featured.py b/scripts/featured.py index ed6347d..9e534b7 100755 --- a/scripts/featured.py +++ b/scripts/featured.py @@ -297,15 +297,18 @@
def hastemplate(self, task): add_tl, remove_tl = self.getTemplateList(self.site.code, task) - for tl in add_tl: + for i, tl in enumerate(add_tl): tp = pywikibot.Page(self.site, tl, ns=10) - if not tp.exists(): - return - for tl in remove_tl: - tp = pywikibot.Page(self.site, tl, ns=10) - if not tp.exists(): - return - return True + if tp.exists(): + return True + else: + pywikibot.output(tl + ' does not exist') + # The first item is the default template to be added. + # It must exist. Otherwise the script must not run. + if i == 0: + return + else: + return
def readcache(self, task): if self.getOption('count') or self.getOption('nocache') is True:
pywikibot-commits@lists.wikimedia.org