jenkins-bot merged this change.

View Change

Approvals: D3r1ck01: Looks good to me, approved jenkins-bot: Verified
[IMPR] Make SandboxBot a ConfigParserBot

This enables to set all options in scripts.ini file inside
[clean_sandbox] section

- change hours to 1.0 to be parsed as float
- change delay to -1 to be parsed as int

Change-Id: I3c357d31a3f28ce99f4859385ceaaf5a4b0f118f
---
M scripts/clean_sandbox.py
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/scripts/clean_sandbox.py b/scripts/clean_sandbox.py
index 36c27f7..ccc9834 100755
--- a/scripts/clean_sandbox.py
+++ b/scripts/clean_sandbox.py
@@ -43,7 +43,8 @@

import pywikibot

-from pywikibot import i18n, Bot, pagegenerators
+from pywikibot import i18n, pagegenerators
+from pywikibot.bot import Bot, ConfigParserBot

content = {
'commons': '{{Sandbox}}\n<!-- Please edit only below this line. -->',
@@ -131,23 +132,23 @@
}


-class SandboxBot(Bot):
+class SandboxBot(Bot, ConfigParserBot):

"""Sandbox reset bot."""

availableOptions = {
- 'hours': 1,
+ 'hours': 1.0,
'no_repeat': True,
- 'delay': None,
- 'delay_td': None,
+ 'delay': -1,
'text': '',
'summary': '',
+ 'delay_td': None, # not a real option but __init__ sets it
}

def __init__(self, **kwargs):
"""Initializer."""
super(SandboxBot, self).__init__(**kwargs)
- if self.getOption('delay') is None:
+ if self.getOption('delay') < 0:
d = min(15, max(5, int(self.getOption('hours') * 60)))
self.availableOptions['delay_td'] = datetime.timedelta(minutes=d)
else:

To view, visit change 511714. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I3c357d31a3f28ce99f4859385ceaaf5a4b0f118f
Gerrit-Change-Number: 511714
Gerrit-PatchSet: 6
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki@aol.com>
Gerrit-Reviewer: John Vandenberg <jayvdb@gmail.com>
Gerrit-Reviewer: jenkins-bot (75)