jenkins-bot has submitted this change and it was merged.
Change subject: comms/http.py: Pyflakes fixes
......................................................................
comms/http.py: Pyflakes fixes
local variable 'proto' is assigned to but never used
local variable 'host' is assigned to but never used
Change-Id: Ibad5d84dffdd9f555b8d3ef21efce05497952349
---
M pywikibot/comms/http.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py
index 95d0cdc..d383378 100644
--- a/pywikibot/comms/http.py
+++ b/pywikibot/comms/http.py
@@ -152,7 +152,7 @@
else:
proto = site.protocol()
host = site.hostname()
- baseuri = urlparse.urljoin("%(proto)s://%(host)s" % locals(), uri)
+ baseuri = urlparse.urljoin("%s://%s" % (proto, host), uri)
else:
baseuri = uri
--
To view, visit https://gerrit.wikimedia.org/r/151398
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ibad5d84dffdd9f555b8d3ef21efce05497952349
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
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: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Use pywikibot.input instead of raw_input
......................................................................
Use pywikibot.input instead of raw_input
Also removed unused rawtoclean method.
bug: 69060
Change-Id: Ia805687f12fa914a15405085bb854ffe34b05fc1
---
M scripts/makecat.py
1 file changed, 2 insertions(+), 9 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
Mpaa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/makecat.py b/scripts/makecat.py
index 3db5ecf..fe4d372 100644
--- a/scripts/makecat.py
+++ b/scripts/makecat.py
@@ -44,12 +44,6 @@
from pywikibot import date, pagegenerators, i18n
-def rawtoclean(c):
- #Given the 'raw' category, provides the 'clean' category
- c2 = c.title().split('|')[0]
- return pywikibot.Page(mysite, c2)
-
-
def isdate(s):
"""returns true if s is a date or year """
dict, val = date.getAutoFormat(pywikibot.Site().language(), s)
@@ -158,7 +152,7 @@
pywikibot.output(u"a: Add another page")
pywikibot.output(u"l: Give a list of the pages to check")
elif answer == 'a':
- pagetitle = raw_input("Specify page to add:")
+ pagetitle = pywikibot.input("Specify page to add:")
page = pywikibot.Page(pywikibot.Site(), pagetitle)
if page not in checked.keys():
include(page)
@@ -216,11 +210,10 @@
workingcatname.append(arg)
if len(workingcatname) == 0:
- workingcatname = raw_input("Which page to start with? ")
+ workingcatname = pywikibot.input("Which page to start with? ")
else:
workingcatname = ' '.join(workingcatname)
mysite = pywikibot.Site()
- workingcatname = unicode(workingcatname, 'utf-8')
pywikibot.setAction(i18n.twtranslate(mysite, 'makecat-create', {'cat': workingcatname}))
workingcat = pywikibot.Category(mysite,
u'%s:%s'
--
To view, visit https://gerrit.wikimedia.org/r/151375
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia805687f12fa914a15405085bb854ffe34b05fc1
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
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: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
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 <>
jenkins-bot has submitted this change and it was merged.
Change subject: Fix docstring: Pagegenerators doesn't run as script
......................................................................
Fix docstring: Pagegenerators doesn't run as script
Docstring aligned to script behaviour.
Change-Id: Ic4a905bf24aad74d68f61100bdee21f0bb810a60
---
M pywikibot/pagegenerators.py
1 file changed, 2 insertions(+), 3 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py
index b525839..5e855a8 100644
--- a/pywikibot/pagegenerators.py
+++ b/pywikibot/pagegenerators.py
@@ -4,9 +4,8 @@
object that is iterable (see http://legacy.python.org/dev/peps/pep-0255/ ) and
that yields page objects on which other scripts can then work.
-In general, there is no need to run this script directly. It can, however,
-be run for testing purposes. It will then print the page titles to standard
-output.
+Pagegenerators.py cannot be run as script. For testing purposes listpages.py can
+be used instead, to print page titles to standard output.
These parameters are supported to specify which pages titles to print:
--
To view, visit https://gerrit.wikimedia.org/r/151289
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic4a905bf24aad74d68f61100bdee21f0bb810a60
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
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: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Bug 67249: allow filtering of newpages by ns
......................................................................
Bug 67249: allow filtering of newpages by ns
Partial workaround:
If namespace/ns parameters are specified before -newpages, provided
namespace values are used, otherwise default is ns=0.
Same logic applied to RecentChangesPageGenerator to improve efficiency
of the query, if wanted.
Change-Id: I20a4b04bb8f30cd750d43856a89cdf471898f84e
---
M pywikibot/pagegenerators.py
1 file changed, 14 insertions(+), 5 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py
index b525839..fa55fdf 100644
--- a/pywikibot/pagegenerators.py
+++ b/pywikibot/pagegenerators.py
@@ -72,8 +72,12 @@
across all namespaces.
-namespace Filter the page generator to only yield pages in the
--ns specified namespaces. Separate multiple namespace
+-ns specified namespaces. Separate multiple namespace
numbers with commas. Example "-ns:0,2,4"
+ If used with -newpages, -namepace/ns must be provided
+ before -newpages.
+ If used with -recentchanges, efficiency is improved if
+ -namepace/ns is provided before -recentchanges.
-interwiki Work on the given page and all equivalent pages in other
languages. This can, for example, be used to fight
@@ -349,10 +353,11 @@
else:
gen = RandomPageGenerator(total=int(arg[8:]))
elif arg.startswith('-recentchanges'):
+ namespaces = [int(n) for n in self.namespaces] or None
if len(arg) >= 15:
- gen = RecentChangesPageGenerator(total=int(arg[15:]))
+ gen = RecentChangesPageGenerator(namespaces=namespaces, total=int(arg[15:]))
else:
- gen = RecentChangesPageGenerator(total=60)
+ gen = RecentChangesPageGenerator(namespaces=namespaces, total=60)
gen = DuplicateFilterPageGenerator(gen)
elif arg.startswith('-file'):
textfilename = arg[6:]
@@ -470,10 +475,14 @@
u'How many images do you want to load?')
gen = NewimagesPageGenerator(total=int(limit))
elif arg.startswith('-newpages'):
+ # partial workaround for bug 67249
+ # to use -namespace/ns with -newpages, -ns must be given before -newpages
+ # otherwise default namespace is 0
+ namespaces = [int(n) for n in self.namespaces] or 0
if len(arg) >= 10:
- gen = NewpagesPageGenerator(total=int(arg[10:]))
+ gen = NewpagesPageGenerator(namespaces=namespaces, total=int(arg[10:]))
else:
- gen = NewpagesPageGenerator(total=60)
+ gen = NewpagesPageGenerator(namespaces=namespaces, total=60)
elif arg.startswith('-imagesused'):
imagelinkstitle = arg[len('-imagesused:'):]
if not imagelinkstitle:
--
To view, visit https://gerrit.wikimedia.org/r/151307
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I20a4b04bb8f30cd750d43856a89cdf471898f84e
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
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: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Remove categories only containing files
......................................................................
Remove categories only containing files
Also avoid hitting the server twice
Bug: 68705
Change-Id: Idaa1bb7983e6b052e83e258d2b2b588c4385d62c
---
M scripts/category.py
1 file changed, 17 insertions(+), 15 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/category.py b/scripts/category.py
index 72aba3d..7a1c76a 100755
--- a/scripts/category.py
+++ b/scripts/category.py
@@ -649,28 +649,30 @@
{'oldcat': self.cat.title()})
def run(self):
- if self.cat.categoryinfo['pages'] == 0:
- pywikibot.output(u'There are no articles in category %s'
+ empty = True
+ for article in self.cat.articles():
+ empty = False
+ if not self.titleRegex or re.search(self.titleRegex,
+ article.title()):
+ article.change_category(self.cat, None,
+ comment=self.editSummary,
+ inPlace=self.inPlace)
+ if empty:
+ pywikibot.output(u'There are no pages in category %s'
% self.cat.title())
- else:
- for article in self.cat.articles():
- if not self.titleRegex or re.search(self.titleRegex,
- article.title()):
- article.change_category(self.cat, None,
- comment=self.editSummary,
- inPlace=self.inPlace)
if self.pagesonly:
return
# Also removes the category tag from subcategories' pages
- if self.cat.categoryinfo['subcats'] == 0:
+ empty = True
+ for subcategory in self.cat.subcategories():
+ empty = False
+ subcategory.change_category(self.cat, None,
+ comment=self.editSummary,
+ inPlace=self.inPlace)
+ if empty:
pywikibot.output(u'There are no subcategories in category %s'
% self.cat.title())
- else:
- for subcategory in self.cat.subcategories():
- subcategory.change_category(self.cat, None,
- comment=self.editSummary,
- inPlace=self.inPlace)
# Deletes the category page
if self.cat.exists() and self.cat.isEmptyCategory():
if self.useSummaryForDeletion and self.editSummary:
--
To view, visit https://gerrit.wikimedia.org/r/149645
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Idaa1bb7983e6b052e83e258d2b2b588c4385d62c
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
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: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>