jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/472864 )
Change subject: [IMPR] Allow use of action=purge API parameters ......................................................................
[IMPR] Allow use of action=purge API parameters
Add options to use forcelinkupdate, forcerecursivelinkupdate, redirects, and converttitles.
Change-Id: I607304403ded6eedc7d89885c1aecc9fe379e25c --- M scripts/touch.py 1 file changed, 27 insertions(+), 5 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/touch.py b/scripts/touch.py index 48ba7f6..24f5605 100755 --- a/scripts/touch.py +++ b/scripts/touch.py @@ -10,8 +10,17 @@
¶ms;
--purge Do not touch but purge the page --botflag Force botflag in case of edits with changes. +-purge Do not touch but purge the page + +Touch arguments: +-botflag Force botflag in case of edits with changes. + +Purge arguments: +-converttitles Convert titles to other variants if necessary +-forcelinkupdate Update the links tables +-forcerecursivelinkupdate Update the links table, and update the links tables + for any page that uses this page as a template +-redirects Automatically resolve redirects
""" # @@ -62,10 +71,22 @@
"""Purge each page on the generator."""
+ def __init__(self, generator, **kwargs): + """Initialize a PurgeBot instance with the options and generator.""" + self.availableOptions = { + 'converttitles': None, + 'forcelinkupdate': None, + 'forcerecursivelinkupdate': None, + 'redirects': None + } + super(PurgeBot, self).__init__(generator=generator, **kwargs) + def treat(self, page): """Purge the given page.""" pywikibot.output('Page {0}{1} purged'.format( - page.title(as_link=True), '' if page.purge() else ' not')) + page.title(as_link=True), + '' if page.purge(**self.options) else ' not' + ))
def main(*args): @@ -86,14 +107,15 @@
bot_class = TouchBot for arg in local_args: + if gen_factory.handleArg(arg): + continue if arg == '-purge': bot_class = PurgeBot elif arg == '-redir': issue_deprecation_warning( '\n-redir', None, 1, ArgumentDeprecationWarning, since='20150514') - elif not gen_factory.handleArg(arg) and arg.startswith('-'): - # -botflag + elif arg.startswith('-'): options[arg[1:].lower()] = True
gen = gen_factory.getCombinedGenerator(preload=True)
pywikibot-commits@lists.wikimedia.org