jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] ParamInfo: Correct read generators from help
......................................................................
[FIX] ParamInfo: Correct read generators from help
Interpreting the help text in d0485f71 was done incorrectly for the
query generators as it must have been a parameter allowing multiple
values.
Change-Id: I31f23977c571bf3fe554f01dbf10e348a0d1d894
---
M pywikibot/data/api.py
1 file changed, 2 insertions(+), 2 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 7946767..0ad45c8 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -363,8 +363,8 @@
meta_modules = help_text[start:end].split(', ')
start = help_text.find('Use the output of a list as the input')
- start = help_text.find(query_help_list_prefix, start)
- start += len(query_help_list_prefix)
+ start = help_text.find('One value: ', start)
+ start += len('One value: ')
end = help_text.find('\n', start)
gen_modules = help_text[start:end].split(', ')
--
To view, visit https://gerrit.wikimedia.org/r/199853
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I31f23977c571bf3fe554f01dbf10e348a0d1d894
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: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] replaceExcept: Replace references iteratively
......................................................................
[FIX] replaceExcept: Replace references iteratively
Instead of searching for back references (\0 or \g<foo>) on the entire
resulting string it just searches over the original replacement string. So when
back references appear in the resulting string itself, they won't be found.
It also allows group numbers in \g back references to act the same as re.sub.
Bug: T99032
Change-Id: Ia4419804b83e67baada277e1493b58e4d2f73bf5
---
M pywikibot/textlib.py
M tests/textlib_tests.py
2 files changed, 42 insertions(+), 12 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index cfca7e0..26b291f 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -296,23 +296,26 @@
# text = text[:match.start()] + replacement + text[match.end():]
# So we have to process the group references manually.
- replacement = new
+ replacement = ''
- groupR = re.compile(r'\\(?P<number>\d+)|\\g<(?P<name>.+?)>')
- while True:
- groupMatch = groupR.search(replacement)
- if not groupMatch:
- break
- groupID = (groupMatch.group('name') or
- int(groupMatch.group('number')))
+ group_regex = re.compile(r'\\(\d+)|\\g<(.+?)>')
+ last = 0
+ for group_match in group_regex.finditer(new):
+ group_id = group_match.group(1) or group_match.group(2)
try:
- replacement = (replacement[:groupMatch.start()] +
- (match.group(groupID) or '') +
- replacement[groupMatch.end():])
+ group_id = int(group_id)
+ except ValueError:
+ pass
+ try:
+ replacement += new[last:group_match.start()]
+ replacement += match.group(group_id) or ''
except IndexError:
- pywikibot.output('\nInvalid group reference: %s' % groupID)
+ pywikibot.output('\nInvalid group reference: %s' % group_id)
pywikibot.output('Groups found:\n%s' % match.groups())
raise IndexError
+ last = group_match.end()
+ replacement += new[last:]
+
text = text[:match.start()] + replacement + text[match.end():]
# continue the search on the remaining text
diff --git a/tests/textlib_tests.py b/tests/textlib_tests.py
index 5edb23f..468d3f2 100644
--- a/tests/textlib_tests.py
+++ b/tests/textlib_tests.py
@@ -384,6 +384,22 @@
self.assertEqual(
textlib.replaceExcept('', r'(a)?', r'\1\1', [], site=self.site),
'')
+ self.assertEqual(
+ textlib.replaceExcept('A123B', r'A(\d)2(\d)B', r'A\g<1>x\g<2>B',
+ [], site=self.site),
+ 'A1x3B')
+ self.assertEqual(
+ textlib.replaceExcept('A123B', r'A(?P<a>\d)2(?P<b>\d)B',
+ r'A\g<a>x\g<b>B', [], site=self.site),
+ 'A1x3B')
+ self.assertEqual(
+ textlib.replaceExcept('A123B', r'A(?P<a>\d)2(\d)B',
+ r'A\g<a>x\g<2>B', [], site=self.site),
+ 'A1x3B')
+ self.assertEqual(
+ textlib.replaceExcept('A123B', r'A(?P<a>\d)2(\d)B',
+ r'A\g<a>x\2B', [], site=self.site),
+ 'A1x3B')
def test_case_sensitive(self):
self.assertEqual(textlib.replaceExcept('AxB', 'x', 'y', [],
@@ -513,6 +529,17 @@
['template'], site=self.site),
template_sample)
+ def test_replace_source_reference(self):
+ """Test replacing in text which contains back references."""
+ # Don't use a valid reference number in the original string, in case it
+ # tries to apply that as a reference.
+ self.assertEqual(textlib.replaceExcept(r'\42', r'^(.*)$', r'X\1X',
+ [], site=self.site),
+ r'X\42X')
+ self.assertEqual(textlib.replaceExcept(r'\g<bar>', r'^(?P<foo>.*)$',
+ r'X\g<foo>X', [], site=self.site),
+ r'X\g<bar>X')
+
if __name__ == '__main__':
try:
--
To view, visit https://gerrit.wikimedia.org/r/212978
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia4419804b83e67baada277e1493b58e4d2f73bf5
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: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] i18n: twtranslate returns used code in list
......................................................................
[FIX] i18n: twtranslate returns used code in list
It fixes an issue with 5767d73d, that twntranslate didn't get the language code
which was actually used. With fallback=True twtranslate might use another
language than the language given in the first place. To inform twntranslate
about that, twntranslate uses a list which is modified by twtranslate.
But with 5767d73d it always added the same value again so that the list wasn't
chaned at all.
Change-Id: I7228b1ab19510769c876e8943e92dc666c6b2ded
---
M pywikibot/i18n.py
M tests/i18n_tests.py
2 files changed, 22 insertions(+), 2 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py
index 67b227f..69549f8 100644
--- a/pywikibot/i18n.py
+++ b/pywikibot/i18n.py
@@ -499,7 +499,7 @@
'Read https://mediawiki.org/wiki/PWB/i18n' % twtitle)
# send the language code back via the given list
if code_needed:
- code.append(lang)
+ code.append(alt)
if parameters:
return trans % parameters
else:
diff --git a/tests/i18n_tests.py b/tests/i18n_tests.py
index 0634181..897e2e2 100644
--- a/tests/i18n_tests.py
+++ b/tests/i18n_tests.py
@@ -13,7 +13,7 @@
import pywikibot
-from pywikibot import i18n, bot
+from pywikibot import i18n, bot, plural
from tests.aspects import unittest, TestCase, DefaultSiteTestCase, PwbTestCase
@@ -311,6 +311,26 @@
% {'action': u'Ändere'},
u'Bot: Ändere 1 Zeile von einer Seite.')
+ def test_fallback_lang(self):
+ """
+ Test that twntranslate uses the translation's language.
+
+ twntranslate calls _twtranslate which might return the translation for
+ a different language and then the plural rules from that language need
+ to be applied.
+ """
+ # co has fr as altlang but has no plural rules defined (otherwise this
+ # test might not catch problems) so it's using the plural variant for 0
+ # although French uses the plural variant for numbers > 1 (so not 0)
+ assert('co' not in plural.plural_rules)
+ assert(plural.plural_rules['fr']['plural'](0) is False)
+ self.assertEqual(
+ i18n.twntranslate('co', 'test-plural', {'num': 0, 'descr': 'seulement'}),
+ u'Robot: Changer seulement une page.')
+ self.assertEqual(
+ i18n.twntranslate('co', 'test-plural', {'num': 1, 'descr': 'seulement'}),
+ u'Robot: Changer seulement une page.')
+
class ScriptMessagesTestCase(TWNTestCaseBase):
--
To view, visit https://gerrit.wikimedia.org/r/214428
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7228b1ab19510769c876e8943e92dc666c6b2ded
Gerrit-PatchSet: 2
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: Siebrand <siebrand(a)kitano.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] APISite.upload: Expect a dict not a list
......................................................................
[FIX] APISite.upload: Expect a dict not a list
The imageinfo returned via query+imageinfo is a list while the imageinfo
returned via upload is just a dict. Since 31cd9fdc it assumed it returned
actually a list of dicts and thus failed when FileInfo tried to create itself
from a part of the dict.
Bug: T100627
Change-Id: I0a31451fee3ac342a748c6b03fea9e9853cefd7f
---
M pywikibot/site.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index ebcd71d..939fa58 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -5090,7 +5090,7 @@
# If we receive a nochange, that would mean we're in simulation
# mode, don't attempt to access imageinfo
if "nochange" not in result:
- filepage._load_file_revisions(result["imageinfo"])
+ filepage._load_file_revisions([result["imageinfo"]])
return
@deprecated_args(number="step",
--
To view, visit https://gerrit.wikimedia.org/r/214423
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0a31451fee3ac342a748c6b03fea9e9853cefd7f
Gerrit-PatchSet: 2
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: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: rename deledpimage to remove_edp_images
......................................................................
rename deledpimage to remove_edp_images
The new name is proposed in I3c43958e14d87a81ad047c1821fe43f30ce575c8
Change-Id: I9dfea27bb9bf5c1b1812d1d4b8e5f3fce2b4bb5b
---
R remove_edp_images.py
R remove_edp_images/ar.json
R remove_edp_images/en.json
R remove_edp_images/qqq.json
R remove_edp_images/zh.json
5 files changed, 0 insertions(+), 0 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/deledpimage.py b/remove_edp_images.py
similarity index 100%
rename from deledpimage.py
rename to remove_edp_images.py
diff --git a/deledpimage/ar.json b/remove_edp_images/ar.json
similarity index 100%
rename from deledpimage/ar.json
rename to remove_edp_images/ar.json
diff --git a/deledpimage/en.json b/remove_edp_images/en.json
similarity index 100%
rename from deledpimage/en.json
rename to remove_edp_images/en.json
diff --git a/deledpimage/qqq.json b/remove_edp_images/qqq.json
similarity index 100%
rename from deledpimage/qqq.json
rename to remove_edp_images/qqq.json
diff --git a/deledpimage/zh.json b/remove_edp_images/zh.json
similarity index 100%
rename from deledpimage/zh.json
rename to remove_edp_images/zh.json
--
To view, visit https://gerrit.wikimedia.org/r/214354
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9dfea27bb9bf5c1b1812d1d4b8e5f3fce2b4bb5b
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/i18n
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Siebrand <siebrand(a)kitano.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: update mw and wm versions
......................................................................
update mw and wm versions
Change-Id: I4374aec3c87fd1f9bb2757481dd42c7ba00159e6
---
M family.py
1 file changed, 2 insertions(+), 2 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/family.py b/family.py
index f3ec8b1..7a1d320 100644
--- a/family.py
+++ b/family.py
@@ -4331,7 +4331,7 @@
# Don't use this, use versionnumber() instead. This only exists
# to not break family files.
# Here we return the latest mw release for downloading
- return '1.24.2'
+ return '1.25.1'
def versionnumber(self, code, version=None):
"""Return an int identifying MediaWiki version.
@@ -4967,7 +4967,7 @@
# Don't use this, use versionnumber() instead. This only exists
# to not break family files.
# Here we return the latest mw release of wikimedia projects
- return '1.26wmf5'
+ return '1.26wmf7'
def shared_image_repository(self, code):
return ('commons', 'commons')
--
To view, visit https://gerrit.wikimedia.org/r/214336
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I4374aec3c87fd1f9bb2757481dd42c7ba00159e6
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] replaceExcept: Handle empty matches
......................................................................
[FIX] replaceExcept: Handle empty matches
When the regex can match the empty string, it will get into an infinite loop as
soon as it reached the end of the string, as it will match the last 0
characters over and over.
This uses the same functionality from re.sub() that it only replaces if it
isn't adjacent to a previous match.
Change-Id: I479d6d5f9ac756b84d93bfd1fd81a2948677787f
---
M pywikibot/textlib.py
M tests/textlib_tests.py
2 files changed, 15 insertions(+), 0 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
XZise: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index 462afa2..cfca7e0 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -253,6 +253,8 @@
index = 0
markerpos = len(text)
while True:
+ if index > len(text):
+ break
match = old.search(text, index)
if not match:
# nothing left to replace
@@ -318,6 +320,9 @@
index = match.start() + 1
else:
index = match.start() + len(replacement)
+ if not match.group():
+ # When the regex allows to match nothing, shift by one character
+ index += 1
markerpos = match.start() + len(replacement)
text = text[:markerpos] + marker + text[markerpos:]
diff --git a/tests/textlib_tests.py b/tests/textlib_tests.py
index 3974fd3..5edb23f 100644
--- a/tests/textlib_tests.py
+++ b/tests/textlib_tests.py
@@ -374,6 +374,16 @@
r'A(\d)2(\d)B', r'A\1x\2B', [],
site=self.site),
'A1x3B')
+ self.assertEqual(
+ textlib.replaceExcept('', r'(a?)', r'\1B', [], site=self.site),
+ 'B')
+ self.assertEqual(
+ textlib.replaceExcept('abc', r'x*', r'-', [], site=self.site),
+ '-a-b-c-')
+ # This is different from re.sub() as re.sub() doesn't allow None groups
+ self.assertEqual(
+ textlib.replaceExcept('', r'(a)?', r'\1\1', [], site=self.site),
+ '')
def test_case_sensitive(self):
self.assertEqual(textlib.replaceExcept('AxB', 'x', 'y', [],
--
To view, visit https://gerrit.wikimedia.org/r/213204
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I479d6d5f9ac756b84d93bfd1fd81a2948677787f
Gerrit-PatchSet: 2
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: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>