jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/731223 )
Change subject: [doc] Update ConfigParserBot documentation ......................................................................
[doc] Update ConfigParserBot documentation
- update documentation for basic.py - add documention for blockpageschecker.py
clean_sandbox.py: - update documentation - remove internal option 'no_repeat' and use hours value -1 to not repeat script run - remove internal 'delay_td' option and use delay_td attribute instead
Change-Id: I97a1a1d91efc377737a8d130d3cd4872a3aefaec --- M scripts/basic.py M scripts/blockpageschecker.py M scripts/clean_sandbox.py 3 files changed, 18 insertions(+), 12 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/basic.py b/scripts/basic.py index 0691d00..e8695da 100755 --- a/scripts/basic.py +++ b/scripts/basic.py @@ -22,10 +22,12 @@
-summary: Set the action summary message for the edit.
-All settings can be made either by giving option with the command line -or with a settings file which is scripts.ini by default. If you don't -want the default values you can add any option you want to change to -that settings file below the [basic] section like: +This sample script is a +:py:obj:`ConfigParserBot <pywikibot.bot.ConfigParserBot>`. All settings can be +made either by giving option with the command line or with a settings file +which is scripts.ini by default. If you don't want the default values you can +add any option you want to change to that settings file below the [basic] +section like:
[basic] ; inline comments starts with colon # This is a commend line. Assignments may be done with '=' or ':' diff --git a/scripts/blockpageschecker.py b/scripts/blockpageschecker.py index dc8715f..b5186c3 100755 --- a/scripts/blockpageschecker.py +++ b/scripts/blockpageschecker.py @@ -19,6 +19,10 @@
-moveprotected Same as -protectedpages, for moveprotected pages
+This script is a :py:obj:`ConfigParserBot <pywikibot.bot.ConfigParserBot>`. +The following options can be set within a settings file which is scripts.ini +by default:: + -always Doesn't ask every time whether the bot should make the change. Do it always.
diff --git a/scripts/clean_sandbox.py b/scripts/clean_sandbox.py index 6848c1d..e27b729 100755 --- a/scripts/clean_sandbox.py +++ b/scripts/clean_sandbox.py @@ -23,6 +23,7 @@ -summary Summary of the edit made by bot. Overrides the default from i18n.
+This script is a :py:obj:`ConfigParserBot <pywikibot.bot.ConfigParserBot>`. All local parameters can be given inside a scripts.ini file. Options passed to the script are priorized over options read from ini file. See: https://docs.python.org/3/library/configparser.html#supported-ini-file-struc... @@ -152,12 +153,10 @@ """Sandbox reset bot."""
available_options = { - 'hours': 1.0, - 'no_repeat': True, + 'hours': -1.0, # do not repeat if hours < 0 'delay': -1, 'text': '', 'summary': '', - 'delay_td': None, # not a real option but __init__ sets it }
def __init__(self, **kwargs) -> None: @@ -165,10 +164,10 @@ super().__init__(**kwargs) if self.opt.delay < 0: d = min(15, max(5, int(self.opt.hours * 60))) - self.opt.delay_td = datetime.timedelta(minutes=d) + self.delay_td = datetime.timedelta(minutes=d) else: d = max(5, self.opt.delay) - self.opt.delay_td = datetime.timedelta(minutes=d) + self.delay_td = datetime.timedelta(minutes=d)
self.site = pywikibot.Site() self.translated_content = self.opt.text or i18n.translate( @@ -224,7 +223,7 @@ else: edit_delta = (datetime.datetime.utcnow() - sandbox_page.editTime()) - delta = self.opt.delay_td - edit_delta + delta = self.delay_td - edit_delta # Is the last edit more than 'delay' minutes ago? if delta <= datetime.timedelta(0): sandbox_page.put( @@ -247,9 +246,11 @@ pywikibot.output( '*** The sandbox is not existent, skipping.') continue - if self.opt.no_repeat: + + if self.opt.hours < 0: pywikibot.output('\nDone.') return + if not wait: if self.opt.hours < 1.0: pywikibot.output('\nSleeping {} minutes, now {}'.format( @@ -279,7 +280,6 @@ continue if opt == 'hours': opts[opt] = float(value) - opts['no_repeat'] = False elif opt == 'delay': opts[opt] = int(value) elif opt == 'text':
pywikibot-commits@lists.wikimedia.org