jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/462172 )
Change subject: [doc] handleArgs() is deprecated; change doc strings accordingly
......................................................................
[doc] handleArgs() is deprecated; change doc strings accordingly
Change-Id: Ib321c3642edc5a80783b6563a80969d269e9e7aa
---
M pywikibot/bot.py
1 file changed, 2 insertions(+), 2 deletions(-)
Approvals:
Framawiki: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index 9721ded..e17bef5 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -255,7 +255,7 @@
This function must be called before using pywikibot.output(); and must
be called again if the destination stream is changed.
- Note: this function is called by handleArgs(), so it should normally
+ Note: this function is called by handle_args(), so it should normally
not need to be called explicitly
All user output is routed through the logging module.
@@ -375,7 +375,7 @@
# script call time stamp
log(u'DATE: %s UTC' % str(datetime.datetime.utcnow()))
- # new framework release/revision? (handleArgs needs to be called first)
+ # new framework release/revision? (handle_args needs to be called first)
try:
log(u'VERSION: %s' %
version.getversion(online=config.log_pywiki_repo_version).strip())
--
To view, visit https://gerrit.wikimedia.org/r/462172
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: Ib321c3642edc5a80783b6563a80969d269e9e7aa
Gerrit-Change-Number: 462172
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/321089 )
Change subject: [IMPR] Add new page generators
......................................................................
[IMPR] Add new page generators
Added/enabled following page generators:
-wantedpages
-wantedfiles
-wantedcategories
-wantedtemplates
Also add some tests.
Signed-off-by: xqt <info(a)gno.de>
Bug: T56557
Bug: T150222
Change-Id: I7d5cba11c2534b8ff90d10205cc399a06ce83590
---
M pywikibot/pagegenerators.py
M pywikibot/site.py
M tests/pagegenerators_tests.py
3 files changed, 100 insertions(+), 2 deletions(-)
Approvals:
Framawiki: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py
index 7be9948..b8aea84 100644
--- a/pywikibot/pagegenerators.py
+++ b/pywikibot/pagegenerators.py
@@ -252,6 +252,22 @@
is the string to look for, or "-searchitem:lang:text",
where lang is the langauge to search items in.
+-wantedpages Work on pages that are linked, but do not exist;
+ may be given as "-wantedpages:n" where n is the maximum
+ number of articles to work on.
+
+-wantedcategories Work on categories that are used, but do not exist;
+ may be given as "-wantedcategories:n" where n is the
+ maximum number of categories to work on.
+
+-wantedfiles Work on files that are used, but do not exist;
+ may be given as "-wantedfiles:n" where n is the maximum
+ number of files to work on.
+
+-wantedtemplates Work on templates that are used, but do not exist;
+ may be given as "-wantedtemplates:n" where n is the
+ maximum number of templates to work on.
+
-random Work on random pages returned by [[Special:Random]].
Can also be given as "-random:n" where n is the number
of pages to be returned.
@@ -737,6 +753,22 @@
return UnwatchedPagesPageGenerator(
total=_int_none(value), site=self.site)
+ def _handle_wantedpages(self, value):
+ """Handle `-wantedpages` argument."""
+ return self.site.wantedpages(total=_int_none(value))
+
+ def _handle_wantedfiles(self, value):
+ """Handle `-wantedfiles` argument."""
+ return self.site.wantedfiles(total=_int_none(value))
+
+ def _handle_wantedtemplates(self, value):
+ """Handle `-wantedtemplates` argument."""
+ return self.site.wantedtemplates(total=_int_none(value))
+
+ def _handle_wantedcategories(self, value):
+ """Handle `-wantedcategories` argument."""
+ return self.site.wantedcategories(total=_int_none(value))
+
def _handle_property(self, value):
"""Handle `-property` argument."""
if not value:
@@ -2427,6 +2459,7 @@
return site.pages_with_property(name, total=total)
+@deprecated('Site.wantedpages', since='20180803')
def WantedPagesPageGenerator(total=100, site=None):
"""
Wanted page generator.
@@ -2438,8 +2471,7 @@
"""
if site is None:
site = pywikibot.Site()
- for page in site.wantedpages(total=total):
- yield page
+ return site.wantedpages(total=total)
@deprecated_args(number="total", repeat=None)
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 304dcdc..29f3799 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -6653,6 +6653,7 @@
type_arg='querypage', gqppage='Unwatchedpages',
total=total)
+ @need_version('1.18')
@deprecated_args(step=None)
def wantedpages(self, total=None):
"""Yield Pages from Special:Wantedpages.
@@ -6663,6 +6664,27 @@
type_arg='querypage', gqppage='Wantedpages',
total=total)
+ @need_version('1.18')
+ def wantedfiles(self, total=None):
+ """Yield Pages from Special:Wantedfiles.
+
+ @param total: number of pages to return
+ """
+ return self._generator(api.PageGenerator,
+ type_arg='querypage', gqppage='Wantedfiles',
+ total=total)
+
+ @need_version('1.18')
+ def wantedtemplates(self, total=None):
+ """Yield Pages from Special:Wantedtemplates.
+
+ @param total: number of pages to return
+ """
+ return self._generator(api.PageGenerator,
+ type_arg='querypage', gqppage='Wantedtemplates',
+ total=total)
+
+ @need_version('1.18')
@deprecated_args(number='total', step=None, repeat=None)
def wantedcategories(self, total=None):
"""Yield Pages from Special:Wantedcategories.
diff --git a/tests/pagegenerators_tests.py b/tests/pagegenerators_tests.py
index e846b3c..fa6b956 100755
--- a/tests/pagegenerators_tests.py
+++ b/tests/pagegenerators_tests.py
@@ -1256,6 +1256,50 @@
self.assertPagesInNamespaces(gen, 1)
+class TestWantedFactoryGenerator(DefaultSiteTestCase):
+
+ """Test pagegenerators.GeneratorFactory for wanted pages."""
+
+ def setUp(self):
+ """Setup tests."""
+ super(TestWantedFactoryGenerator, self).setUp()
+ self.gf = pagegenerators.GeneratorFactory(site=self.site)
+
+ def _generator_with_tests(self):
+ """Test generator."""
+ gen = self.gf.getCombinedGenerator()
+ self.assertIsNotNone(gen)
+ pages = list(gen)
+ self.assertLessEqual(len(pages), 5)
+ for page in pages:
+ yield page
+
+ def test_wanted_pages(self):
+ """Test wantedpages generator."""
+ self.gf.handleArg('-wantedpages:5')
+ for page in self._generator_with_tests():
+ self.assertIsInstance(page, pywikibot.Page)
+
+ def test_wanted_files(self):
+ """Test wantedfiles generator."""
+ self.gf.handleArg('-wantedfiles:5')
+ for page in self._generator_with_tests():
+ self.assertIsInstance(page, pywikibot.FilePage)
+
+ def test_wanted_templates(self):
+ """Test wantedtemplates generator."""
+ self.gf.handleArg('-wantedtemplates:5')
+ for page in self._generator_with_tests():
+ self.assertIsInstance(page, pywikibot.Page)
+ self.assertEqual(page.namespace(), 10)
+
+ def test_wanted_categories(self):
+ """Test wantedcategories generator."""
+ self.gf.handleArg('-wantedcategories:5')
+ for page in self._generator_with_tests():
+ self.assertIsInstance(page, pywikibot.Category)
+
+
class TestFactoryGeneratorWikibase(WikidataTestCase):
"""Test pagegenerators.GeneratorFactory on Wikibase site."""
--
To view, visit https://gerrit.wikimedia.org/r/321089
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: I7d5cba11c2534b8ff90d10205cc399a06ce83590
Gerrit-Change-Number: 321089
Gerrit-PatchSet: 13
Gerrit-Owner: XXN <dan10real(a)gmail.com>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Multichill <maarten(a)mdammers.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
Gerrit-CC: Matěj Suchánek <matejsuchanek97(a)gmail.com>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/462197 )
Change subject: api.QueryGenerator._add_slots: Do not add slots if using deprecated parameters
......................................................................
api.QueryGenerator._add_slots: Do not add slots if using deprecated parameters
Usage of slots with deprecated parameters is forbidden by API.
Bug: T205210
Change-Id: I9e30e285d5928430e8ffe77fd628ddf75bf7c53c
---
M pywikibot/data/api.py
1 file changed, 27 insertions(+), 5 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 68ea978..2c801f9 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -2716,18 +2716,40 @@
if self.site.mw_version < '1.32':
return
request = self.request
+ # If using any deprecated_params, do not add slots. Usage of
+ # these parameters together with slots is forbidden and the user will
+ # get an API warning anyway.
props = request.get('prop')
if props:
if 'revisions' in props:
- request['rvslots'] = '*'
+ deprecated_params = {
+ 'rvexpandtemplates', 'rvparse', 'rvdiffto', 'rvdifftotext',
+ 'rvdifftotextpst', 'rvcontentformat', 'parsetree'}
+ if not set(request) & deprecated_params:
+ request['rvslots'] = '*'
if 'deletedrevisions' in props:
- request['drvslots'] = '*'
+ deprecated_params = {
+ 'drvexpandtemplates', 'drvparse', 'drvdiffto',
+ 'drvdifftotext', 'drvdifftotextpst', 'drvcontentformat',
+ 'parsetree'}
+ if not set(request) & deprecated_params:
+ request['drvslots'] = '*'
lists = request.get('list')
if lists:
if 'allrevisions' in lists:
- request['arvslots'] = '*'
- if 'deletedrevisions' in lists:
- request['adrslots'] = '*'
+ deprecated_params = {
+ 'arvexpandtemplates', 'arvparse', 'arvdiffto',
+ 'arvdifftotext', 'arvdifftotextpst', 'arvcontentformat',
+ 'parsetree'}
+ if not set(request) & deprecated_params:
+ request['arvslots'] = '*'
+ if 'alldeletedrevisions' in lists:
+ deprecated_params = {
+ 'adrexpandtemplates', 'adrparse', 'adrdiffto',
+ 'adrdifftotext', 'adrdifftotextpst', 'adrcontentformat',
+ 'parsetree'}
+ if not set(request) & deprecated_params:
+ request['adrslots'] = '*'
def set_query_increment(self, value):
"""Set the maximum number of items to be retrieved per API query.
--
To view, visit https://gerrit.wikimedia.org/r/462197
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: I9e30e285d5928430e8ffe77fd628ddf75bf7c53c
Gerrit-Change-Number: 462197
Gerrit-PatchSet: 4
Gerrit-Owner: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/462149 )
Change subject: api.QueryGenerator: Handle slots during initialization
......................................................................
api.QueryGenerator: Handle slots during initialization
This is a more general solution that replaces 304e52a and 057a50b.
Bug: T200955
Change-Id: I3afef82836d574d235c849d86c1a552614c3af9b
---
M pywikibot/data/api.py
M pywikibot/site.py
2 files changed, 34 insertions(+), 11 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index cc1fa7f..68ea978 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -1412,7 +1412,7 @@
if "action" not in parameters:
raise ValueError("'action' specification missing from Request.")
self.action = parameters['action']
- self.update(parameters)
+ self.update(parameters) # also convert all parameter values to lists
self._warning_handler = None
# Actions that imply database updates on the server, used for various
# things like throttling or skipping actions when we're in simulation
@@ -1612,11 +1612,11 @@
def __contains__(self, key):
"""Implement dict interface."""
- return self._params.__contains__(key)
+ return key in self._params
def __iter__(self):
"""Implement dict interface."""
- return self._params.__iter__()
+ return iter(self._params)
def __len__(self):
"""Implement dict interface."""
@@ -2697,6 +2697,37 @@
# "templates":{"tlcontinue":"310820|828|Namespace_detect"}}
# self.continuekey is a list
self.continuekey = self.modules
+ self._add_slots()
+
+ def _add_slots(self):
+ """Add slots to params if the site supports multi-content revisions.
+
+ On MW 1.32+ the following query parameters require slots to be given
+ when content or contentmodel is requested.
+
+ * prop=revisions
+ * prop=deletedrevisions or
+ * list=allrevisions
+ * list=alldeletedrevisions
+
+ More info:
+ https://lists.wikimedia.org/pipermail/mediawiki-api-announce/2018-August/00…
+ """
+ if self.site.mw_version < '1.32':
+ return
+ request = self.request
+ props = request.get('prop')
+ if props:
+ if 'revisions' in props:
+ request['rvslots'] = '*'
+ if 'deletedrevisions' in props:
+ request['drvslots'] = '*'
+ lists = request.get('list')
+ if lists:
+ if 'allrevisions' in lists:
+ request['arvslots'] = '*'
+ if 'deletedrevisions' in lists:
+ request['adrslots'] = '*'
def set_query_increment(self, value):
"""Set the maximum number of items to be retrieved per API query.
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 286f213..3cff718 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -3391,8 +3391,6 @@
else:
rvgen.request['titles'] = list(cache.keys())
rvgen.request['rvprop'] = rvprop
- if self.mw_version >= '1.32':
- rvgen.request['rvslots'] = '*'
pywikibot.output(u"Retrieving %s pages from %s."
% (len(cache), self))
@@ -4002,8 +4000,6 @@
elif endsort:
raise ValueError("categorymembers: "
"invalid combination of 'sortby' and 'endsort'")
- if content and self.mw_version >= '1.32':
- cmargs['rvslots'] = '*'
return self._generator(api.PageGenerator, namespaces=namespaces,
total=total, g_content=content, **cmargs)
@@ -4085,10 +4081,6 @@
rvargs = {'type_arg': 'info|revisions'}
rvargs['rvprop'] = ['ids', 'timestamp', 'flags', 'comment', 'user']
- if self.mw_version >= '1.32':
- rvargs['rvslots'] = '*'
- # 'roles' is not implemented in Revision class yet.
- # rvargs['rvprop'].append('roles')
if self.mw_version >= '1.21':
rvargs['rvprop'].append('contentmodel')
if self.mw_version >= '1.19':
--
To view, visit https://gerrit.wikimedia.org/r/462149
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: I3afef82836d574d235c849d86c1a552614c3af9b
Gerrit-Change-Number: 462149
Gerrit-PatchSet: 3
Gerrit-Owner: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/462174 )
Change subject: CREDITS: Add myself as contributor to the Pywikibot project
......................................................................
CREDITS: Add myself as contributor to the Pywikibot project
Added "Alangi Derick" as contributor to CREDITS file as a contributor
to the project. Thanks Xqt :)
Change-Id: I0062e9eb8d831f02f57c3ebddd90244781a330ee
---
M CREDITS
1 file changed, 2 insertions(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/CREDITS b/CREDITS
index dc861ca..a444f15 100644
--- a/CREDITS
+++ b/CREDITS
@@ -7,6 +7,7 @@
Ævar Arnfjörð Bjarmason
akashagarwal
AkshitKumar
+Alangi Derick
Alex Shih-Han Lin
Alexander Jones
Alexander Shtyrov
@@ -165,4 +166,4 @@
Yuri Astrakhan
Yusuke Matsubara
Zaher Kadour
-zhuyifei1999
\ No newline at end of file
+zhuyifei1999
--
To view, visit https://gerrit.wikimedia.org/r/462174
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: I0062e9eb8d831f02f57c3ebddd90244781a330ee
Gerrit-Change-Number: 462174
Gerrit-PatchSet: 1
Gerrit-Owner: D3r1ck01 <alangiderick(a)gmail.com>
Gerrit-Reviewer: D3r1ck01 <alangiderick(a)gmail.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/462148 )
Change subject: Use 'rvslots' when fetching categorymember() content on MW 1.32+
......................................................................
Use 'rvslots' when fetching categorymember() content on MW 1.32+
This is a temporary workaround to silence the API warnings. We perhaps need to
update the Revision class for other slot types in the future.
Bug: T200955
Change-Id: I842afdbbe659d17522697164d3dd216ae0860819
---
M pywikibot/site.py
1 file changed, 2 insertions(+), 0 deletions(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index c4a97e5..286f213 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -4002,6 +4002,8 @@
elif endsort:
raise ValueError("categorymembers: "
"invalid combination of 'sortby' and 'endsort'")
+ if content and self.mw_version >= '1.32':
+ cmargs['rvslots'] = '*'
return self._generator(api.PageGenerator, namespaces=namespaces,
total=total, g_content=content, **cmargs)
--
To view, visit https://gerrit.wikimedia.org/r/462148
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: I842afdbbe659d17522697164d3dd216ae0860819
Gerrit-Change-Number: 462148
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/462134 )
Change subject: [doc] Prepare next release
......................................................................
[doc] Prepare next release
Change-Id: I27399490557d6b115ca8b1f5bbc6ca8dd8b2f9e7
---
M HISTORY.rst
M docs/conf.py
2 files changed, 7 insertions(+), 1 deletion(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/HISTORY.rst b/HISTORY.rst
index 1b288b4..e0c3c86 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -4,6 +4,12 @@
Current release
---------------
+* Bugfixes and improvements
+* Localisation updates
+
+3.0.20180922
+------------
+
* Enable multiple streams for EventStreams (T205114)
* Fix Wikibase aliases handling (T194512)
* Remove cryptography support from python<=2.7.6 requirements (T203435)
diff --git a/docs/conf.py b/docs/conf.py
index 375d1e0..d10f7b9 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -71,7 +71,7 @@
# The short X.Y version.
version = '3.0'
# The full version, including alpha/beta/rc tags.
-release = '3.0.20180823'
+release = '3.0.20180922'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
--
To view, visit https://gerrit.wikimedia.org/r/462134
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: I27399490557d6b115ca8b1f5bbc6ca8dd8b2f9e7
Gerrit-Change-Number: 462134
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)