jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/434266 )
Change subject: [IMPR] use setup/teardown for scripts ......................................................................
[IMPR] use setup/teardown for scripts
instead of overwriting run method use new setup or teardown method
Change-Id: I93e22d325c1809e92dbdadbbe2ab1baf0fe9f7a3 --- M scripts/category.py M scripts/lonelypages.py 2 files changed, 12 insertions(+), 12 deletions(-)
Approvals: JJMC89: Looks good to me, but someone else must approve Dalba: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/category.py b/scripts/category.py index e95594f..09faef2 100755 --- a/scripts/category.py +++ b/scripts/category.py @@ -1108,12 +1108,11 @@ self.move_to_category(member, original_cat, subcatlist[choice[1]])
- def run(self): - """Start bot.""" - super(CategoryTidyRobot, self).run() + def teardown(self): + """Cleanups after run operation.""" if not self._treat_counter: - pywikibot.output('There are no pages or files in category %s' - % self.catTitle) + pywikibot.output('There are no pages or files in category {}' + .format(self.catTitle))
def treat(self, page): """Process page.""" diff --git a/scripts/lonelypages.py b/scripts/lonelypages.py index ca9f9c2..8f4d2d1 100755 --- a/scripts/lonelypages.py +++ b/scripts/lonelypages.py @@ -34,7 +34,7 @@ # # (C) Pietrodn, it.wiki 2006-2007 # (C) Filnik, it.wiki 2007 -# (C) Pywikibot team, 2008-2017 +# (C) Pywikibot team, 2008-2018 # # Distributed under the terms of the MIT license. # @@ -168,14 +168,15 @@ return getenable == 'enable' return True
- def run(self): - """Run the bot.""" - # If the enable page is set to disable, turn off the bot - # (useful when the bot is run on a server) + def setup(self): + """Setup the bot. + + If the enable page is set to disable, set an empty generator which + turns off the bot (useful when the bot is run on a server). + """ if not self.enable_page(): pywikibot.output('The bot is disabled') - return - super(LonelyPagesBot, self).run() + self.generator = ()
def treat(self, page): """Check if page is applicable and not marked and add template then."""
pywikibot-commits@lists.wikimedia.org