jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/522596 )
Change subject: [IMPR] simplify arg parsing ......................................................................
[IMPR] simplify arg parsing
detached from I3b341d3
Change-Id: Ie130acaf3207a5a49ceb798eaa47975f100b1d80 --- M scripts/clean_sandbox.py 1 file changed, 14 insertions(+), 15 deletions(-)
Approvals: Dvorapa: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/clean_sandbox.py b/scripts/clean_sandbox.py index 36c27f7..89886ed 100755 --- a/scripts/clean_sandbox.py +++ b/scripts/clean_sandbox.py @@ -257,22 +257,21 @@ local_args = pywikibot.handle_args(args) gen_factory = pagegenerators.GeneratorFactory() for arg in local_args: - if arg.startswith('-hours:'): - opts['hours'] = float(arg[7:]) + opt, _, value = arg.partition(':') + if opt.startswith('-'): + opt = opt[1:] + else: + continue + if opt == 'hours': + opts[opt] = float(value) opts['no_repeat'] = False - elif arg.startswith('-delay:'): - opts['delay'] = int(arg[7:]) - elif arg.startswith('-text'): - if len(arg) == 5: - opts['text'] = pywikibot.input( - 'What text do you want to substitute?') - else: - opts['text'] = arg[6:] - elif arg.startswith('-summary'): - if len(arg) == len('-summary'): - opts['summary'] = pywikibot.input('Enter the summary:') - else: - opts['summary'] = arg[9:] + elif opt == 'delay': + opts[opt] = int(value) + elif opt == 'text': + opts[opt] = value or pywikibot.input( + 'What text do you want to substitute?') + elif opt == 'summary': + opts[opt] = value or pywikibot.input('Enter the summary:') else: gen_factory.handleArg(arg)