jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/404904 )
Change subject: texlib.py: Revert 097245e7e347, improve docstirngs and variable names
......................................................................
texlib.py: Revert 097245e7e347, improve docstirngs and variable names
- improve docstrings
replaceLanguageLinks:
- Revert 097245e7e347. It's not needed anymore because after
9c1ed96db3f05ecf0ce700edfd13eda4bb7ba128 the trailing whitespace is
ignored by userPut method.
replaceCategoryLinks:
- Rename s to new_cats. It's a string containing new categories.
- Rename s2 to cats_removed_text. It's the result of calling
removeCategoryLinksAndSeparator on oldtext.
Bug: T184886
Change-Id: I652d852aff968374c9f00025dbc55255602e3180
---
M pywikibot/textlib.py
1 file changed, 75 insertions(+), 40 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index 92dae16..4ced2bc 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -879,10 +879,16 @@
"""Return text with all inter-language links removed.
If a link to an unknown language is encountered, a warning is printed.
- If a marker is defined, that string is placed at the location of the
- last occurrence of an interwiki link (at the end if there are no
- interwiki links).
+ @param text: The text that needs to be modified.
+ @type text: str
+ @param site: The site that the text is coming from.
+ @type site: pywikibot.Site
+ @param marker: If defined, marker is placed after the the last language
+ link, or at the end of text if there are no language links.
+ @type marker: str
+ @return: The modified text.
+ @rtype: str
"""
if site is None:
site = pywikibot.Site()
@@ -906,10 +912,19 @@
Return text with inter-language links and preceding separators removed.
If a link to an unknown language is encountered, a warning is printed.
- If a marker is defined, that string is placed at the location of the
- last occurrence of an interwiki link (at the end if there are no
- interwiki links).
+ @param text: The text that needs to be modified.
+ @type text: str
+ @param site: The site that the text is coming from.
+ @type site: pywikibot.Site
+ @param marker: If defined, marker is placed after the the last interwiki
+ link, or at the end of text if there are no interwiki links.
+ @type marker: str
+ @param separator: The separator string that will be removed if is followed
+ by the language links.
+ @type separator: str
+ @return: The modified text
+ @rtype: str
"""
if separator:
mymarker = findmarker(text, u'@L@')
@@ -924,9 +939,24 @@
template=False, template_subpage=False):
"""Replace inter-language links in the text with a new set of links.
- 'new' should be a dict with the Site objects as keys, and Page or Link
- objects as values (i.e., just like the dict returned by getLanguageLinks
- function).
+ @param oldtext: The text that needs to be modified.
+ @type oldtext: str
+ @param new: A dict with the Site objects as keys, and Page or Link objects
+ as values (i.e., just like the dict returned by getLanguageLinks
+ function).
+ @type new: dict
+ @param site: The site that the text is from.
+ @type site: pywikibot.Site
+ @param addOnly: If True, do not remove old language links, only add new
+ ones.
+ @type addOnly: bool
+ @param template: Indicates if text belongs to a template page or not.
+ @type template: bool
+ @param template_subpage: Indicates if text belongs to a template sub-page
+ or not.
+ @type template_subpage: bool
+ @return The modified text.
+ @rtype str
"""
# Find a marker that is not already in the text.
marker = findmarker(oldtext)
@@ -936,9 +966,6 @@
cseparator = site.family.category_text_separator
separatorstripped = separator.strip()
cseparatorstripped = cseparator.strip()
- do_not_strip = oldtext.strip() != oldtext
- if do_not_strip:
- issue_deprecation_warning('Using unstripped text', 'stripped text', 2)
if addOnly:
s2 = oldtext
else:
@@ -1006,7 +1033,7 @@
newtext = s2.replace(marker, '').strip() + separator + s
else:
newtext = s2.replace(marker, '')
- return newtext if do_not_strip else newtext.strip()
+ return newtext
def interwikiFormat(links, insite=None):
@@ -1221,10 +1248,17 @@
Replace all existing category links with new category links.
@param oldtext: The text that needs to be replaced.
+ @type oldtext: str
@param new: Should be a list of Category objects or strings
which can be either the raw name or [[Category:..]].
+ @type new: iterable
+ @param site: The site that the text is from.
+ @type site: pywikibot.Site
@param addOnly: If addOnly is True, the old category won't be deleted and the
category(s) given will be added (and so they won't replace anything).
+ @type addOnly: bool
+ @return: The modified text.
+ @rtype: str
"""
# Find a marker that is not already in the text.
marker = findmarker(oldtext)
@@ -1242,52 +1276,53 @@
separatorstripped = separator.strip()
iseparatorstripped = iseparator.strip()
if addOnly:
- s2 = oldtext
+ cats_removed_text = oldtext
else:
- s2 = removeCategoryLinksAndSeparator(oldtext, site=site, marker=marker,
- separator=separatorstripped)
- s = categoryFormat(new, insite=site)
- if s:
+ cats_removed_text = removeCategoryLinksAndSeparator(
+ oldtext, site=site, marker=marker, separator=separatorstripped)
+ new_cats = categoryFormat(new, insite=site)
+ if new_cats:
if site.code in site.family.category_attop:
- newtext = s + separator + s2
+ newtext = new_cats + separator + cats_removed_text
else:
# calculate what was after the categories links on the page
- firstafter = s2.find(marker)
+ firstafter = cats_removed_text.find(marker)
if firstafter < 0:
- firstafter = len(s2)
+ firstafter = len(cats_removed_text)
else:
firstafter += len(marker)
# Is there text in the 'after' part that means we should keep it
# after?
- if "</noinclude>" in s2[firstafter:]:
+ if '</noinclude>' in cats_removed_text[firstafter:]:
if separatorstripped:
- s = separator + s
- newtext = (s2[:firstafter].replace(marker, '') +
- s +
- s2[firstafter:])
+ new_cats = separator + new_cats
+ newtext = (cats_removed_text[:firstafter].replace(marker, '')
+ + new_cats + cats_removed_text[firstafter:])
elif site.code in site.family.categories_last:
- newtext = s2.replace(marker, '').strip() + separator + s
+ newtext = (cats_removed_text.replace(marker, '').strip()
+ + separator + new_cats)
else:
- interwiki = getLanguageLinks(s2, insite=site)
- s2 = removeLanguageLinksAndSeparator(s2.replace(marker, ''),
- site, '',
- iseparatorstripped
- ) + separator + s
- newtext = replaceLanguageLinks(s2, interwiki, site=site,
- addOnly=True)
+ interwiki = getLanguageLinks(cats_removed_text, insite=site)
+ langs_removed_text = removeLanguageLinksAndSeparator(
+ cats_removed_text.replace(marker, ''), site, '',
+ iseparatorstripped) + separator + new_cats
+ newtext = replaceLanguageLinks(
+ langs_removed_text, interwiki, site, addOnly=True)
else:
- newtext = s2.replace(marker, '')
+ newtext = cats_removed_text.replace(marker, '')
return newtext.strip()
def categoryFormat(categories, insite=None):
"""Return a string containing links to all categories in a list.
- 'categories' should be a list of Category or Page objects or strings
- which can be either the raw name, [[Category:..]] or [[cat_localised_ns:...]].
-
- The string is formatted for inclusion in insite.
- Category namespace is converted to localised namespace.
+ @param categories: A list of Category or Page objects or strings which can
+ be either the raw name, [[Category:..]] or [[cat_localised_ns:...]].
+ @type categories: iterable
+ @param insite: Used to to localise the category namespace.
+ @type insite: pywikibot.Site
+ @return: String of categories
+ @rtype: str
"""
if not categories:
return ''
--
To view, visit https://gerrit.wikimedia.org/r/404904
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I652d852aff968374c9f00025dbc55255602e3180
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/404637 )
Change subject: [doc] Show pagegenerators options with -help
......................................................................
[doc] Show pagegenerators options with -help
- also remove unused NL constant
Change-Id: I384098245993581653758fd2fe11150063774201
---
M scripts/imagecopy.py
1 file changed, 7 insertions(+), 3 deletions(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/imagecopy.py b/scripts/imagecopy.py
index 6c8a731..c37fb0d 100644
--- a/scripts/imagecopy.py
+++ b/scripts/imagecopy.py
@@ -19,6 +19,8 @@
Command line options:
+¶ms;
+
-always Skip the GUI validation
-setcat: Set the category of the copied image
@@ -51,9 +53,7 @@
python pwb.py imagecopy.py -page:Image:<imagename> -delete
-See pagegenerators.py for more ways to get a list of images.
By default the bot works on your home wiki (set in user-config)
-
"""
# Based on upload.py by:
# (C) Rob W.W. Hooft, Andre Engels 2003-2007
@@ -93,7 +93,11 @@
Tkinter = _tk_error
Tkdialog = object
-NL = ''
+# This is required for the text that is shown when you run this script
+# with the parameter -help.
+docuReplacements = {
+ '¶ms;': pagegenerators.parameterHelp
+}
nowCommonsTemplate = {
'_default': u'{{NowCommons|%s}}',
--
To view, visit https://gerrit.wikimedia.org/r/404637
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I384098245993581653758fd2fe11150063774201
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ryan2758 <asd431888066(a)hotmail.com>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/404469 )
Change subject: Declare development status as Production/Stable
......................................................................
Declare development status as Production/Stable
As long as push tag a new release to pypi and create a tag for it
this is always tested by travis and appreyor builds so we can conclude
that the published release is stable (enough).
Change-Id: I0468a12e0fe96290c02b0c1020d1ab8de083c3c1
---
M setup.py
1 file changed, 2 insertions(+), 2 deletions(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/setup.py b/setup.py
index 495d3f2..92063cb 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Installer script for Pywikibot 3.0 framework."""
#
-# (C) Pywikibot team, 2009-2017
+# (C) Pywikibot team, 2009-2018
#
# Distributed under the terms of the MIT license.
#
@@ -266,7 +266,7 @@
test_suite="tests.collector",
tests_require=test_deps,
classifiers=[
- 'Development Status :: 4 - Beta',
+ 'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
--
To view, visit https://gerrit.wikimedia.org/r/404469
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0468a12e0fe96290c02b0c1020d1ab8de083c3c1
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/404618 )
Change subject: Solve -cc conflict in imagecopy
......................................................................
Solve -cc conflict in imagecopy
imagecopy.py did not support its -cc option because it conflicted with
the global option to toggle cosmetic changes
Renamed the local implementation and added option descriptions
Bug: T182522
Change-Id: I2db4e4ffa313ff3cc043658b3ca3d6d436d65a5b
---
M scripts/imagecopy.py
1 file changed, 12 insertions(+), 2 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/scripts/imagecopy.py b/scripts/imagecopy.py
index 7a539b5..6c8a731 100644
--- a/scripts/imagecopy.py
+++ b/scripts/imagecopy.py
@@ -17,6 +17,16 @@
so he can test at: [[de:Benutzer Diskussion:Magnus Manske]]. You can
write him in German and English.
+Command line options:
+
+-always Skip the GUI validation
+
+-setcat: Set the category of the copied image
+
+-delete Delete the image after the image has been transferred. This will
+ only work if the user has sysops privileges, otherwise the image
+ will only be marked for deletion.
+
Examples
Work on a single image::
@@ -494,8 +504,8 @@
for arg in local_args:
if arg == '-always':
always = True
- elif arg.startswith('-cc:'):
- category = arg[len('-cc:'):]
+ elif arg.startswith('-setcat:'):
+ category = arg[len('-setcat:'):]
elif arg == '-delete':
delete_after_done = True
else:
--
To view, visit https://gerrit.wikimedia.org/r/404618
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I2db4e4ffa313ff3cc043658b3ca3d6d436d65a5b
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ryan10145 <chang.ryan10145(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/348233 )
Change subject: Do not exceed API limit of pageids in BaseSite.preloadpages
......................................................................
Do not exceed API limit of pageids in BaseSite.preloadpages
AllpagesGenerator (and possibly others) returns pages with their ids.
When reused in PreloadingGenerator, this generates a warning and
truncates the series of pages to the limit.
Bug: T78333
Bug: T161783
Change-Id: I240b0f998d5ef9c6438338da9572bdde265a3699
---
M pywikibot/site.py
M scripts/category_redirect.py
2 files changed, 10 insertions(+), 4 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
Objections:
Mpaa: There's a problem with this change, please improve
diff --git a/pywikibot/site.py b/pywikibot/site.py
index a16bdea..e5259c0 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -3257,7 +3257,14 @@
next_prio = 0
rvgen = api.PropertyGenerator(props, site=self)
rvgen.set_maximum_items(-1) # suppress use of "rvlimit" parameter
- if len(pageids) == len(sublist):
+
+ parameter = self._paraminfo.parameter('query+info', 'prop')
+ if self.logged_in() and self.has_right('apihighlimits'):
+ max_ids = int(parameter['highlimit'])
+ else:
+ max_ids = int(parameter['limit']) # T78333, T161783
+
+ if len(pageids) == len(sublist) and len(set(pageids)) <= max_ids:
# only use pageids if all pages have them
rvgen.request['pageids'] = set(pageids)
else:
diff --git a/scripts/category_redirect.py b/scripts/category_redirect.py
index 65aae8d..d616d4f 100755
--- a/scripts/category_redirect.py
+++ b/scripts/category_redirect.py
@@ -223,9 +223,8 @@
comment = i18n.twtranslate(self.site, self.redir_comment)
# generator yields all hard redirect pages in namespace 14
- for page in pagegenerators.PreloadingGenerator(
- self.site.allpages(namespace=14, filterredir=True),
- groupsize=250):
+ for page in self.site.allpages(namespace=14, filterredir=True,
+ content=True):
if page.isCategoryRedirect():
# this is already a soft-redirect, so skip it (for now)
continue
--
To view, visit https://gerrit.wikimedia.org/r/348233
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I240b0f998d5ef9c6438338da9572bdde265a3699
Gerrit-PatchSet: 5
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>