jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] Allow apostrophe in password
......................................................................
[FIX] Allow apostrophe in password
If the password contains an apostrophe it'll mess up the line in the password
file. E.g. if the password is "foo'bar" it'll add the following line:
('username', 'foo'bar')
This escapes now any quotes and it'll generate the following line:
('username', 'foo\'bar')
Bug: T105783
Change-Id: I45501958362ef07e20b73448a11f11a4160f3136
(cherry picked from commit ac07c7a09ca43c66bb5352533ac88d766d64bdbf)
---
M .travis.yml
M tests/README.rst
2 files changed, 4 insertions(+), 2 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/.travis.yml b/.travis.yml
index 6135c7f..0ffea0d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -48,7 +48,7 @@
echo "usernames['wikipedia']['test'] = '$PYWIKIBOT2_USERNAME'" >> ~/.pywikibot/user-config.py ;
echo "usernames['wikidata']['test'] = '$PYWIKIBOT2_USERNAME'" >> ~/.pywikibot/user-config.py ;
echo "usernames['commons']['commons'] = '$PYWIKIBOT2_USERNAME'" >> ~/.pywikibot/user-config.py ;
- echo "('$PYWIKIBOT2_USERNAME', '$USER_PASSWORD')" > ~/.pywikibot/passwordfile ;
+ printf "('%q', '%q')\n" "$PYWIKIBOT2_USERNAME" "$USER_PASSWORD" > ~/.pywikibot/passwordfile ;
echo "import os" >> ~/.pywikibot/user-config.py ;
echo "password_file = os.path.expanduser('~/.pywikibot/passwordfile')" >> ~/.pywikibot/user-config.py ;
fi
diff --git a/tests/README.rst b/tests/README.rst
index 3080680..2f9f91a 100644
--- a/tests/README.rst
+++ b/tests/README.rst
@@ -109,7 +109,9 @@
4. The next build should run tests that require a logged in user
While passwords in travis-ci environment variables are not leaked in normal
-operations, you are responsible for your own passwords.
+operations, you are responsible for your own passwords. If the password contains
+single quotes it is necessary to surround them in double quotes (see also
+`travis-ci #4350 <https://github.com/travis-ci/travis-ci/issues/4350>`_).
It is strongly recommended that an untrusted bot account is created for
travis tests, using a password that is not shared with trusted accounts.
--
To view, visit https://gerrit.wikimedia.org/r/242521
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I45501958362ef07e20b73448a11f11a4160f3136
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: 2.0
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] checkimages: Expect NoPage exception
......................................................................
[FIX] checkimages: Expect NoPage exception
In compat the script called `getHash` which returned None if the image is
missing while `latest_file_info` raises a NoPage exception.
The script was previously fixed in 88ad247f and the usage was changed into
`getFileSHA1Sum` which would raise a `TypeError` if the page doesn't exist.
Bug: T105727
Change-Id: I9c39c41b86125ab7eeb1e842faad2a2cecbcb637
(cherry picked from commit 4bd04db59ba76534c165f2d674f5bebd1c156cd2)
---
M scripts/checkimages.py
1 file changed, 3 insertions(+), 2 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/checkimages.py b/scripts/checkimages.py
index e889f4d..985c554 100755
--- a/scripts/checkimages.py
+++ b/scripts/checkimages.py
@@ -905,8 +905,9 @@
"""Checking if the file is on commons."""
pywikibot.output(u'Checking if [[%s]] is on commons...'
% self.imageName)
- hash_found = self.image.latest_file_info.sha1
- if not hash_found:
+ try:
+ hash_found = self.image.latest_file_info.sha1
+ except pywikibot.NoPage:
return # Image deleted, no hash found. Skip the image.
site = pywikibot.Site('commons', 'commons')
--
To view, visit https://gerrit.wikimedia.org/r/242520
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9c39c41b86125ab7eeb1e842faad2a2cecbcb637
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: 2.0
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: Allow titletranslate.translate page to be None
......................................................................
Allow titletranslate.translate page to be None
60c01fa552 introduced a dependency in titletranslate.translate on
its page parameter, however that parameter can be None.
Fix the spec of the method to indicate it can be None, and
also rewrite the only invocation, in interwiki.py, so it is more
easily understandable.
Also deprecate unused family parameter.
Bug: T75934
Change-Id: Ifca8a1c259d34e8c43c6ab331d2dc5196f3bfb44
(cherry picked from commit 95404658bd53a9cc50d276a86a0d82d293d16ac3)
---
M pywikibot/titletranslate.py
M scripts/interwiki.py
2 files changed, 26 insertions(+), 22 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/titletranslate.py b/pywikibot/titletranslate.py
index 5735163..e0fe8ca 100644
--- a/pywikibot/titletranslate.py
+++ b/pywikibot/titletranslate.py
@@ -3,7 +3,7 @@
#
# (C) Rob W.W. Hooft, 2003
# (C) Yuri Astrakhan, 2005
-# (C) Pywikibot team, 2003-2014
+# (C) Pywikibot team, 2003-2015
#
# Distributed under the terms of the MIT license.
#
@@ -15,11 +15,14 @@
import pywikibot
import pywikibot.date as date
+
from pywikibot import config
+from pywikibot.tools import deprecated_args
-def translate(page, hints=None, auto=True, removebrackets=False, site=None,
- family=None):
+@deprecated_args(family=None)
+def translate(page=None, hints=None, auto=True, removebrackets=False,
+ site=None):
"""
Return a list of links to pages on other sites based on hints.
@@ -32,10 +35,12 @@
"""
result = set()
+
+ assert page or site
+
if site is None and page:
site = page.site
- if family is None and site:
- family = site.family
+
if hints:
for h in hints:
if ':' not in h:
@@ -65,13 +70,15 @@
codes = site.family.language_groups[codes]
else:
codes = codes.split(',')
+
for newcode in codes:
if newcode in site.languages():
if newcode != site.code:
+ ns = page.namespace() if page else 0
x = pywikibot.Link(newname,
site.getSite(code=newcode),
- defaultNamespace=page.namespace())
+ defaultNamespace=ns)
result.add(x)
else:
if config.verbose_output:
diff --git a/scripts/interwiki.py b/scripts/interwiki.py
index fa26860..caa6d67 100755
--- a/scripts/interwiki.py
+++ b/scripts/interwiki.py
@@ -924,24 +924,21 @@
"""Add the given translation hints to the todo list."""
if globalvar.same and self.originPage:
if hints:
- links = titletranslate.translate(
- self.originPage,
- hints=hints + ['all:'],
- auto=globalvar.auto,
- removebrackets=globalvar.hintnobracket)
+ hints += ['all:']
else:
- links = titletranslate.translate(
- self.originPage,
- hints=['all:'],
- auto=globalvar.auto,
- removebrackets=globalvar.hintnobracket)
+ hints = ['all:']
+
+ site = self.originPage.site
else:
- links = titletranslate.translate(
- self.originPage,
- hints=hints,
- auto=globalvar.auto,
- removebrackets=globalvar.hintnobracket,
- site=pywikibot.Site())
+ site = pywikibot.Site()
+
+ links = titletranslate.translate(
+ self.originPage,
+ hints=hints,
+ auto=globalvar.auto,
+ removebrackets=globalvar.hintnobracket,
+ site=site)
+
for link in links:
page = pywikibot.Page(link)
if globalvar.contentsondisk:
--
To view, visit https://gerrit.wikimedia.org/r/243109
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ifca8a1c259d34e8c43c6ab331d2dc5196f3bfb44
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: 2.0
Gerrit-Owner: 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] rollback: Use Revision instance properly
......................................................................
[FIX] rollback: Use Revision instance properly
The previous implementation assumed that the revisions are ordered by the id
while they are in fact ordered by the timestamp. It also did iterate over the
revision ids and not over the `Revision` instance which caused the loop to
fail.
Now `APISite.rollbackpage` also requires the user to be logged in.
Change-Id: I280a4781f0f293e09dd94e14007f49cee30f60e3
(cherry picked from commit 5f4eabe94c651717b51927182951701237a54166)
---
M pywikibot/site.py
1 file changed, 3 insertions(+), 1 deletion(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 5e3a53f..341b76f 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -4445,6 +4445,7 @@
"alreadyrolled": "Page [[%(title)s]] already rolled back; action aborted.",
} # other errors shouldn't arise because we check for those errors
+ @must_be('user')
def rollbackpage(self, page, **kwargs):
"""Roll back page to version before last user's edits.
@@ -4463,7 +4464,8 @@
% page.title(asLink=True))
last_rev = page.latest_revision
last_user = last_rev.user
- for rev in sorted(list(page._revisions.keys()), reverse=True):
+ for rev in sorted(page._revisions.values(), reverse=True,
+ key=lambda r: r.timestamp):
# start with most recent revision first
if rev.user != last_user:
break
--
To view, visit https://gerrit.wikimedia.org/r/243106
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I280a4781f0f293e09dd94e14007f49cee30f60e3
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: 2.0
Gerrit-Owner: 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 ComparableMixin
......................................................................
Fix ComparableMixin
The implementation in 6c6b185e failed for inequality,
resulting in 'Namespace 0 < int 0' returning True.
Change-Id: Ia00ab2dd68938b0520253f7017d685aa03c36592
(cherry picked from commit 57a55ff9929f7c692a041ed209a913422f097fe5)
---
M pywikibot/tools/__init__.py
M tests/namespace_tests.py
2 files changed, 25 insertions(+), 13 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index 00c7fc2..bb88166 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -115,27 +115,27 @@
"""Mixin class to allow comparing to other objects which are comparable."""
def __lt__(self, other):
- """Compare if other is less than self."""
- return other >= self._cmpkey()
-
- def __le__(self, other):
- """Compare if other is less equals self."""
+ """Compare if self is less than other."""
return other > self._cmpkey()
+ def __le__(self, other):
+ """Compare if self is less equals other."""
+ return other >= self._cmpkey()
+
def __eq__(self, other):
- """Compare if other is equal to self."""
+ """Compare if self is equal to other."""
return other == self._cmpkey()
def __ge__(self, other):
- """Compare if other is greater equals self."""
- return other < self._cmpkey()
-
- def __gt__(self, other):
- """Compare if other is greater than self."""
+ """Compare if self is greater equals other."""
return other <= self._cmpkey()
+ def __gt__(self, other):
+ """Compare if self is greater than other."""
+ return other < self._cmpkey()
+
def __ne__(self, other):
- """Compare if other is not equal to self."""
+ """Compare if self is not equal to other."""
return other != self._cmpkey()
diff --git a/tests/namespace_tests.py b/tests/namespace_tests.py
index 6f18a73..ca1790a 100644
--- a/tests/namespace_tests.py
+++ b/tests/namespace_tests.py
@@ -145,13 +145,17 @@
self.assertEqual(a, 0)
self.assertEqual(a, '')
+ self.assertFalse(a < 0)
+ self.assertFalse(a > 0)
self.assertNotEqual(a, None)
+
+ self.assertGreater(a, -1)
x = Namespace(id=6, custom_name=u'dummy', canonical_name=u'File',
aliases=[u'Image', u'Immagine'])
y = Namespace(id=6, custom_name=u'ملف', canonical_name=u'File',
aliases=[u'Image', u'Immagine'])
- z = Namespace(id=7, custom_name=u'dummy', canonical_name=u'File',
+ z = Namespace(id=7, custom_name=u'dummy 7', canonical_name=u'File',
aliases=[u'Image', u'Immagine'])
self.assertEqual(x, x)
@@ -170,11 +174,19 @@
self.assertEqual(x, u'image')
self.assertEqual(x, u'Image')
+ self.assertFalse(x < 6)
+ self.assertFalse(x > 6)
+
self.assertEqual(y, u'ملف')
self.assertLess(a, x)
+ self.assertLess(x, z)
+ self.assertLessEqual(a, x)
self.assertGreater(x, a)
+ self.assertGreater(x, 0)
self.assertGreater(z, x)
+ self.assertGreaterEqual(x, a)
+ self.assertGreaterEqual(y, x)
self.assertIn(6, [x, y, z])
self.assertNotIn(8, [x, y, z])
--
To view, visit https://gerrit.wikimedia.org/r/243104
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia00ab2dd68938b0520253f7017d685aa03c36592
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: 2.0
Gerrit-Owner: 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: Deprecate ParamInfo.query_modules_with_limits
......................................................................
Deprecate ParamInfo.query_modules_with_limits
query_modules_with_limits is an unnecessary performance hit
during site initialisation, and causes problems in production
when there are problems with a query module.
It also causes a paraminfo caching bug to become a major bug
preventing all access due to an assert added in 424eaa3.
Bug: T100779
Bug: T109168
Change-Id: I90910e52395f1db72f51088fa4306f62b625cc2c
(cherry picked from commit 879defd1fd5ee7976d364fc34cd99254c31e4737)
---
M pywikibot/data/api.py
M tests/api_tests.py
M tests/utils.py
3 files changed, 29 insertions(+), 8 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 0d4d01e..c2af5ea 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -797,6 +797,7 @@
if self[mod][attribute])
@property
+ @deprecated('parameter()')
def query_modules_with_limits(self):
"""Set of all query modules which have limits."""
if not self._with_limits:
@@ -2059,10 +2060,11 @@
kwargs['continue'] = True
self.request = Request(**kwargs)
- # This forces all paraminfo for all query modules to be bulk loaded.
- limited_modules = (
- set(self.modules) & self.site._paraminfo.query_modules_with_limits
- )
+ self.site._paraminfo.fetch('query+' + mod for mod in self.modules)
+
+ limited_modules = set(
+ mod for mod in self.modules
+ if self.site._paraminfo.parameter('query+' + mod, 'limit'))
if not limited_modules:
self.limited_module = None
@@ -2073,7 +2075,7 @@
# Query will continue as needed until limit (if any) for this module
# is reached.
for module in self.modules:
- if module in self.site._paraminfo.query_modules_with_limits:
+ if module in limited_modules:
self.limited_module = module
limited_modules.remove(module)
break
diff --git a/tests/api_tests.py b/tests/api_tests.py
index dde46f5..1facab9 100644
--- a/tests/api_tests.py
+++ b/tests/api_tests.py
@@ -276,6 +276,19 @@
self.assertIn('revisions', pi.prefixes)
+class TestParaminfoModules(DefaultSiteTestCase):
+
+ """Test loading all paraminfo modules."""
+
+ def test_action_modules(self):
+ """Test loading all action modules."""
+ self.site._paraminfo.fetch(self.site._paraminfo.action_modules)
+
+ def test_query_modules(self):
+ """Test loading all query modules."""
+ self.site._paraminfo.fetch(self.site._paraminfo.query_modules)
+
+
class TestOptionSet(TestCase):
"""OptionSet class test class."""
diff --git a/tests/utils.py b/tests/utils.py
index db2b9a3..5fef89e 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -116,14 +116,20 @@
self.prefixes = set()
def fetch(self, modules, _init=False):
- """Prevented method."""
- raise Exception(u'DryParamInfo.fetch(%r, %r) prevented'
- % (modules, _init))
+ """Load dry data."""
+ return [self[mod] for mod in modules]
def parameter(self, module, param_name):
"""Load dry data."""
return self[module][param_name]
+ def __getitem__(self, name):
+ """Return dry data or a dummy parameter block."""
+ try:
+ return super(DryParamInfo, self).__getitem__(name)
+ except KeyError:
+ return {'name': name, 'limit': None}
+
class DummySiteinfo():
--
To view, visit https://gerrit.wikimedia.org/r/243060
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I90910e52395f1db72f51088fa4306f62b625cc2c
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: 2.0
Gerrit-Owner: 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 <>
Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #2945
Status: Failed
Duration: 21 minutes and 48 seconds
Commit: 1ff1cec (2.0rc3)
Author: Fabian Neundorf
Message: Release 2.0rc3
After all WMF wikis will be broken without d1854f5e a new version should be
released.
Change-Id: Ifef5202c4e60a638336c7eb2b3b0074962e4ff2c
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/2.0rc3
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/83334733
--
You can configure recipients for build notifications in your .travis.yml file. See http://docs.travis-ci.com/user/notifications