Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #3362
Status: Errored
Duration: 1 hour, 20 minutes, and 25 seconds
Commit: f655663 (master)
Author: Mpaa
Message: Page.namespace() shall return Namespace() for pages in Main ns
For pages in Main ns, page.namespace() shall return a Namespace()
object instead on an int().
Note: bool(namespace) is now True when namespace is Main.
So explicit test vs. Namespace.MAIN is needed to discriminate if
namespace is Main or not.
Bug: T104864
Change-Id: I15667db612b5e3d7a65319e203065a0b33aa45ad
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/cff48cfd0015...f6556636…
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/118948804
--
You can configure recipients for build notifications in your .travis.yml file. See https://docs.travis-ci.com/user/notifications
jenkins-bot has submitted this change and it was merged.
Change subject: site.py: prefixindex should also return non-redirects by default
......................................................................
site.py: prefixindex should also return non-redirects by default
The prefixindex function was only returning redirects by default which
was unintuitive.
To fix that, calculate the appropriate value for filterredir before passing
it to allpages() and try to keep the new implementation backward compatible
with the original one.
See the following commits for the original implementation:
- df1292d96469bae6d06c919d5c1260025b3848c2
- 187f51bb7d9b4a5083e436d0c7027ea441da4eed
Change-Id: Ib486292f2596612e7709ab44a563a207b8e2b58b
---
M pywikibot/site.py
1 file changed, 7 insertions(+), 1 deletion(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index aac59f5..e366f5b 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -3966,8 +3966,14 @@
Use allpages() with the prefix= parameter instead of this method.
"""
+ if not includeredirects:
+ filterredir = False
+ elif includeredirects == 'only':
+ filterredir = True
+ else:
+ filterredir = None
return self.allpages(prefix=prefix, namespace=namespace,
- filterredir=includeredirects)
+ filterredir=filterredir)
@deprecated_args(step=None)
def alllinks(self, start="!", prefix="", namespace=0, unique=False,
--
To view, visit https://gerrit.wikimedia.org/r/274809
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib486292f2596612e7709ab44a563a207b8e2b58b
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Solve usage of expectedFailure for tools_tests.py
......................................................................
Solve usage of expectedFailure for tools_tests.py
Bug: T130985
Change-Id: I60a6398f78d3f3dedea8073fa355662eef443cb9
---
M pywikibot/tools/__init__.py
M tests/tools_tests.py
2 files changed, 11 insertions(+), 4 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index c2c5bba..cb3e0be 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -759,6 +759,8 @@
used automatically. Any other method may be provided explicitly using the
add parameter.
+ Beware that key=id is only useful for cases where id() is not unique.
+
Note: This is not thread safe.
@param iterable: the source iterable
diff --git a/tests/tools_tests.py b/tests/tools_tests.py
index 2d0935e..d48cfb0 100644
--- a/tests/tools_tests.py
+++ b/tests/tools_tests.py
@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
"""Test tools package alone which don't fit into other tests."""
#
-# (C) Pywikibot team, 2015
+# (C) Pywikibot team, 2016
#
# Distributed under the terms of the MIT license.
from __future__ import absolute_import, unicode_literals
@@ -409,13 +409,18 @@
deduper = tools.filter_unique(self.decs, container=deduped, key=hash)
self._test_dedup_int(deduped, deduper, hash)
- @unittest.expectedFailure
def test_obj_id(self):
"""Test filter_unique with objects using id as key, which fails."""
- # Two objects which may be equal do not have the same id.
+ # Two objects which may be equal do not necessary have the same id.
deduped = set()
deduper = tools.filter_unique(self.decs, container=deduped, key=id)
- self._test_dedup_int(deduped, deduper, id)
+ self.assertEqual(len(deduped), 0)
+ for _ in self.decs:
+ self.assertEqual(id(next(deduper)), deduped.pop())
+ self.assertRaises(StopIteration, next, deduper)
+ # No. of Decimal with distinct ids != no. of Decimal with distinct value.
+ deduper_ids = list(tools.filter_unique(self.decs, key=id))
+ self.assertNotEqual(len(deduper_ids), len(set(deduper_ids)))
def test_str(self):
"""Test filter_unique with str."""
--
To view, visit https://gerrit.wikimedia.org/r/278456
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I60a6398f78d3f3dedea8073fa355662eef443cb9
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(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: Page.namespace() shall return Namespace() for pages in Main ns
......................................................................
Page.namespace() shall return Namespace() for pages in Main ns
For pages in Main ns, page.namespace() shall return a Namespace()
object instead on an int().
Note: bool(namespace) is now True when namespace is Main.
So explicit test vs. Namespace.MAIN is needed to discriminate if
namespace is Main or not.
Bug: T104864
Change-Id: I15667db612b5e3d7a65319e203065a0b33aa45ad
---
M pywikibot/page.py
1 file changed, 12 insertions(+), 14 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index c0c8294..d2793ac 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -4873,7 +4873,7 @@
self._source = source or pywikibot.Site()
self._text = text
- self._defaultns = defaultNamespace
+ self._defaultns = self._source.namespaces[defaultNamespace]
# preprocess text (these changes aren't site-dependent)
# First remove anchor, which is stored unchanged, if there is one
@@ -4988,7 +4988,7 @@
while u":" in t:
# Initial colon indicates main namespace rather than default
if t.startswith(u":"):
- self._namespace = 0
+ self._namespace = self._site.namespaces[0]
# remove the colon but continue processing
# remove any subsequent whitespace
t = t.lstrip(u":").lstrip(u" ")
@@ -5146,7 +5146,8 @@
def canonical_title(self):
"""Return full page title, including localized namespace."""
- if self.namespace:
+ # Avoid that ':' will be added to the title for Main ns.
+ if self.namespace != Namespace.MAIN:
return "%s:%s" % (self.site.namespace(self.namespace),
self.title)
else:
@@ -5162,26 +5163,23 @@
@raise pywikibot.Error: no corresponding namespace is found in onsite
"""
- ns_id = self.namespace
- ns = self.site.namespaces[ns_id]
-
if onsite is None:
- namespace = ns.canonical_name
+ name = self.namespace.canonical_name
else:
# look for corresponding ns in onsite by name comparison
- for alias in ns:
+ for alias in self.namespace:
namespace = onsite.namespaces.lookup_name(alias)
- if namespace:
- namespace = namespace.custom_name
+ if namespace is not None:
+ name = namespace.custom_name
break
else:
# not found
raise pywikibot.Error(
u'No corresponding namespace found for namespace %s on %s.'
- % (self.site.namespaces[ns_id], onsite))
+ % (self.namespace, onsite))
- if namespace:
- return u'%s:%s' % (namespace, self.title)
+ if self.namespace != Namespace.MAIN:
+ return u'%s:%s' % (name, self.title)
else:
return self.title
@@ -5196,7 +5194,7 @@
if onsite is None:
onsite = self._source
title = self.title
- if self.namespace:
+ if self.namespace != Namespace.MAIN:
title = onsite.namespace(self.namespace) + ":" + title
if self.section:
title = title + "#" + self.section
--
To view, visit https://gerrit.wikimedia.org/r/279726
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I15667db612b5e3d7a65319e203065a0b33aa45ad
Gerrit-PatchSet: 8
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(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: [doc] Improve some doc strings
......................................................................
[doc] Improve some doc strings
- add some @rtype tags
- start multiline string at new line
Change-Id: I1152b3eca575eef965dd02d5f5cda0d28c09c5ab
---
M pywikibot/data/api.py
1 file changed, 22 insertions(+), 12 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 1969c90..c3f1ddf 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -1831,14 +1831,15 @@
@classmethod
def _build_mime_request(cls, params, mime_params):
- """Construct a MIME multipart form post.
+ """
+ Construct a MIME multipart form post.
@param params: HTTP request params
@type params: dict
@param mime_params: HTTP request parts which must be sent in the body
@type mime_params: dict of (content, keytype, headers)
@return: HTTP request headers and body
- @rtype: (headers, body)
+ @rtype: tuple (dict, str)
"""
# construct a MIME message containing all API key/values
container = MIMEMultipart(_subtype='form-data')
@@ -1883,10 +1884,11 @@
pywikibot.warning(u"API warning (%s): %s" % (mod, single_warning))
def submit(self):
- """Submit a query and parse the response.
+ """
+ Submit a query and parse the response.
@return: a dict containing data retrieved from api.php
-
+ @rtype: dict
"""
self._add_defaults()
if (not config.enable_GET_without_SSL and
@@ -2216,11 +2218,13 @@
@classmethod
def _get_cache_dir(cls):
- """Return the base directory path for cache entries.
+ """
+ Return the base directory path for cache entries.
The directory will be created if it does not already exist.
- @return: basestring
+ @return: base directory path for cache entries
+ @rtype: basestring
"""
path = os.path.join(pywikibot.config2.base_dir, 'apicache')
cls._make_dir(path)
@@ -2228,14 +2232,16 @@
@staticmethod
def _make_dir(dir):
- """Create directory if it does not exist already.
+ """
+ Create directory if it does not exist already.
The directory name (dir) is returned unmodified.
@param dir: directory path
@type dir: basestring
- @return: basestring
+ @return: directory name
+ @rtype: basestring
"""
try:
os.makedirs(dir)
@@ -2352,7 +2358,8 @@
class APIGenerator(_RequestWrapper):
- """Iterator that handle API responses containing lists.
+ """
+ Iterator that handle API responses containing lists.
The iterator will iterate each item in the query response and use the
continue request parameter to retrieve the next portion of items
@@ -2425,7 +2432,8 @@
% (self.__class__.__name__, self.limit), _logger)
def __iter__(self):
- """Submit request and iterate the response.
+ """
+ Submit request and iterate the response.
Continues response as needed until limit (if defined) is reached.
"""
@@ -2458,7 +2466,8 @@
class QueryGenerator(_RequestWrapper):
- """Base class for iterators that handle responses to API action=query.
+ """
+ Base class for iterators that handle responses to API action=query.
By default, the iterator will iterate each item in the query response,
and use the (query-)continue element, if present, to continue iterating as
@@ -2475,7 +2484,8 @@
"""
def __init__(self, **kwargs):
- """Construct a QueryGenerator object.
+ """
+ Construct a QueryGenerator object.
kwargs are used to create a Request object; see that object's
documentation for values. 'action'='query' is assumed.
--
To view, visit https://gerrit.wikimedia.org/r/278885
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1152b3eca575eef965dd02d5f5cda0d28c09c5ab
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>