jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/500712 )
Change subject: Revert "[feat] Allow i18n.translate fallback to wikibase item"
......................................................................
Revert "[feat] Allow i18n.translate fallback to wikibase item"
This reverts commit 2529e6a592fe36f79c88f222674542c4ffa2b55c
made by mistake. btw all travis tests are failing with that patch
Change-Id: I746b54f42dafc3e03b2662655ef12bddc9cf4af2
---
M pywikibot/i18n.py
M tests/i18n_tests.py
2 files changed, 9 insertions(+), 33 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py
index bff1416..4000a51 100644
--- a/pywikibot/i18n.py
+++ b/pywikibot/i18n.py
@@ -43,8 +43,7 @@
from pywikibot.exceptions import Error
from pywikibot.plural import plural_rules
from pywikibot.tools import (
- deprecated, deprecated_args, issue_deprecation_warning, StringTypes,
- UnicodeType)
+ deprecated, deprecated_args, issue_deprecation_warning, StringTypes)
PLURAL_PATTERN = r'{{PLURAL:(?:%\()?([^\)]*?)(?:\)d)?\|(.*?)}}'
@@ -584,9 +583,8 @@
@param parameters: For passing (plural) parameters
@type parameters: dict, string, unicode, int
@param fallback: Try an alternate language code. If it's iterable it'll
- also try those entries and choose the first match. If it's wikibase
- item, it'll try to load local page title from here.
- @type fallback: bool, iterable or str
+ also try those entries and choose the first match.
+ @type fallback: boolean or iterable
@raise IndexError: If the language supports and requires more plurals than
defined for the given translation template.
"""
@@ -612,7 +610,7 @@
codes = [code]
if fallback is True:
codes += _altlang(code) + ['_default', 'en']
- elif fallback is not False and not isinstance(fallback, UnicodeType):
+ elif fallback is not False:
codes += list(fallback)
for code in codes:
if code in xdict:
@@ -620,17 +618,11 @@
break
else:
if fallback is not True:
- if isinstance(fallback, UnicodeType):
- r_page = pywikibot.Site(code, family).page_from_repository(
- fallback)
- trans = r_page.title()
- else:
- # this shouldn't simply return "any one" code
- # but when fallback was True before 65518573d2b0,
- # it did just that. When False it did just return
- # None. It's now also returning None in the new
- # iterable mode.
- return
+ # this shouldn't simply return "any one" code but when fallback
+ # was True before 65518573d2b0, it did just that. When False it
+ # did just return None. It's now also returning None in the new
+ # iterable mode.
+ return
code = list(xdict.keys())[0]
trans = xdict[code]
if trans is None:
diff --git a/tests/i18n_tests.py b/tests/i18n_tests.py
index 6d5396f..3b700fe 100644
--- a/tests/i18n_tests.py
+++ b/tests/i18n_tests.py
@@ -87,22 +87,6 @@
'test-no-english JA')
-class TestTranslateNonDry(TestCase):
-
- """Test translate method."""
-
- family = 'wikipedia'
- code = 'cs'
-
- msg_localized = {'en': 'Universe', 'de': 'Universum'}
-
- def testWikibaseFallback(self):
- """Test Wikibase item fallback."""
- self.assertEqual(i18n.translate(self.code, self.msg_localized,
- fallback='Q1'),
- 'Vesmír')
-
-
class UserInterfaceLangTestCase(TestCase):
"""Base class for tests using config.userinterface_lang."""
--
To view, visit https://gerrit.wikimedia.org/r/500712
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I746b54f42dafc3e03b2662655ef12bddc9cf4af2
Gerrit-Change-Number: 500712
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/498714 )
Change subject: [feat] Allow i18n.translate fallback to wikibase item
......................................................................
[feat] Allow i18n.translate fallback to wikibase item
Bug: T173103
Bug: T218467
Change-Id: Ib1867c75643bfa7275a137d3f893bb3f91c35780
---
M pywikibot/i18n.py
M tests/i18n_tests.py
2 files changed, 33 insertions(+), 9 deletions(-)
Approvals:
D3r1ck01: Looks good to me, but someone else must approve
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py
index 4000a51..bff1416 100644
--- a/pywikibot/i18n.py
+++ b/pywikibot/i18n.py
@@ -43,7 +43,8 @@
from pywikibot.exceptions import Error
from pywikibot.plural import plural_rules
from pywikibot.tools import (
- deprecated, deprecated_args, issue_deprecation_warning, StringTypes)
+ deprecated, deprecated_args, issue_deprecation_warning, StringTypes,
+ UnicodeType)
PLURAL_PATTERN = r'{{PLURAL:(?:%\()?([^\)]*?)(?:\)d)?\|(.*?)}}'
@@ -583,8 +584,9 @@
@param parameters: For passing (plural) parameters
@type parameters: dict, string, unicode, int
@param fallback: Try an alternate language code. If it's iterable it'll
- also try those entries and choose the first match.
- @type fallback: boolean or iterable
+ also try those entries and choose the first match. If it's wikibase
+ item, it'll try to load local page title from here.
+ @type fallback: bool, iterable or str
@raise IndexError: If the language supports and requires more plurals than
defined for the given translation template.
"""
@@ -610,7 +612,7 @@
codes = [code]
if fallback is True:
codes += _altlang(code) + ['_default', 'en']
- elif fallback is not False:
+ elif fallback is not False and not isinstance(fallback, UnicodeType):
codes += list(fallback)
for code in codes:
if code in xdict:
@@ -618,11 +620,17 @@
break
else:
if fallback is not True:
- # this shouldn't simply return "any one" code but when fallback
- # was True before 65518573d2b0, it did just that. When False it
- # did just return None. It's now also returning None in the new
- # iterable mode.
- return
+ if isinstance(fallback, UnicodeType):
+ r_page = pywikibot.Site(code, family).page_from_repository(
+ fallback)
+ trans = r_page.title()
+ else:
+ # this shouldn't simply return "any one" code
+ # but when fallback was True before 65518573d2b0,
+ # it did just that. When False it did just return
+ # None. It's now also returning None in the new
+ # iterable mode.
+ return
code = list(xdict.keys())[0]
trans = xdict[code]
if trans is None:
diff --git a/tests/i18n_tests.py b/tests/i18n_tests.py
index 3b700fe..6d5396f 100644
--- a/tests/i18n_tests.py
+++ b/tests/i18n_tests.py
@@ -87,6 +87,22 @@
'test-no-english JA')
+class TestTranslateNonDry(TestCase):
+
+ """Test translate method."""
+
+ family = 'wikipedia'
+ code = 'cs'
+
+ msg_localized = {'en': 'Universe', 'de': 'Universum'}
+
+ def testWikibaseFallback(self):
+ """Test Wikibase item fallback."""
+ self.assertEqual(i18n.translate(self.code, self.msg_localized,
+ fallback='Q1'),
+ 'Vesmír')
+
+
class UserInterfaceLangTestCase(TestCase):
"""Base class for tests using config.userinterface_lang."""
--
To view, visit https://gerrit.wikimedia.org/r/498714
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib1867c75643bfa7275a137d3f893bb3f91c35780
Gerrit-Change-Number: 498714
Gerrit-PatchSet: 15
Gerrit-Owner: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/500441 )
Change subject: [cleanup] use page_namespaces as a set instead a list
......................................................................
[cleanup] use page_namespaces as a set instead a list
Change-Id: I08733690a8d56e89d2e5dbffab4303e62fc604ab
---
M tests/aspects.py
1 file changed, 5 insertions(+), 5 deletions(-)
Approvals:
Dvorapa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/aspects.py b/tests/aspects.py
index 79af4f8..71f14e6 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -249,14 +249,14 @@
else:
assert isinstance(namespaces, set)
- page_namespaces = [page.namespace() for page in gen]
+ page_namespaces = {page.namespace() for page in gen}
- if skip and set(page_namespaces) != namespaces:
+ if skip and page_namespaces != namespaces:
raise unittest.SkipTest('Pages in namespaces {!r} not found.'
- .format(list(namespaces
- - set(page_namespaces))))
+ .format(
+ list(namespaces - page_namespaces)))
else:
- self.assertEqual(set(page_namespaces), namespaces)
+ self.assertEqual(page_namespaces, namespaces)
def assertPageTitlesEqual(self, gen, titles, site=None):
"""
--
To view, visit https://gerrit.wikimedia.org/r/500441
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I08733690a8d56e89d2e5dbffab4303e62fc604ab
Gerrit-Change-Number: 500441
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/500394 )
Change subject: [bugfix] Use a new file for tests
......................................................................
[bugfix] Use a new file for tests
The old file "File:Băieţi de Cartier - La Familia cover.jpg"
has been deleted. Use a new file which has a redirect.
Bug: T219752
Change-Id: Idc44028baeaac1741a97cc1b1f72c4cf998bab29
---
M tests/site_tests.py
1 file changed, 4 insertions(+), 6 deletions(-)
Approvals:
Dvorapa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/site_tests.py b/tests/site_tests.py
index 540db79..b090ccf 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -2684,9 +2684,7 @@
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.page = pywikibot.Page(self.site, 'File:BoA – Woman.png')
self.backlinks = list(self.page.backlinks(follow_redirects=False,
filter_redirects=True,
total=5))
@@ -2715,11 +2713,11 @@
def test_backlinks_redirects_pageid(self):
"""Test backlinks redirects pageid."""
for page in self.backlinks:
- self.assertEqual(page.pageid, 45341783)
+ self.assertEqual(page.pageid, 58874049)
for page in self.references:
- self.assertEqual(page.pageid, 45341783)
+ self.assertEqual(page.pageid, 58874049)
for page in self.nofollow:
- self.assertEqual(page.pageid, 45341783)
+ self.assertEqual(page.pageid, 58874049)
class TestCommonsSite(TestCase):
--
To view, visit https://gerrit.wikimedia.org/r/500394
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Idc44028baeaac1741a97cc1b1f72c4cf998bab29
Gerrit-Change-Number: 500394
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)