Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #2740
Status: Fixed
Duration: 29 minutes and 43 seconds
Commit: c28b316 (master)
Author: Fabian Neundorf
Message: [FIX] upload: Increase stack depth of warnings
The `APISite.upload` method is decorated which causes an additional layer in
the stack. This is increasing the depth of each warning accordingly.
Change-Id: I0a2e04a7178600deaa040e002004eee886ca2c1c
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/884482f04bc9...c28b316c…
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/77974029
--
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] ParamInfo: Use parameter info directly
......................................................................
[IMPROV] ParamInfo: Use parameter info directly
To determine the submodules on wikis before 1.26wmf9 it's iterating over the
parameter names for a module and then requesting the parameter info even though
it is already available for all parameters.
Change-Id: I765ccd47b63dc3c0907b1288964791c08369a1d6
---
M pywikibot/data/api.py
1 file changed, 4 insertions(+), 7 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 d864abf..d25616c 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -686,10 +686,7 @@
submodules.add(child)
else:
# Boolean submodule info added to MW API in afa153ae
- if self.site.version() >= MediaWikiVersion('1.24wmf18'):
- params = set(param['name'] for param in parameters
- if 'submodules' in param)
- else:
+ if self.site.version() < MediaWikiVersion('1.24wmf18'):
if module == 'main':
params = set(['action'])
elif module == 'query':
@@ -700,10 +697,10 @@
if param['name'] in params:
param['submodules'] = ''
- for param in params:
- param = self.parameter(module, param)
+ for param in parameters:
# Do not add format modules
- if module != 'main' or param['name'] != 'format':
+ if 'submodules' in param and (module != 'main' or
+ param['name'] != 'format'):
submodules |= set(param['type'])
if submodules:
--
To view, visit https://gerrit.wikimedia.org/r/230316
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I765ccd47b63dc3c0907b1288964791c08369a1d6
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: [FEAT] tests: Add ability to easily patch parts
......................................................................
[FEAT] tests: Add ability to easily patch parts
This adds the decorator `TestCaseBase.patched()` and the method
`TestCaseBase.patch()` to easily patch something which is unpatched in
`tearDown`. Each method with that `@patched()` decorator will be automatically
patched into the given target. Anything more complex can be done manually with
`patch()`.
Change-Id: Id08a2ebf12edda4eb5d3a4673b9defd1859b4aa4
---
M tests/aspects.py
1 file changed, 38 insertions(+), 0 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/aspects.py b/tests/aspects.py
index f4016d7..5dec99c 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -1019,6 +1019,44 @@
return result
+class PatchingTestCase(TestCase):
+
+ """Easily patch and unpatch instances."""
+
+ @staticmethod
+ def patched(obj, attr_name):
+ """Apply patching information."""
+ def add_patch(decorated):
+ decorated._patching = (obj, attr_name)
+ return decorated
+ return add_patch
+
+ def patch(self, obj, attr_name, replacement):
+ """
+ Patch the obj's attribute with the replacement.
+
+ It will be reset after each C{tearDown}.
+ """
+ self._patched_instances += [(obj, attr_name, getattr(obj, attr_name))]
+ setattr(obj, attr_name, replacement)
+
+ def setUp(self):
+ """Set up the test by initializing the patched list."""
+ super(TestCaseBase, self).setUp()
+ self._patched_instances = []
+ for attribute in dir(self):
+ attribute = getattr(self, attribute)
+ if callable(attribute) and hasattr(attribute, '_patching'):
+ self.patch(attribute._patching[0], attribute._patching[1],
+ attribute)
+
+ def tearDown(self):
+ """Tear down the test by unpatching the patched."""
+ for patched in self._patched_instances:
+ setattr(*patched)
+ super(TestCaseBase, self).tearDown()
+
+
class SiteAttributeTestCase(TestCase):
"""Add the sites as attributes to the instances."""
--
To view, visit https://gerrit.wikimedia.org/r/231797
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id08a2ebf12edda4eb5d3a4673b9defd1859b4aa4
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: [FIX] APISite: Use NamespaceDict's resolve
......................................................................
[FIX] APISite: Use NamespaceDict's resolve
The `Namespace.resolve` method has been deprecated in favor of
`NamespaceDict`'s implementation. This is updating the two remaining calls.
Change-Id: Ib452c8cd8a279a77183844efa495c9caddfba910
---
M pywikibot/site.py
1 file changed, 2 insertions(+), 3 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 3f3fe9f..ef42621 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -3359,8 +3359,7 @@
# to use namespaces available on earlier versions.
# Covert namespaces to a known type
- namespaces = set(Namespace.resolve(namespaces or [],
- self.namespaces))
+ namespaces = set(self.namespaces.resolve(namespaces or []))
if 'page' in member_type:
excluded_namespaces = set()
@@ -5813,7 +5812,7 @@
@return: The pages which are protected.
@rtype: generator of Page
"""
- namespaces = Namespace.resolve(namespace, self.namespaces)
+ namespaces = self.namespaces.resolve(namespace)
# always assert that, so we are be sure that type could be 'create'
assert 'create' in self.protection_types(), \
"'create' should be a valid protection type."
--
To view, visit https://gerrit.wikimedia.org/r/234813
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib452c8cd8a279a77183844efa495c9caddfba910
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: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [IMPR] Rename the message index by using keyword arguments.
......................................................................
[IMPR] Rename the message index by using keyword arguments.
- bugfix for generic 'qqq' edit summary message
- Add doc strings to methods
- add script to flake8-docstrings-mandatory
Change-Id: I2becaee8126f5413bed5025ddfd41c6ac25558cd
---
M scripts/maintenance/make_i18n_dict.py
M tox.ini
2 files changed, 31 insertions(+), 18 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/maintenance/make_i18n_dict.py b/scripts/maintenance/make_i18n_dict.py
index bb6155f..de37f2c 100755
--- a/scripts/maintenance/make_i18n_dict.py
+++ b/scripts/maintenance/make_i18n_dict.py
@@ -14,17 +14,20 @@
If you have more than one message dictionary, give all these names to the bot:
>>> bot = i18nBot('<scriptname>', '<msg dict1>', '<msg dict2>', '<msg dict3>')
+If you want to rename the message index use keyword arguments. This may be
+mixed with preleading positonal argumens:
+>>> bot = i18nBot('<scriptname>', '<msg dict1>', the_other_msg='<msg dict2>')
+
If you have the messages as instance constants you may call the bot as follows:
>>> bot = i18nBot('<scriptname>.<class instance>', '<msg dict1>', '<msg dict2>')
-It's also possible to make json files too by using to_json method:
->>> from scripts.maintenance.make_i18n_dict import i18nBot
->>> bot = i18nBot('disambredir', 'msg')
+It's also possible to make json files too by using to_json method after
+instantiating the bot. It also calls bot.run() to create the dictionaries.
>>> bot.to_json()
"""
#
-# (C) xqt, 2013-2014
-# (C) Pywikibot team, 2013-2014
+# (C) xqt, 2013-2015
+# (C) Pywikibot team, 2013-2015
#
# Distributed under the terms of the MIT license.
#
@@ -44,20 +47,24 @@
"""I18n bot."""
- def __init__(self, script, *args):
+ def __init__(self, script, *args, **kwargs):
+ """Constructor."""
modules = script.split('.')
self.scriptname = modules[0]
self.script = __import__('scripts.' + self.scriptname)
for m in modules:
self.script = getattr(self.script, m)
- self.messages = list()
+ self.messages = {}
+ # setup the message dict
for msg in args:
if hasattr(self.script, msg):
- self.messages.append(msg)
- self.messages.sort()
- self.dict = dict()
+ self.messages[msg] = msg
+ for new, old in kwargs.items():
+ self.messages[old] = new.replace('_', '-')
+ self.dict = {}
def print_all(self):
+ """Pretty print the dict as a file content to screen."""
keys = list(self.dict.keys())
keys.remove('qqq')
keys.sort()
@@ -70,7 +77,7 @@
print("msg = {")
for code in keys:
print(" '%s': {" % code)
- for msg in self.messages:
+ for msg in sorted(self.messages.values()):
label = "%s-%s" % (self.scriptname, msg)
if label in self.dict[code]:
print(" '%s': u'%s'," % (label,
@@ -78,31 +85,36 @@
print(" },")
print("};")
- def read(self, item):
- msg = getattr(self.script, item)
+ def read(self, oldmsg, newmsg=None):
+ """Read a single message from source script."""
+ msg = getattr(self.script, oldmsg)
keys = list(msg.keys())
keys.append('qqq')
+ if newmsg is None:
+ newmsg = oldmsg
for code in keys:
- label = "%s-%s" % (self.scriptname, item)
+ label = "%s-%s" % (self.scriptname, newmsg)
if code == 'qqq':
if code not in self.dict:
self.dict[code] = {}
self.dict[code][label] = (
u'Edit summary for message %s of %s report'
- % (self.scriptname, item))
+ % (newmsg, self.scriptname))
elif code != 'commons':
if code not in self.dict:
self.dict[code] = {}
self.dict[code][label] = msg[code]
if 'en' not in keys:
- print('WARNING: "en" key missing for message %s' % item)
+ print('WARNING: "en" key missing for message %s' % newmsg)
def run(self):
- for msg in self.messages:
- self.read(msg)
+ """Run the bot, read the messages from source and print the dict."""
+ for item in self.messages.items():
+ self.read(*item)
self.print_all()
def to_json(self):
+ """Run the bot and create json files."""
if not self.dict:
self.run()
json_dir = os.path.join(
diff --git a/tox.ini b/tox.ini
index 6a052c3..c641bd2 100644
--- a/tox.ini
+++ b/tox.ini
@@ -102,6 +102,7 @@
scripts/listpages.py \
scripts/login.py \
scripts/maintenance/__init__.py \
+ scripts/maintenance/make_i18n_dict.py \
scripts/misspelling.py \
scripts/newitem.py \
scripts/noreferences.py \
--
To view, visit https://gerrit.wikimedia.org/r/234720
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I2becaee8126f5413bed5025ddfd41c6ac25558cd
Gerrit-PatchSet: 5
Gerrit-Project: pywikibot/core
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: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Siebrand <siebrand(a)kitano.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>