jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] Logentries: Use the query's site argument
......................................................................
[FIX] Logentries: Use the query's site argument
The 'title' and 'new_title' methods of LogEntry and MoveEntry both don't
use the site used to generate the log entries but the default site
object.
This is a breaking change as LogEntry and LogEntryFactory now require a
site parameter.
Bug: T75723
Change-Id: Ia965ce5c4733f9fef84d58f556dd4b1f5d46fc8b
---
M pywikibot/data/api.py
M pywikibot/logentries.py
2 files changed, 12 insertions(+), 8 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 8aa97b4..0400f5d 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -1689,7 +1689,7 @@
ListGenerator.__init__(self, "logevents", **kwargs)
from pywikibot import logentries
- self.entryFactory = logentries.LogEntryFactory(logtype)
+ self.entryFactory = logentries.LogEntryFactory(self.site, logtype)
def result(self, pagedata):
return self.entryFactory.create(pagedata)
diff --git a/pywikibot/logentries.py b/pywikibot/logentries.py
index 5a71ad9..5b35cd8 100644
--- a/pywikibot/logentries.py
+++ b/pywikibot/logentries.py
@@ -37,9 +37,10 @@
# Overriden in subclasses.
_expectedType = None
- def __init__(self, apidata):
+ def __init__(self, apidata, site):
"""Initialize object from a logevent dict returned by MW API."""
self.data = LogDict(apidata)
+ self.site = site
if self._expectedType is not None and self._expectedType != self.type():
raise Error("Wrong log type! Expecting %s, received %s instead."
% (self._expectedType, self.type()))
@@ -59,7 +60,7 @@
def title(self):
"""Page on which action was performed."""
if not hasattr(self, '_title'):
- self._title = pywikibot.Page(pywikibot.Link(self.data['title']))
+ self._title = pywikibot.Page(self.site, self.data['title'])
return self._title
def type(self):
@@ -88,9 +89,9 @@
_expectedType = 'block'
- def __init__(self, apidata):
+ def __init__(self, apidata, site):
"""Constructor."""
- super(BlockEntry, self).__init__(apidata)
+ super(BlockEntry, self).__init__(apidata, site)
# see en.wikipedia.org/w/api.php?action=query&list=logevents&letype=block&lelimit…
# When an autoblock is removed, the "title" field is not a page title
# ( https://bugzilla.wikimedia.org/show_bug.cgi?id=17781 )
@@ -205,7 +206,7 @@
def new_title(self):
"""Return page object of the new title."""
if not hasattr(self, '_new_title'):
- self._new_title = pywikibot.Page(pywikibot.Link(self.data['move']['new_title']))
+ self._new_title = pywikibot.Page(self.site, self.data['move']['new_title'])
return self._new_title
def suppressedredirect(self):
@@ -261,15 +262,18 @@
'newusers': NewUsersEntry
}
- def __init__(self, logtype=None):
+ def __init__(self, site, logtype=None):
"""
Constructor.
+ @param site: The site on which the log entries are created.
+ @type site: BaseSite
@param logtype: The log type of the log entries, if known in advance.
If None, the Factory will fetch the log entry from
the data to create each object.
@type logtype: (letype) str : move/block/patrol/etc...
"""
+ self._site = site
if logtype is None:
self._creator = self._createFromData
else:
@@ -286,7 +290,7 @@
@return: LogEntry object representing logdata
"""
- return self._creator(logdata)
+ return self._creator(logdata, self._site)
@staticmethod
def _getEntryClass(logtype):
--
To view, visit https://gerrit.wikimedia.org/r/175414
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia965ce5c4733f9fef84d58f556dd4b1f5d46fc8b
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: Zhuyifei1999 <zhuyifei1999(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Set __signature__ in decorators
......................................................................
Set __signature__ in decorators
PEP 362 introduces __signature__ for functions as a way to alter
function arguments in a decorator in a way that can be reliably
inspected. It is first implemented in Python 3.3, but not complete
until Python 3.4, which includes inspect.unwrap. Back ports are
available, and should be used before __signature__ is relied upon.
Sphinx 1.3 on Python 3.4 uses the inspect module to automatically
describe function arguments, allowing documentation to be accurate
even in the presence of decorators.
deprecated_args updates the signature to include the deprecated
arguments, either providing a note in the default value, or
a default of NotImplemented if there is no substitute argument.
Change-Id: I2aeef8c8f31cdb01f18e199834b2f1a8ef8b043c
---
M pywikibot/site.py
M pywikibot/tools.py
2 files changed, 39 insertions(+), 1 deletion(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 1e6e614..2a55df6 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -30,7 +30,7 @@
from pywikibot.tools import (
itergroup, deprecated, deprecate_arg, UnicodeMixin, ComparableMixin,
redirect_func, add_decorated_full_name, deprecated_args,
- SelfCallDict, SelfCallString,
+ SelfCallDict, SelfCallString, signature,
)
from pywikibot.tools import MediaWikiVersion as LV
from pywikibot.throttle import Throttle
@@ -973,6 +973,7 @@
if not hasattr(fn, '__full_name__'):
add_decorated_full_name(fn)
callee.__full_name__ = fn.__full_name__
+ callee.__signature__ = signature(fn)
return callee
return decorator
@@ -1001,6 +1002,7 @@
callee.__name__ = fn.__name__
callee.__doc__ = fn.__doc__
callee.__module__ = fn.__module__
+ callee.__signature__ = signature(fn)
if not hasattr(fn, '__full_name__'):
add_decorated_full_name(fn)
callee.__full_name__ = fn.__full_name__
diff --git a/pywikibot/tools.py b/pywikibot/tools.py
index d71ad8a..d34291d 100644
--- a/pywikibot/tools.py
+++ b/pywikibot/tools.py
@@ -457,6 +457,26 @@
# a deprecator without any arguments.
+def signature(obj):
+ """
+ Safely return function Signature object (PEP 362).
+
+ inspect.signature was introduced in 3.3, however backports are available.
+ In Python 3.3, it does not support all types of callables, and should
+ not be relied upon. Python 3.4 works correctly.
+
+ Any exception calling inspect.signature is ignored and None is returned.
+
+ @param obj: Function to inspect
+ @rtype obj: callable
+ @rtype: inpect.Signature or None
+ """
+ try:
+ return inspect.signature(obj)
+ except (AttributeError, ValueError):
+ return None
+
+
def add_decorated_full_name(obj):
"""Extract full object name, including class, and store in __full_name__.
@@ -527,6 +547,7 @@
inner_wrapper.__doc__ = obj.__doc__
inner_wrapper.__name__ = obj.__name__
inner_wrapper.__module__ = obj.__module__
+ inner_wrapper.__signature__ = signature(obj)
# The decorator being decorated may have args, so both
# syntax need to be supported.
@@ -581,6 +602,7 @@
wrapper.__doc__ = obj.__doc__
wrapper.__name__ = obj.__name__
wrapper.__module__ = obj.__module__
+ wrapper.__signature__ = signature(obj)
return wrapper
without_parameters = len(args) == 1 and len(kwargs) == 0 and callable(args[0])
@@ -662,6 +684,20 @@
wrapper.__doc__ = obj.__doc__
wrapper.__name__ = obj.__name__
wrapper.__module__ = obj.__module__
+ wrapper.__signature__ = signature(obj)
+ if wrapper.__signature__:
+ # Build a new signature with deprecated args added.
+ params = collections.OrderedDict()
+ for param in wrapper.__signature__.parameters.values():
+ params[param.name] = param.replace()
+ for old_arg, new_arg in arg_pairs.items():
+ params[old_arg] = inspect.Parameter(
+ old_arg, kind=inspect._POSITIONAL_OR_KEYWORD,
+ default='[deprecated name of ' + new_arg + ']'
+ if new_arg not in [True, False, None]
+ else NotImplemented)
+ wrapper.__signature__ = inspect.Signature()
+ wrapper.__signature__._parameters = params
if not hasattr(obj, '__full_name__'):
add_decorated_full_name(obj)
wrapper.__full_name__ = obj.__full_name__
--
To view, visit https://gerrit.wikimedia.org/r/175419
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I2aeef8c8f31cdb01f18e199834b2f1a8ef8b043c
Gerrit-PatchSet: 5
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
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: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Add French support to dn_template
......................................................................
Add French support to dn_template
Requested and confirmed on IRC and French Wikipedia.
https://fr.wikipedia.org/w/index.php?diff=109292075&oldid=109291315
Change-Id: Ie3ee521600a5169b50ed3187a22097d643fe89ec
---
M scripts/solve_disambiguation.py
1 file changed, 1 insertion(+), 0 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/solve_disambiguation.py b/scripts/solve_disambiguation.py
index 9f26db8..fc03782 100644
--- a/scripts/solve_disambiguation.py
+++ b/scripts/solve_disambiguation.py
@@ -89,6 +89,7 @@
# Disambiguation Needed template
dn_template = {
'en': u'{{dn}}',
+ 'fr': u'{{Lien vers un homonyme}}',
}
# disambiguation page name format for "primary topic" disambiguations
--
To view, visit https://gerrit.wikimedia.org/r/175436
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie3ee521600a5169b50ed3187a22097d643fe89ec
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
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: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Allow unexpectedSuccess and expectedFailure
......................................................................
Allow unexpectedSuccess and expectedFailure
Python 3.4, and unittest2 0.8, error on unexpected successes
and warn on expected failure, if those conditions are not handled.
As these are used in pywikibot tests to capture current (usually wrong)
behaviour, and unexpected successes may be due to varying data and even
execution time in the case of script tests, it is not desirable
to fail the build as a consequence. They need to be investigated
by a human to determine why the behaviour changed.
One way to handle them is to add hooks on the TestCase subclass,
_addUnexpectedSuccess and _addExpectedFailure. This patch uses
that approach, reporting to stdout 'unexpected success' and
'expected failure', and marks the test as a success. This closely
resembles the behaviour in Python 2.7, 3.3 and unittest2 0.6.
Change-Id: I8468cb4507414d55f38ec1f73beda311029f4f44
---
M tests/aspects.py
1 file changed, 12 insertions(+), 0 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/aspects.py b/tests/aspects.py
index 00ee838..4aad55e 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -78,6 +78,18 @@
"""
return self.assertItemsEqual(*args, **kwargs)
+ def _addUnexpectedSuccess(self, result):
+ """Report and ignore."""
+ print(' unexpected success ', end='')
+ sys.stdout.flush()
+ result.addSuccess(self)
+
+ def _addExpectedFailure(self, result, exc_info=None):
+ """Report and ignore."""
+ print(' expected failure ', end='')
+ sys.stdout.flush()
+ result.addSuccess(self)
+
def assertPageInNamespaces(self, page, namespaces):
"""
Assert that Pages is in namespaces.
--
To view, visit https://gerrit.wikimedia.org/r/175329
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8468cb4507414d55f38ec1f73beda311029f4f44
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
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: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Require flickrapi 1.4.5 for Python 2
......................................................................
Require flickrapi 1.4.5 for Python 2
flickrapi 1.4.4 installs a logger, which breaks script tests.
flickrapi 1.4.5 and flickrapi 2.x do not have this problem.
Require at least 1.4.5 to avoid this problem, and allow users
to remain on a stable version with less dependencies.
This issue is not relevant to Python 3, as only flickrapi 2.x
will work on Python 3, and setuptools automatically selects it.
Bug: 71454
Change-Id: I58b732a3dae69797fe9bc27067a666c091be2e93
---
M requirements.txt
M setup.py
2 files changed, 17 insertions(+), 6 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/requirements.txt b/requirements.txt
index 08d005c..7547aef 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -38,6 +38,12 @@
argparse
# scripts/flickrripper.py
+# On Python 2, flickrapi 1.4.x or 2.x may be used. Only 2.x works on Python 3.
+# The following automatically selects 2.x on all Python versions, which depends
+# on requests 2.x, which may cause pip to report an error like the following:
+# pkg_resources.VersionConflict: (requests 1.2.3 (/usr/lib/python2.7/site-packages), Requirement.parse('requests>=2.2.1'))
+# If you see that on Python 2, change this to flickrapi==1.4.5
+# On Python 3, force pip to install requests 2.2.1, or remove flickrapi below.
Pillow
flickrapi
diff --git a/setup.py b/setup.py
index 564ad08..6bc7a38 100644
--- a/setup.py
+++ b/setup.py
@@ -33,11 +33,19 @@
script_deps = {
'script_wui.py': ['irc', 'lunatic-python', 'crontab'],
# Note: None of the 'lunatic-python' repos on github support MS Windows.
- 'flickrripper.py': ['Pillow', 'flickrapi'],
- # Note: 'PIL' is not available via pip2.7 on MS Windows,
- # however it is available with setuptools.
+ 'flickrripper.py': ['Pillow'],
'states_redirect.py': ['pycountry']
}
+# flickrapi 1.4.4 installs a root logger in verbose mode; 1.4.5 fixes this.
+# The problem doesnt exist in flickrapi 2.x.
+# pywikibot accepts flickrapi 1.4.5+ on Python 2, as it has been stable for a
+# long time, and only depends on python-requests 1.x, whereas flickrapi 2.x
+# depends on python-requests 2.x, which is first packaged in Ubuntu 14.04
+# and will be first packaged for Fedora Core 21.
+# flickrapi 1.4.x does not run on Python 3, and setuptools can only
+# select flickrapi 2.x for Python 3 installs.
+script_deps['flickrripper.py'].append('flickrapi' if sys.version_info[0] > 2
+ else 'flickrapi>=1.4.5')
dependency_links = [
'https://git.wikimedia.org/zip/?r=pywikibot/externals/httplib2.git&format=gz…',
@@ -63,8 +71,6 @@
print("ERROR: Python 3.3 or higher is required!")
sys.exit(1)
- dependency_links.append('hg+https://bitbucket.org/sybren/flickrapi#egg=flickrapi')
-
if os.name != 'nt':
# See bug 66010, Windows users will have issues
# when trying to build the C modules.
@@ -80,7 +86,6 @@
# so scripts can be compiled in test suite.
if 'PYSETUP_TEST_EXTRAS' in os.environ:
test_deps += list(itertools.chain(*(script_deps.values())))
-
# late import of setuptools due to monkey-patching above
from ez_setup import use_setuptools
--
To view, visit https://gerrit.wikimedia.org/r/171491
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I58b732a3dae69797fe9bc27067a666c091be2e93
Gerrit-PatchSet: 9
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
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: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Remove incorrect 'test_utils' in requirements.txt
......................................................................
Remove incorrect 'test_utils' in requirements.txt
test_utils was incorrectly placed into requirements.txt.
In fact that was an implicit local import rather than a
dependency on the external package of the same name.
The local module was removed in b55d584.
Change-Id: I9844196af5914fb3cea44ec27140592de25f0beb
---
M requirements.txt
1 file changed, 0 insertions(+), 3 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
Nullzero: Looks good to me, approved
jenkins-bot: Verified
diff --git a/requirements.txt b/requirements.txt
index 08d005c..415fd1d 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -41,9 +41,6 @@
Pillow
flickrapi
-# scripts/tests/test_data_ingestion.py
-test_utils
-
# incomplete core component botirc
irc
--
To view, visit https://gerrit.wikimedia.org/r/175328
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9844196af5914fb3cea44ec27140592de25f0beb
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
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: Nullzero <nullzero.free(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: WikiApiary AutoFamily
......................................................................
WikiApiary AutoFamily
WikiApiary is on the meta interwiki map ([[meta:IWM]]), and is a
useful dataset for the development of pywikibot, e.g. providing
lists of sites which use MediaWiki generator versions, which can
be used to test pywikibot against specific versions.
It will also be the only family registered in pywikibot that is
Semantic MediaWiki, so it may be useful when testing bugs relating
to Semantic MediaWiki.
Bug: 72854
Change-Id: Id5e7ee43e0ccf944f2375918fee7520c7884bf86
---
M pywikibot/config2.py
1 file changed, 1 insertion(+), 0 deletions(-)
Approvals:
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index 4d74265..57c47f2 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -252,6 +252,7 @@
# Get the names of all known families, and initialize with empty dictionaries.
# ‘families/’ is a subdirectory of the directory in which config2.py is found.
register_families_folder(os.path.join(os.path.dirname(__file__), 'families'))
+register_family_file('wikiapiary', 'https://wikiapiary.com')
# Set to True to override the {{bots}} exclusion protocol (at your own risk!)
ignore_bot_templates = False
--
To view, visit https://gerrit.wikimedia.org/r/170650
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id5e7ee43e0ccf944f2375918fee7520c7884bf86
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
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: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>