jenkins-bot merged this change.

View Change

Approvals: Dvorapa: Looks good to me, but someone else must approve Xqt: Looks good to me, approved jenkins-bot: Verified
Renamed -total option to -limit at redirect.py and unusedfiles.py

Bug: T148354
Change-Id: I56b04c265e0b62875c338e319b07f71cc5f88f0d
---
M scripts/redirect.py
M scripts/unusedfiles.py
2 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/scripts/redirect.py b/scripts/redirect.py
index 3c962b4..2d77de4 100755
--- a/scripts/redirect.py
+++ b/scripts/redirect.py
@@ -55,7 +55,7 @@
-until:title The possible last page title in each namespace. Page needs not
exist.

--total:n The maximum count of redirects to work upon. If omitted, there
+-limit:n The maximum count of redirects to work upon. If omitted, there
is no limit.

-delete Prompt the user whether broken redirects should be deleted (or
@@ -87,7 +87,9 @@
from pywikibot import i18n, xmlreader
from pywikibot.bot import (OptionHandler, SingleSiteBot, ExistingPageBot,
RedirectPageBot)
+from pywikibot.exceptions import ArgumentDeprecationWarning
from pywikibot.textlib import extract_templates_and_params_regex_simple
+from pywikibot.tools import issue_deprecation_warning

if sys.version_info[0] > 2:
basestring = (str, )
@@ -110,7 +112,7 @@
'offset': -1,
'page': None,
'start': None,
- 'total': None,
+ 'limit': None,
'until': None,
'xml': None,
}
@@ -125,7 +127,7 @@
self.offset = self.getOption('offset')
self.page_title = self.getOption('page')
self.api_start = self.getOption('start')
- self.api_number = self.getOption('total')
+ self.api_number = self.getOption('limit')
self.api_until = self.getOption('until')
self.xmlFilename = self.getOption('xml')

@@ -404,7 +406,7 @@
def __init__(self, action, **kwargs):
"""Initializer."""
self.availableOptions.update({
- 'total': float('inf'),
+ 'limit': float('inf'),
'delete': False,
'sdtemplate': None,
})
@@ -674,8 +676,8 @@

def treat(self, page):
"""Treat a page."""
- if self._treat_counter >= self.getOption('total'):
- pywikibot.output('\nNumber of pages reached the total limit. '
+ if self._treat_counter >= self.getOption('limit'):
+ pywikibot.output('\nNumber of pages reached the limit. '
'Script terminated.')
self.stop()
super(RedirectRobot, self).treat(page)
@@ -710,8 +712,6 @@
action = arg
elif option in ('always', 'delete'):
options[option] = True
- elif option == 'total':
- options[option] = gen_options[option] = int(value)
elif option == 'sdtemplate':
options['sdtemplate'] = value or pywikibot.input(
'Which speedy deletion template to use?')
@@ -742,6 +742,13 @@
gen_options[option] = int(value)
elif option in ('page', 'start', 'until'):
gen_options[option] = value
+ elif option in ('limit', 'total'):
+ option['limit'] = gen_options['limit'] = int(value)
+ if option == 'total':
+ issue_deprecation_warning('The usage of "{0}"'.format(arg),
+ '-limit', 2,
+ ArgumentDeprecationWarning,
+ since='20190120')
else:
pywikibot.output('Unknown argument: ' + arg)

diff --git a/scripts/unusedfiles.py b/scripts/unusedfiles.py
index d5599da..0d35d55 100755
--- a/scripts/unusedfiles.py
+++ b/scripts/unusedfiles.py
@@ -7,15 +7,15 @@

-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
+-limit Specify number of pages to work on with "-limit:n" where
n is the maximum number of articles to work on.
If not used, all pages are used.
"""
#
# (C) Leonardo Gregianin, 2007
# (C) Filnik, 2008
-# (c) xqt, 2011-2018
-# (C) Pywikibot team, 2013-2018
+# (c) xqt, 2011-2019
+# (C) Pywikibot team, 2013-2019
#
# Distributed under the terms of the MIT license.
#
@@ -24,6 +24,8 @@
import pywikibot
from pywikibot import i18n, pagegenerators
from pywikibot.bot import SingleSiteBot, AutomaticTWSummaryBot, ExistingPageBot
+from pywikibot.exceptions import ArgumentDeprecationWarning
+from pywikibot.tools import issue_deprecation_warning

template_to_the_image = {
'meta': '{{Orphan file}}',
@@ -114,8 +116,13 @@

for arg in local_args:
arg, sep, value = arg.partition(':')
- if arg == '-total':
+ if arg == '-limit':
total = value
+ elif arg == '-total':
+ total = value
+ issue_deprecation_warning('The usage of "{0}"'.format(arg),
+ '-limit', 2, ArgumentDeprecationWarning,
+ since='20190120')
else:
options[arg[1:]] = True


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

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I56b04c265e0b62875c338e319b07f71cc5f88f0d
Gerrit-Change-Number: 484007
Gerrit-PatchSet: 18
Gerrit-Owner: Zoranzoki21 <zorandori4444@gmail.com>
Gerrit-Reviewer: D3r1ck01 <alangiderick@gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa@seznam.cz>
Gerrit-Reviewer: John Vandenberg <jayvdb@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444@gmail.com>
Gerrit-Reviewer: jenkins-bot (75)