jenkins-bot has submitted this change and it was merged.
Change subject: site.loadrevisions():request contentmodel and sha1 from proper MW version
......................................................................
site.loadrevisions():request contentmodel and sha1 from proper MW version
Request contentmodel only from MW >=1.21 and sha1 from MW >= 1.19.
Support for these params has been inserted in such versions.
Change-Id: I4d5384f9ee10a909fa7684181dbac6ac71320982
---
M pywikibot/data/api.py
M pywikibot/site.py
2 files changed, 6 insertions(+), 3 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 8ce923b..c932613 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -3061,8 +3061,6 @@
page._protection[item['type']] = item['level'], item['expiry']
if 'revisions' in pagedict:
# TODO: T102735: Use the page content model for <1.21
- # TODO: Add rvprop 'contentmodel' to all revisions calls, but only
- # on 1.21+ otherwise it causes API warnings
for rev in pagedict['revisions']:
assert 'parentid' in rev, 'parentid missing in revision %r' % rev
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 25dedf7..8199c1f 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -3668,8 +3668,13 @@
rvargs = {'type_arg': 'info|revisions'}
+ rvargs['rvprop'] = ['ids', 'timestamp', 'flags', 'comment', 'user']
+ if MediaWikiVersion(self.version()) >= MediaWikiVersion('1.21'):
+ rvargs['rvprop'].append('contentmodel')
+ if MediaWikiVersion(self.version()) >= MediaWikiVersion('1.19'):
+ rvargs['rvprop'].append('sha1')
if getText:
- rvargs[u"rvprop"] = u"ids|flags|timestamp|user|comment|content|sha1"
+ rvargs['rvprop'].append('content')
if section is not None:
rvargs[u"rvsection"] = unicode(section)
if rollback:
--
To view, visit https://gerrit.wikimedia.org/r/245187
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I4d5384f9ee10a909fa7684181dbac6ac71320982
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: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #3010
Status: Broken
Duration: 41 minutes and 45 seconds
Commit: 7a69fa8 (master)
Author: Fabian Neundorf
Message: [FEAT] i18n: Support specific plural messages
This adds support for translations which use specific plural texts for specific
values.
Bug: T115297
Change-Id: I5372ed4ef3343cbbab1b33efcee0cf707e50ae24
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/94300f86e83b...7a69fa84…
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/85245520
--
You can configure recipients for build notifications in your .travis.yml file. See http://docs.travis-ci.com/user/notifications
Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #3009
Status: Fixed
Duration: 38 minutes and 53 seconds
Commit: 94300f8 (master)
Author: Fabian Neundorf
Message: [IMPROV] i18n: Deprecate list as code in twtranslate
`twtranslate` supports a list as code in order to change it and return the
actually used code. This was only used for `twntranslate` and shouldn't be used
anymore.
Change-Id: I13d45e39ea52d77983fb4e654f8c0772f0263306
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/12a7d5b40357...94300f86…
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/85034155
--
You can configure recipients for build notifications in your .travis.yml file. See http://docs.travis-ci.com/user/notifications
jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] i18n: Deprecate list as code in twtranslate
......................................................................
[IMPROV] i18n: Deprecate list as code in twtranslate
`twtranslate` supports a list as code in order to change it and return the
actually used code. This was only used for `twntranslate` and shouldn't be used
anymore.
Change-Id: I13d45e39ea52d77983fb4e654f8c0772f0263306
---
M pywikibot/i18n.py
1 file changed, 8 insertions(+), 1 deletion(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py
index 58e23fd..3bd9e9e 100644
--- a/pywikibot/i18n.py
+++ b/pywikibot/i18n.py
@@ -33,6 +33,7 @@
import pkgutil
from collections import defaultdict, Mapping
+from warnings import warn
import pywikibot
@@ -554,7 +555,9 @@
... % {'descr': 'seulement'})
'Robot: Changer seulement quelques pages.'
- @param code: The language code
+ @param code: When it's a site it's using the code attribute and otherwise it
+ is using the value directly.
+ @type code: BaseSite or str
@param twtitle: The TranslateWiki string title, in <package>-<key> format
@param parameters: For passing parameters. It should be a mapping but for
backwards compatibility can also be a list, tuple or a single value.
@@ -583,6 +586,10 @@
lang = code.code
# check whether we need the language code back
elif isinstance(code, list):
+ # For backwards compatibility still support lists, when twntranslate
+ # was not deprecated and needed a way to get the used language code back
+ warn('The code argument should not be a list but either a BaseSite or '
+ 'a str/unicode.', DeprecationWarning, 2)
lang = code.pop()
code_needed = True
else:
--
To view, visit https://gerrit.wikimedia.org/r/245610
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I13d45e39ea52d77983fb4e654f8c0772f0263306
Gerrit-PatchSet: 1
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: Siebrand <siebrand(a)kitano.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] i18n: Replace all plural items at once
......................................................................
[IMPROV] i18n: Replace all plural items at once
Instead of generating one list of plural items and to substitute always the
first occurrence it can actually iterate over the string using `re.sub` and
dynamically replace it with a plural replacement.
It does verify that `nplurals` is 1 when the `plurals` is not callable. And if
`nplurals` is 1 it verifies that that the value returned is 0.
Change-Id: Id72f7bd55ddd816f6d15ba69e9b8e936333625fd
---
M pywikibot/i18n.py
1 file changed, 43 insertions(+), 22 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py
index fe06672..58e23fd 100644
--- a/pywikibot/i18n.py
+++ b/pywikibot/i18n.py
@@ -338,31 +338,48 @@
@param message: the message to be replaced
@type message: unicode string
@param parameters: plural parameters passed from other methods
- @type parameters: int, basestring, tuple, list, dict
-
+ @type parameters: Mapping of str to int
+ @return: The message with the plural instances replaced
+ @rtype: str
"""
- plural_items = re.findall(PLURAL_PATTERN, message)
+ def static_plural_value(n):
+ return rule['plural']
+
+ def replace_plural(match):
+ selector = match.group(1)
+ variants = match.group(2)
+ num = parameters[selector]
+ if not isinstance(num, int):
+ issue_deprecation_warning(
+ 'type {0} for value {1} ({2})'.format(type(num), selector, num),
+ 'an int', 1)
+ num = int(num)
+
+ index = plural_value(num)
+ if rule['nplurals'] == 1:
+ assert index == 0
+
+ plural_entries = variants.split('|')
+ if index >= len(plural_entries):
+ raise IndexError(
+ 'requested plural {0} for {1} but only {2} ("{3}") '
+ 'provided'.format(
+ index, selector, len(plural_entries),
+ '", "'.join(plural_entries)))
+ return plural_entries[index]
+
assert isinstance(parameters, Mapping), \
'parameters is not Mapping but {0}'.format(type(parameters))
- if plural_items: # we found PLURAL patterns, process it
- for selector, variants in plural_items:
- num = parameters[selector]
- if not isinstance(num, int):
- issue_deprecation_warning(
- 'type {0} for value {1} ({2})'.format(type(num), selector, num),
- 'an int', 1)
- num = int(num)
- # TODO: check against plural_rules[code]['nplurals']
- try:
- index = plural_rules[code]['plural'](num)
- except KeyError:
- index = plural_rules['_default']['plural'](num)
- except TypeError:
- # we got an int, not a function
- index = plural_rules[code]['plural']
- repl = variants.split('|')[index]
- message = re.sub(PLURAL_PATTERN, repl, message, count=1)
- return message
+ try:
+ rule = plural_rules[code]
+ except KeyError:
+ rule = plural_rules['_default']
+ plural_value = rule['plural']
+ if not callable(plural_value):
+ assert rule['nplurals'] == 1
+ plural_value = static_plural_value
+
+ return re.sub(PLURAL_PATTERN, replace_plural, message)
class _PluralMappingAlias(Mapping):
@@ -430,6 +447,8 @@
@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
+ @raise IndexError: If the language supports and requires more plurals than
+ defined for the given translation template.
"""
family = pywikibot.config.family
# If a site is given instead of a code, use its language
@@ -548,6 +567,8 @@
to the resulting string. If this is True the placeholders must be
manually applied afterwards.
@type only_plural: bool
+ @raise IndexError: If the language supports and requires more plurals than
+ defined for the given translation template.
"""
if not messages_available():
raise TranslationError(
--
To view, visit https://gerrit.wikimedia.org/r/244360
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id72f7bd55ddd816f6d15ba69e9b8e936333625fd
Gerrit-PatchSet: 3
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: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Add tox default envs for WM Jenkins
......................................................................
Add tox default envs for WM Jenkins
For those that can be run in isolated Debian Jessie VMs and don't need special
jobs.
Bug: T87169
Change-Id: I7af6c732769650319f0bd08eeffd57f59885a28f
---
M tox.ini
1 file changed, 5 insertions(+), 0 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tox.ini b/tox.ini
index 339afde..529dd3d 100644
--- a/tox.ini
+++ b/tox.ini
@@ -3,6 +3,11 @@
skipsdist = True
envlist = flake8,flake8-py3,flake8-docstrings-mandatory,py26,py27,py34
+[tox:jenkins]
+# Override default for WM Jenkins
+# Others are run in their own individual jobs on WM Jenkins
+envlist = flake8,flake8-py3,flake8-docstrings-mandatory
+
[params]
nose_skip = --ignore-files=(gui\.py|botirc\.py|rcstream\.py)
flake8_ignore = D102,D103,{[flake8]ignore}
--
To view, visit https://gerrit.wikimedia.org/r/245582
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7af6c732769650319f0bd08eeffd57f59885a28f
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: JanZerebecki <jan.wikimedia(a)zerebecki.de>
Gerrit-Reviewer: JanZerebecki <jan.wikimedia(a)zerebecki.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>