jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/433981 )
Change subject: [bugfix] Don't fail when there is no parameter in doc template
......................................................................
[bugfix] Don't fail when there is no parameter in doc template
Change-Id: I71a166a8cd3d4e9b2b47f39d7f60a6efd8583935
---
M scripts/category.py
1 file changed, 4 insertions(+), 3 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/category.py b/scripts/category.py
index b12b6ba..cf5c209 100755
--- a/scripts/category.py
+++ b/scripts/category.py
@@ -255,9 +255,10 @@
tmpl = [tmpl]
if tmpl != []:
templates = page.templatesWithParams()
- for template in templates:
- if template[0].title(withNamespace=False).lower() in tmpl:
- doc_page = pywikibot.Page(page.site, template[1])
+ for template, params in templates:
+ if (template.title(withNamespace=False).lower() in tmpl
+ and params):
+ doc_page = pywikibot.Page(page.site, params[0])
if doc_page.exists():
page = doc_page
includeonly = ['includeonly']
--
To view, visit https://gerrit.wikimedia.org/r/433981
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I71a166a8cd3d4e9b2b47f39d7f60a6efd8583935
Gerrit-Change-Number: 433981
Gerrit-PatchSet: 2
Gerrit-Owner: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
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/433520 )
Change subject: [IMPR] Use a set as default container
......................................................................
[IMPR] Use a set as default container
A set is the the appropriate implemetation of a container holding all
seen items instead using a dict with it's key and unused value.
Don't care about 2 nanoseconds which is lower than the function overhead!
Change-Id: I7edc8205a017448a5a1ab51cce8c2c90174e48da
---
M pywikibot/tools/__init__.py
1 file changed, 6 insertions(+), 6 deletions(-)
Approvals:
Zhuyifei1999: Looks good to me, but someone else must approve
Framawiki: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index 6ef05c5..08677a9 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -843,14 +843,14 @@
"""
Yield unique items from an iterable, omitting duplicates.
- By default, to provide uniqueness, it puts the generated items into
- the keys of a dict created as a local variable, each with a value of True.
- It only yields items which are not already present in the local dict.
+ By default, to provide uniqueness, it puts the generated items into a
+ set created as a local variable. It only yields items which are not
+ already present in the local set.
For large collections, this is not memory efficient, as a strong reference
- to every item is kept in a local dict which can not be cleared.
+ to every item is kept in a local set which can not be cleared.
- Also, the local dict cant be re-used when chaining unique operations on
+ Also, the local set can't be re-used when chaining unique operations on
multiple generators.
To avoid these issues, it is advisable for the caller to provide their own
@@ -876,7 +876,7 @@
@type add: callable
"""
if container is None:
- container = {}
+ container = set()
if not add:
if hasattr(container, 'add'):
--
To view, visit https://gerrit.wikimedia.org/r/433520
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I7edc8205a017448a5a1ab51cce8c2c90174e48da
Gerrit-Change-Number: 433520
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999(a)gmail.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/432767 )
Change subject: [bugfix] Solve wrong redirect status found for redirect filter in backlinks
......................................................................
[bugfix] Solve wrong redirect status found for redirect filter in backlinks
- imageinfo property is always appended to the request parameter. If the
query result is only one page the imageinfo will cause a query continue and
the batch might not be completed if there are more than 1 file histories
but there are no other infos of the page like page info property. This
gives unexpected results as long as the imageinfo api generator result is
not handled properly.
- for a quick bugfix just increase "iilimit" to max and load all imageinfo
at once.
- Test for the related phab task added.
Bug: T194233
Change-Id: I6a38f1d57165b1fc3e089b11780669054e2c1788
---
M pywikibot/data/api.py
M tests/site_tests.py
2 files changed, 51 insertions(+), 0 deletions(-)
Approvals:
JJMC89: Looks good to me, but someone else must approve
Framawiki: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index d956df9..62bef1e 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -2921,6 +2921,7 @@
if not ('inprop' in parameters and 'protection' in parameters['inprop']):
appendParams(parameters, 'inprop', 'protection')
appendParams(parameters, 'iiprop', 'timestamp|user|comment|url|size|sha1|metadata')
+ appendParams(parameters, 'iilimit', 'max') # T194233
parameters['generator'] = generator
QueryGenerator.__init__(self, **kwargs)
self.resultkey = "pages" # element to look for in result
diff --git a/tests/site_tests.py b/tests/site_tests.py
index 62ff953..3a8be4b 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -2581,6 +2581,56 @@
for rev in mainpage._revisions.values()))
+class TestBacklinks(TestCase):
+
+ """Test for backlinks (issue T194233)."""
+
+ family = 'wikipedia'
+ code = 'en'
+
+ cached = True
+
+ def setUp(self):
+ """Setup tests."""
+ super(TestBacklinks, self).setUp()
+ self.page = pywikibot.Page(
+ self.site,
+ 'File:Băieţi de Cartier - La Familia cover.jpg')
+ self.backlinks = list(self.page.backlinks(followRedirects=False,
+ filterRedirects=True,
+ total=5))
+ self.references = list(self.page.getReferences(follow_redirects=True,
+ redirectsOnly=True,
+ total=5))
+ self.nofollow = list(self.page.getReferences(follow_redirects=False,
+ redirectsOnly=True,
+ total=5))
+
+ def test_backlinks_redirects_length(self):
+ """Test backlinks redirects lenght."""
+ self.assertEqual(len(self.backlinks), 1)
+ self.assertEqual(len(self.references), 1)
+ self.assertEqual(len(self.nofollow), 1)
+
+ def test_backlinks_redirects_status(self):
+ """Test backlinks redirects statur."""
+ for page in self.backlinks:
+ self.assertTrue(page.isRedirectPage())
+ for page in self.references:
+ self.assertTrue(page.isRedirectPage())
+ for page in self.nofollow:
+ self.assertTrue(page.isRedirectPage())
+
+ def test_backlinks_redirects_pageid(self):
+ """Test backlinks redirects pageid."""
+ for page in self.backlinks:
+ self.assertEqual(page.pageid, 45341783)
+ for page in self.references:
+ self.assertEqual(page.pageid, 45341783)
+ for page in self.nofollow:
+ self.assertEqual(page.pageid, 45341783)
+
+
class TestCommonsSite(TestCase):
"""Test cases for Site methods on Commons."""
--
To view, visit https://gerrit.wikimedia.org/r/432767
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I6a38f1d57165b1fc3e089b11780669054e2c1788
Gerrit-Change-Number: 432767
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia(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/433912 )
Change subject: fix typos in the comments of misspelling.py
......................................................................
fix typos in the comments of misspelling.py
Change-Id: I63fd5d28edb4e77ed27affde2758a641593e167a
---
M scripts/misspelling.py
1 file changed, 2 insertions(+), 2 deletions(-)
Approvals:
Zoranzoki21: Looks good to me, but someone else must approve
Dvorapa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/misspelling.py b/scripts/misspelling.py
index d86635a..d832c40 100755
--- a/scripts/misspelling.py
+++ b/scripts/misspelling.py
@@ -133,10 +133,10 @@
templates = (templates, )
for template, params in disambPage.templatesWithParams():
if template.title(withNamespace=False) in templates:
- # The correct spelling is in the last paramter.
+ # The correct spelling is in the last parameter.
correctSpelling = params[-1]
# On de.wikipedia, there are some cases where the
- # misspelling is ambigous, see for example:
+ # misspelling is ambiguous, see for example:
# https://de.wikipedia.org/wiki/Buthan
for match in self.linkR.finditer(correctSpelling):
self.alternatives.append(match.group('title'))
--
To view, visit https://gerrit.wikimedia.org/r/433912
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I63fd5d28edb4e77ed27affde2758a641593e167a
Gerrit-Change-Number: 433912
Gerrit-PatchSet: 1
Gerrit-Owner: PeterTheOne <petertheone(a)gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Welcome, new contributor! <ssethi(a)wikimedia.org>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>