jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/423701 )
Change subject: [bugfix] ensure "modules" parameter of ParamInfo._fetch is a set
......................................................................
[bugfix] ensure "modules" parameter of ParamInfo._fetch is a set
Bug: T122763
Change-Id: I896b8cdd85bed894c23824f31c99f3b86f36257c
---
M pywikibot/data/api.py
1 file changed, 15 insertions(+), 3 deletions(-)
Approvals:
Zhuyifei1999: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index f7e4745..1b86cf5 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Interface to Mediawiki's api.php."""
#
-# (C) Pywikibot team, 2007-2018
+# (C) Pywikibot team, 2007-2019
#
# Distributed under the terms of the MIT license.
#
@@ -541,6 +541,17 @@
self._emulate_pageset()
+ @staticmethod
+ def _modules_to_set(modules):
+ """Return modules as a set.
+
+ @type modules: iterable or basestring
+ @rtype: set
+ """
+ if isinstance(modules, basestring):
+ return set(modules.split('|'))
+ return set(modules)
+
def fetch(self, modules):
"""
Fetch paraminfo for multiple modules.
@@ -557,6 +568,8 @@
# query modules can be prefixed with 'query+'
self._init()
+ modules = self._modules_to_set(modules)
+
if self._action_modules:
# The query module may be added before the action modules have been
if 'query' in self._modules:
@@ -740,8 +753,7 @@
def _normalize_modules(self, modules):
"""Add query+ to any query module name not also in action modules."""
# Users will supply the wrong type, and expect it to work.
- if isinstance(modules, basestring):
- modules = set(modules.split('|'))
+ modules = self._modules_to_set(modules)
assert(self._action_modules)
--
To view, visit https://gerrit.wikimedia.org/r/423701
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: I896b8cdd85bed894c23824f31c99f3b86f36257c
Gerrit-Change-Number: 423701
Gerrit-PatchSet: 7
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999(a)gmail.com>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/481664 )
Change subject: [IMPR] Make Wikidata bots add claims with sources in a single edit
......................................................................
[IMPR] Make Wikidata bots add claims with sources in a single edit
This has been possible since Id44613daa30ad7b8ba40134e4db496a0e4a927b0.
Change-Id: Iaadd5704268b62dbf57fff3263f46503beb86459
---
M pywikibot/bot.py
1 file changed, 4 insertions(+), 20 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index 916ff41..eebfb10 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -1986,22 +1986,6 @@
ignore_save_related_errors=ignore_save_related_errors,
ignore_server_errors=ignore_server_errors, **kwargs)
- def _add_source_callback(self, claim, source, **kwargs):
- """
- Make a callback for user_add_claim.
-
- @return: callback to be executed after saving the claim
- @rtype: callable or None
- """
- callback = None
- sourceclaim = self.getSource(source)
- if sourceclaim:
- def callback(item, err):
- if err is None and claim.on_item is not None:
- claim.addSource(sourceclaim, **kwargs)
-
- return callback
-
def user_add_claim(self, item, claim, source=None, bot=True, **kwargs):
"""
Add a claim to an item, with user confirmation as required.
@@ -2025,14 +2009,14 @@
"""
self.current_page = item
- callback = None
if source:
- callback = self._add_source_callback(claim, source, bot=bot)
+ sourceclaim = self.getSource(source)
+ if sourceclaim:
+ claim.addSource(sourceclaim)
pywikibot.output('Adding %s --> %s' % (claim.getID(),
claim.getTarget()))
- return self._save_page(item, item.addClaim, claim, bot=bot,
- callback=callback, **kwargs)
+ return self._save_page(item, item.addClaim, claim, bot=bot, **kwargs)
def getSource(self, site):
"""
--
To view, visit https://gerrit.wikimedia.org/r/481664
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: Iaadd5704268b62dbf57fff3263f46503beb86459
Gerrit-Change-Number: 481664
Gerrit-PatchSet: 1
Gerrit-Owner: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)