jenkins-bot has submitted this change and it was merged.
Change subject: bugfix; solve minor issue with different versions/implementations returning tuples of len 2 or 3
......................................................................
bugfix; solve minor issue with different versions/implementations returning tuples of len 2 or 3
Change-Id: I86b27fbb7e9682956e57f34d87086d48de89f233
---
M catimages.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
DrTrigon: Verified; Looks good to me, but someone else must approve
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/catimages.py b/catimages.py
index bdfa7bd..dbb4a8f 100644
--- a/catimages.py
+++ b/catimages.py
@@ -864,7 +864,7 @@
rvec, tvec = cv2.solvePnP(np.array(D3points).astype('float32'),
np.array(D2points).astype('float32'),
np.array(cameraMatrix).astype('float32'),
- None)
+ None)[-2:]
# compare to 2D points
err = []
--
To view, visit https://gerrit.wikimedia.org/r/129927
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I86b27fbb7e9682956e57f34d87086d48de89f233
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: DrTrigon <dr.trigon(a)surfeu.ch>
Gerrit-Reviewer: DrTrigon <dr.trigon(a)surfeu.ch>
Gerrit-Reviewer: Ladsgroup <ladsgroup(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 and Link: use 'rich' comparison
......................................................................
Page and Link: use 'rich' comparison
Py3 killed __cmp__, so we have to use the rich comparison operators
(__eq__, __ne__, etc.). To prevent having to define all six of them,
we use the ComparableMixin from [1] instead. Comparison is then
done using the tuple returned from self._cmpkey().
[1] http://python3porting.com/preparing.html
Change-Id: I2fa2b7322769beace6d3d42ca533943fe2b4c82b
---
M pywikibot/page.py
M pywikibot/tools.py
2 files changed, 39 insertions(+), 48 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index fe54ef6..cfb6fe8 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -15,7 +15,7 @@
from pywikibot import deprecated
from pywikibot import config
import pywikibot.site
-
+from pywikibot.tools import ComparableMixin
import hashlib
try:
@@ -42,7 +42,7 @@
# Note: Link objects (defined later on) represent a wiki-page's title, while
# Page objects (defined here) represent the page itself, including its contents.
-class Page(pywikibot.UnicodeMixin):
+class Page(pywikibot.UnicodeMixin, ComparableMixin):
"""Page: A MediaWiki page
This object only implements internally methods that do not require
@@ -223,23 +223,13 @@
return "%s(%s)" % (self.__class__.__name__,
self.title().encode(config.console_encoding))
- def __cmp__(self, other):
- """Test for equality and inequality of Page objects.
-
+ def _cmpkey(self):
+ """
Page objects are "equal" if and only if they are on the same site
and have the same normalized title, including section if any.
- Page objects are sortable by namespace first, then by title.
-
- """
- if not isinstance(other, Page):
- # especially, return -1 if other is None
- return -1
- if self.site != other.site:
- return cmp(self.site, other.site)
- if self.namespace() != other.namespace():
- return cmp(self.namespace(), other.namespace())
- return cmp(self._link.title, other._link.title)
+ Page objects are sortable by site, namespace then title."""
+ return (self.site, self.namespace(), self.title())
def __hash__(self):
# Pseudo method that makes it possible to store Page objects as keys
@@ -2393,25 +2383,6 @@
self.repo = self.site
self._isredir = False # Wikibase pages cannot be a redirect
- def __cmp__(self, other):
- """Test for equality and inequality of WikibasePage objects.
-
- Page objects are "equal" if and only if they are on the same site
- and have the same normalized title, including section if any.
-
- Page objects are sortable by namespace first, then by title.
-
- This is basically the same as Page.__cmp__ but slightly different.
- """
- if not isinstance(other, Page):
- # especially, return -1 if other is None
- return -1
- if self.site != other.site:
- return cmp(self.site, other.site)
- if self.namespace() != other.namespace():
- return cmp(self.namespace(), other.namespace())
- return cmp(self.title(), other.title())
-
def title(self, **kwargs):
if self.namespace() == 0:
self._link._text = self.getID()
@@ -3107,7 +3078,7 @@
self.minor = minor
-class Link(object):
+class Link(ComparableMixin):
"""A Mediawiki link (local or interwiki)
Has the following attributes:
@@ -3419,23 +3390,14 @@
def __str__(self):
return self.astext().encode("ascii", "backslashreplace")
- def __cmp__(self, other):
- """Test for equality and inequality of Link objects.
-
+ def _cmpkey(self):
+ """
Link objects are "equal" if and only if they are on the same site
and have the same normalized title, including section if any.
Link objects are sortable by site, then namespace, then title.
-
"""
- if not isinstance(other, Link):
- # especially, return -1 if other is None
- return -1
- if not self.site == other.site:
- return cmp(self.site, other.site)
- if self.namespace != other.namespace:
- return cmp(self.namespace, other.namespace)
- return cmp(self.title, other.title)
+ return (self.site, self.namespace, self.title)
def __unicode__(self):
return self.astext()
diff --git a/pywikibot/tools.py b/pywikibot/tools.py
index 3b5671b..31ca0ef 100644
--- a/pywikibot/tools.py
+++ b/pywikibot/tools.py
@@ -30,6 +30,35 @@
return self.__unicode__().encode('utf8')
+# From http://python3porting.com/preparing.html
+class ComparableMixin(object):
+ def _compare(self, other, method):
+ try:
+ return method(self._cmpkey(), other._cmpkey())
+ except (AttributeError, TypeError):
+ # _cmpkey not implemented, or return different type,
+ # so I can't compare with "other".
+ return NotImplemented
+
+ def __lt__(self, other):
+ return self._compare(other, lambda s, o: s < o)
+
+ def __le__(self, other):
+ return self._compare(other, lambda s, o: s <= o)
+
+ def __eq__(self, other):
+ return self._compare(other, lambda s, o: s == o)
+
+ def __ge__(self, other):
+ return self._compare(other, lambda s, o: s >= o)
+
+ def __gt__(self, other):
+ return self._compare(other, lambda s, o: s > o)
+
+ def __ne__(self, other):
+ return self._compare(other, lambda s, o: s != o)
+
+
class ThreadedGenerator(threading.Thread):
"""Look-ahead generator class.
--
To view, visit https://gerrit.wikimedia.org/r/130020
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I2fa2b7322769beace6d3d42ca533943fe2b4c82b
Gerrit-PatchSet: 5
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ladsgroup <ladsgroup(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: Add nocreate parameter to Site.editpage
......................................................................
Add nocreate parameter to Site.editpage
Change-Id: I2b1965fd931ecfcd194a3deac30c32801daa7935
---
M pywikibot/site.py
1 file changed, 5 insertions(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 583df32..cf48768 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -2660,7 +2660,8 @@
@must_be(group='user')
def editpage(self, page, summary, minor=True, notminor=False,
- bot=True, recreate=True, createonly=False, watch=None):
+ bot=True, recreate=True, createonly=False, nocreate=False,
+ watch=None):
"""Submit an edited Page object to be saved to the wiki.
@param page: The Page to be saved; its .text property will be used
@@ -2673,6 +2674,7 @@
title has previously been deleted
@param createonly: if True, raise an error if this title already
exists on the wiki
+ @param nocreate: if True, raise an error if the page does not exist
@param watch: Specify how the watchlist is affected by this edit, set
to one of "watch", "unwatch", "preferences", "nochange":
* watch: add the page to the watchlist
@@ -2720,6 +2722,8 @@
params['recreate'] = ""
if createonly:
params['createonly'] = ""
+ if nocreate:
+ params['nocreate'] = ""
if watch in ["watch", "unwatch", "preferences", "nochange"]:
params['watchlist'] = watch
elif watch:
--
To view, visit https://gerrit.wikimedia.org/r/132790
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I2b1965fd931ecfcd194a3deac30c32801daa7935
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipedia(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: Add Page.isFlowPage to check whether Flow is enabled on a given page
......................................................................
Add Page.isFlowPage to check whether Flow is enabled on a given page
Also adds Site.loadflowinfo to query the API
Bug: 65119
Change-Id: If830e022841918afe7866509380daddaafd036a4
---
M pywikibot/data/api.py
M pywikibot/page.py
M pywikibot/site.py
3 files changed, 29 insertions(+), 0 deletions(-)
Approvals:
Ladsgroup: Looks good to me, approved
Xqt: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 1a85255..ea462e2 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -1055,6 +1055,9 @@
if "pageprops" in pagedict:
page._pageprops = pagedict['pageprops']
+ if "flowinfo" in pagedict:
+ page._flowinfo = pagedict['flowinfo']['flow']
+
if __name__ == "__main__":
from pywikibot import Site, logging
diff --git a/pywikibot/page.py b/pywikibot/page.py
index fe54ef6..848f748 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -1579,6 +1579,14 @@
% (self.title(asLink=True), error.message))
return False
+ def isFlowPage(self):
+ """Whether the given title is a Flow page"""
+ if not self.site.hasExtension('Flow', False):
+ return False
+ if not hasattr(self, '_flowinfo'):
+ self.site.loadflowinfo(self)
+ return 'enabled' in self._flowinfo
+
# ####### DEPRECATED METHODS ########
@deprecated("Site.encoding()")
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 5e54f9f..583df32 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -1299,6 +1299,24 @@
return (pageitem['imageinfo']
if history else pageitem['imageinfo'][0])
+ def loadflowinfo(self, page):
+ """
+ Loads Flow-related information about a given page
+ Assumes that the Flow extension is installed
+ """
+ title = page.title(withSection=False)
+ query = self._generator(api.PropertyGenerator,
+ type_arg="flowinfo",
+ titles=title.encode(self.encoding()),
+ )
+ for pageitem in query:
+ if not self.sametitle(pageitem['title'], title):
+ pywikibot.warning(
+ u"loadflowinfo: Query on %s returned data on '%s'"
+ % (page, pageitem['title']))
+ continue
+ api.update_page(page, pageitem)
+
def page_exists(self, page):
"""Return True if and only if page is an existing page on site."""
if not hasattr(page, "_pageid"):
--
To view, visit https://gerrit.wikimedia.org/r/132767
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If830e022841918afe7866509380daddaafd036a4
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Multichill <maarten(a)mdammers.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Link to "www.mediawiki.org"
......................................................................
Link to "www.mediawiki.org"
Not including the www has some weird issues like bug 31369.
Change-Id: I3c981256e58b11f663b79d532f25b1ce1272b309
---
M setup.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Ladsgroup: Looks good to me, approved
jenkins-bot: Verified
diff --git a/setup.py b/setup.py
index ffefc78..207fa25 100644
--- a/setup.py
+++ b/setup.py
@@ -72,7 +72,7 @@
dependency_links=[
'https://git.wikimedia.org/zip/?r=pywikibot/externals/httplib2.git&format=gz…'
],
- url='https://mediawiki.org/wiki/Pywikibot',
+ url='https://www.mediawiki.org/wiki/Pywikibot',
download_url='https://github.com/wikimedia/pywikibot-core/archive/master.zip#egg=pywikibo…',
test_suite=testcollector,
tests_require=test_deps,
--
To view, visit https://gerrit.wikimedia.org/r/132766
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3c981256e58b11f663b79d532f25b1ce1272b309
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>