jenkins-bot has submitted this change and it was merged.
Change subject: unusedfiles.py: allow to specify number of unused files ......................................................................
unusedfiles.py: allow to specify number of unused files
Allow to specify total parameter in unusedfiles.py.
Bug: T145854 Change-Id: I3eb055232f5582602a7ff5082565921507a22f49 --- M scripts/unusedfiles.py 1 file changed, 17 insertions(+), 8 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/unusedfiles.py b/scripts/unusedfiles.py index 0c19ec7..3bb027a 100755 --- a/scripts/unusedfiles.py +++ b/scripts/unusedfiles.py @@ -7,6 +7,9 @@
-always Don't be asked every time. -nouserwarning Do not warn uploader about orphaned file. +-total Specify number of pages to work on with "-total:n" where + n is the maximum number of articles to work on. + If not used, all pages are used. """ # # (C) Leonardo Gregianin, 2007 @@ -57,11 +60,6 @@ (self.template_user or self.getOption('nouserwarning'))): raise pywikibot.Error(u'This script is not localized for %s site.' % self.site) - - generator = pagegenerators.UnusedFilesGenerator(site=self.site) - generator = pagegenerators.PreloadingGenerator(generator) - - self.generator = generator
def treat(self, image): """Process one image page.""" @@ -114,11 +112,22 @@ @type args: list of unicode """ options = {} + total = None
- for arg in pywikibot.handle_args(args): - options[arg[1:]] = True + local_args = pywikibot.handle_args(args)
- bot = UnusedFilesBot(pywikibot.Site(), **options) + for arg in local_args: + arg, sep, value = arg.partition(':') + if arg == '-total': + total = value + else: + options[arg[1:]] = True + + site = pywikibot.Site() + gen = pagegenerators.UnusedFilesGenerator(total=total, site=site) + gen = pagegenerators.PreloadingGenerator(gen) + + bot = UnusedFilesBot(site, generator=gen, **options) try: bot.run() except pywikibot.Error as e:
pywikibot-commits@lists.wikimedia.org