jenkins-bot has submitted this change and it was merged.
Change subject: remove the 'pageTitle' mechanism in several scripts
......................................................................
remove the 'pageTitle' mechanism in several scripts
- basic.py
- blockreview.py (not working, actually)
- cosmetic_changes.py
- noreferences.py
(split out from Iae38e6ba582e5e65f38290d34d3048cf1442c383)
- touch.py
- weblinkchecker.py (also fixed a typo)
per I3d0c64bd0f4aac2a2c3cf375d84e77cb364868ad
Change-Id: Ic5983b64cbc0cd96c98c105574ccb1db6dbaf9a6
---
M scripts/basic.py
M scripts/blockreview.py
M scripts/cosmetic_changes.py
M scripts/noreferences.py
M scripts/touch.py
M scripts/weblinkchecker.py
6 files changed, 18 insertions(+), 74 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/basic.py b/scripts/basic.py
index 6850dc7..7a8c6c5 100755
--- a/scripts/basic.py
+++ b/scripts/basic.py
@@ -14,8 +14,6 @@
-dry If given, doesn't do any real changes, but only shows
what would have been changed.
-All other parameters will be regarded as part of the title of a single page,
-and the bot will only work on that single page.
"""
#
# (C) Pywikibot team, 2006-2014
@@ -150,9 +148,6 @@
genFactory = pagegenerators.GeneratorFactory()
# The generator gives the pages that should be worked upon.
gen = None
- # This temporary array is used to read the page title if one single
- # page to work on is specified by the arguments.
- pageTitleParts = []
# If dry is True, doesn't do any real changes, but only show
# what would have been changed.
dry = False
@@ -162,17 +157,9 @@
if arg.startswith("-dry"):
dry = True
else:
- # check if a standard argument like
- # -start:XYZ or -ref:Asdf was given.
- if not genFactory.handleArg(arg):
- pageTitleParts.append(arg)
+ genFactory.handleArg(arg)
site.login()
- if pageTitleParts != []:
- # We will only work on a single page.
- pageTitle = ' '.join(pageTitleParts)
- page = pywikibot.Page(pywikibot.Link(pageTitle, site))
- gen = iter([page])
if not gen:
gen = genFactory.getCombinedGenerator()
diff --git a/scripts/blockreview.py b/scripts/blockreview.py
index 6dac7b1..72fc62c 100644
--- a/scripts/blockreview.py
+++ b/scripts/blockreview.py
@@ -11,11 +11,10 @@
-
-All other parameters will be regarded as part of the title of a single page,
-and the bot will only work on that single page.
"""
#
# (C) xqt, 2010-2014
+# (C) Pywikibot team, 2014
#
# Distributed under the terms of the MIT license.
#
diff --git a/scripts/cosmetic_changes.py b/scripts/cosmetic_changes.py
index 34a2d4f..90edde5 100755
--- a/scripts/cosmetic_changes.py
+++ b/scripts/cosmetic_changes.py
@@ -18,9 +18,6 @@
the predefined message texts with original and replacements
inserted.
-All other parameters will be regarded as part of the title of a single page,
-and the bot will only work on that single page.
-
&warning;
For regular use, it is recommended to put this line into your user-config.py:
@@ -887,9 +884,6 @@
def main():
- #page generator
- gen = None
- pageTitle = []
answer = 'y'
options = {}
@@ -904,8 +898,8 @@
options['always'] = True
elif arg == '-async':
options['async'] = True
- elif not genFactory.handleArg(arg):
- pageTitle.append(arg)
+ else:
+ genFactory.handleArg(arg)
site = pywikibot.Site()
site.login()
@@ -914,13 +908,9 @@
# Load default summary message.
options['comment'] = i18n.twtranslate(site,
'cosmetic_changes-standalone')
- if pageTitle:
- gen = iter([pywikibot.Page(pywikibot.Link(t, site)) for t in pageTitle])
- if not gen:
- gen = genFactory.getCombinedGenerator()
- if not gen:
- pywikibot.showHelp()
- else:
+
+ gen = genFactory.getCombinedGenerator()
+ if gen:
if not options.get('always'):
answer = pywikibot.inputChoice(
warning + '\nDo you really want to continue?',
@@ -929,6 +919,8 @@
preloadingGen = pagegenerators.PreloadingGenerator(gen)
bot = CosmeticChangesBot(preloadingGen, **options)
bot.run()
+ else:
+ pywikibot.showHelp()
if __name__ == "__main__":
try:
diff --git a/scripts/noreferences.py b/scripts/noreferences.py
index 57b7f8e..af9fbce 100755
--- a/scripts/noreferences.py
+++ b/scripts/noreferences.py
@@ -24,9 +24,6 @@
-quiet Use this option to get less output
-All other parameters will be regarded as part of the title of a single page,
-and the bot will only work on that single page.
-
If neither a page title nor a page generator is given, it takes all pages from
the default maintenance category.
@@ -689,9 +686,6 @@
def main():
# page generator
gen = None
- # This temporary array is used to read the page title if one single
- # page to work on is specified by the arguments.
- pageTitle = []
# Which namespaces should be processed?
# default to [] which means all namespaces will be processed
namespaces = []
@@ -721,12 +715,8 @@
elif arg == '-quiet':
verbose = False
else:
- if not genFactory.handleArg(arg):
- pageTitle.append(arg)
+ genFactory.handleArg(arg)
- if pageTitle:
- page = pywikibot.Page(pywikibot.Site(), ' '.join(pageTitle))
- gen = iter([page])
if not gen:
gen = genFactory.getCombinedGenerator()
if not gen:
diff --git a/scripts/touch.py b/scripts/touch.py
index 44bb153..7c22a86 100755
--- a/scripts/touch.py
+++ b/scripts/touch.py
@@ -14,9 +14,6 @@
-redir specifies that the bot should work on redirect pages;
otherwise, they will be skipped.
-
-All other parameters will be regarded as a page title; in this case, the bot
-will only touch a single page.
"""
#
# (C) Pywikibot team, 2009-2014
@@ -73,10 +70,6 @@
def main(*args):
gen = None
options = {}
- # If the user chooses to work on a single page, this temporary array is
- # used to read the words from the page title. The words will later be
- # joined with spaces to retrieve the full title.
- pageTitle = []
# Process global args and prepare generator args parser
local_args = pywikibot.handleArgs(*args)
@@ -87,21 +80,14 @@
continue
if arg.startswith("-"):
options[arg[1:].lower()] = True
- else:
- pageTitle.append(arg)
pywikibot.Site().login()
gen = genFactory.getCombinedGenerator()
- if not gen:
- if pageTitle:
- # work on a single page
- page = pywikibot.Page(pywikibot.Link(' '.join(pageTitle)))
- gen = iter([page])
- else:
- pywikibot.showHelp()
- return
- preloadingGen = pagegenerators.PreloadingGenerator(gen)
- bot = TouchBot(preloadingGen, **options)
- bot.run()
+ if gen:
+ preloadingGen = pagegenerators.PreloadingGenerator(gen)
+ bot = TouchBot(preloadingGen, **options)
+ bot.run()
+ else:
+ pywikibot.showHelp()
if __name__ == "__main__":
diff --git a/scripts/weblinkchecker.py b/scripts/weblinkchecker.py
index d69c4a7..cf50a5f 100644
--- a/scripts/weblinkchecker.py
+++ b/scripts/weblinkchecker.py
@@ -54,9 +54,6 @@
-day the first time found dead link longer than x day ago, it should
probably be fixed or removed. if no set, default is 7 day.
-All other parameters will be regarded as part of the title of a single page,
-and the bot will only work on that single page.
-
The following config variables are supported:
max_external_links - The maximum number of web pages that should be
@@ -121,7 +118,7 @@
}
ignorelist = [
- # Officialy reserved for testing, documentation, etc. in
+ # Officially reserved for testing, documentation, etc. in
#
https://tools.ietf.org/html/rfc2606#page-2
# top-level domains:
re.compile('.*[\./(a)]test(/.*)?'))?'),
@@ -801,7 +798,6 @@
def main():
gen = None
- singlePageTitle = []
xmlFilename = None
# Which namespaces should be processed?
# default to [] which means all namespaces will be processed
@@ -841,13 +837,7 @@
else:
xmlFilename = arg[5:]
else:
- if not genFactory.handleArg(arg):
- singlePageTitle.append(arg)
-
- if singlePageTitle:
- singlePageTitle = ' '.join(singlePageTitle)
- page = pywikibot.Page(pywikibot.Site(), singlePageTitle)
- gen = iter([page])
+ genFactory.handleArg(arg)
if xmlFilename:
try:
--
To view, visit
https://gerrit.wikimedia.org/r/147893
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic5983b64cbc0cd96c98c105574ccb1db6dbaf9a6
Gerrit-PatchSet: 6
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>