jenkins-bot has submitted this change and it was merged.
Change subject: (bug 60610) define variables mysite, linktrail, pep8 changes
......................................................................
(bug 60610) define variables mysite, linktrail, pep8 changes
synchronized with compat
Change-Id: I0ca73f541c4fbd018aa9f2db1bf2229c15f13f13
---
M scripts/disambredir.py
1 file changed, 14 insertions(+), 10 deletions(-)
Approvals:
Huji: Verified; Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/disambredir.py b/scripts/disambredir.py
index faafec1..0a60870 100644
--- a/scripts/disambredir.py
+++ b/scripts/disambredir.py
@@ -5,16 +5,16 @@
each link that goes to a redirect page whether it should be replaced.
"""
#
-# (C) André Engels and others, 2006-2009
+# (c) André Engels and others, 2006-2009
+# (c) pywikibot team, 2006-2014
#
# Distributed under the terms of the MIT license.
#
__version__ = '$Id$'
#
+import re
import pywikibot
from pywikibot import pagegenerators
-import re
-from pywikibot import catlib
msg = {
'ar': u'تغيير التحويلات في صفحة توضيح',
@@ -37,11 +37,13 @@
def treat(text, linkedPage, targetPage):
- """
- Based on the method of the same name in solve_disambiguation.py.
- """
+ """ Based on the method of the same name in solve_disambiguation.py. """
# make a backup of the original text so we can show the changes later
- linkR = re.compile(r'\[\[(?P<title>[^\]\|#]*)(?P<section>#[^\]\|]*)?(\|(?P<label>[^\]]*))?\]\](?P<linktrail>' + linktrail + ')')
+ mysite = pywikibot.Site()
+ linktrail = mysite.linktrail()
+ linkR = re.compile(
+ r'\[\[(?P<title>[^\]\|#]*)(?P<section>#[^\]\|]*)?(\|(?P<label>[^\]]*))?\]\](?P<linktrail>%s)'
+ % linktrail)
curpos = 0
# This loop will run until we have finished the current page
while True:
@@ -68,7 +70,8 @@
'\03{default}' + text[m.end(): m.end() + context])
while True:
choice = pywikibot.input(
- u"Option (N=do not change, y=change link to \03{lightpurple}%s\03{default}, r=change and replace text, u=unlink)" % targetPage.title())
+ u"Option (N=do not change, y=change link to \03{lightpurple}%s\03{default}, r=change and replace text, u=unlink)"
+ % targetPage.title())
try:
choice = choice[0]
except:
@@ -102,8 +105,8 @@
if link_text[0].isupper():
new_page_title = targetPage.title()
else:
- new_page_title = targetPage.title()[0].lower() + \
- targetPage.title()[1:]
+ new_page_title = (targetPage.title()[0].lower() +
+ targetPage.title()[1:])
if replaceit and trailing_chars:
newlink = "[[%s%s]]%s" % (new_page_title, section, trailing_chars)
elif replaceit or (new_page_title == link_text and not section):
@@ -176,6 +179,7 @@
pagestoload = []
pagestodo = []
+
if __name__ == "__main__":
try:
main()
--
To view, visit https://gerrit.wikimedia.org/r/110330
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0ca73f541c4fbd018aa9f2db1bf2229c15f13f13
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Andre Engels <andreengels(a)gmail.com>
Gerrit-Reviewer: Huji <huji.huji(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>
Xqt has submitted this change and it was merged.
Change subject: api.py: Server504Error is already hadled by request.submit()
......................................................................
api.py: Server504Error is already hadled by request.submit()
Change-Id: I53a2265c50fceee0fc08455102e942661b3d71c2
---
M pywikibot/data/api.py
1 file changed, 1 insertion(+), 10 deletions(-)
Approvals:
Xqt: Verified; Looks good to me, approved
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 155a615..d40cb3c 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -663,16 +663,7 @@
if new_limit is not None:
self.request[self.prefix + "limit"] = str(new_limit)
if not hasattr(self, "data"):
- try:
- self.data = self.request.submit()
- except Server504Error:
- # server timeout, usually caused by request with high limit
- old_limit = self.query_limit
- if old_limit is None or old_limit < 2:
- raise
- pywikibot.log("Setting query limit to %s" % (old_limit // 2))
- self.set_query_increment(old_limit // 2)
- continue
+ self.data = self.request.submit()
if not self.data or not isinstance(self.data, dict):
pywikibot.debug(
u"%s: stopped iteration because no dict retrieved from api."
--
To view, visit https://gerrit.wikimedia.org/r/110577
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I53a2265c50fceee0fc08455102e942661b3d71c2
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.wiki(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 <>
Xqt has submitted this change and it was merged.
Change subject: new mw release 1.23wmf11
......................................................................
new mw release 1.23wmf11
Change-Id: I1245fed198b475de86033dfe8711f27cc5b295d9
---
M pywikibot/family.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Xqt: Verified; Looks good to me, approved
diff --git a/pywikibot/family.py b/pywikibot/family.py
index 5566798..611853e 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -1065,7 +1065,7 @@
"""Return Wikimedia projects version number as a string."""
# Don't use this, use versionnumber() instead. This only exists
# to not break family files.
- return '1.23wmf9'
+ return '1.23wmf11'
def shared_image_repository(self, code):
return ('commons', 'commons')
--
To view, visit https://gerrit.wikimedia.org/r/110549
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1245fed198b475de86033dfe8711f27cc5b295d9
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
Xqt has submitted this change and it was merged.
Change subject: api.PropertyGenerator: count queried items query and not only pages
......................................................................
api.PropertyGenerator: count queried items query and not only pages
Improvement of fix for:
https://sourceforge.net/support/tracker.php?aid=3569058
See also:
https://www.mediawiki.org/wiki/Special:Code/pywikipedia/10647
Change-Id: I80219732da947883f4b204c039d867996c26b37a
---
M pywikibot/data/api.py
M pywikibot/site.py
M tests/site_tests.py
3 files changed, 36 insertions(+), 3 deletions(-)
Approvals:
Xqt: Verified; Looks good to me, approved
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index a502d35..155a615 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -718,7 +718,16 @@
self.normalized = {}
for item in resultdata:
yield self.result(item)
- count += 1
+ if isinstance(item, dict) and set(self.continuekey) & set(item.keys()):
+ # if we need to count elements contained in items in
+ # self.data["query"]["pages"], we want to count
+ # item[self.continuekey] (e.g. 'revisions') and not
+ # self.resultkey (i.e. 'pages')
+ for key in set(self.continuekey) & set(item.keys()):
+ count += len(item[key])
+ # otherwise we proceed as usual
+ else:
+ count += 1
if self.limit > 0 and count >= self.limit:
return
if self.module == "random" and self.limit:
diff --git a/pywikibot/site.py b/pywikibot/site.py
index c5c9651..e3b505b 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -1943,7 +1943,6 @@
elif excludeuser:
rvgen.request[u"rvexcludeuser"] = excludeuser
# TODO if sysop: something
- rvgen.continuekey = "revisions"
for pagedata in rvgen:
if page is not None:
if not self.sametitle(pagedata['title'],
@@ -1956,7 +1955,6 @@
else:
page = pywikibot.Page(self, pagedata['title'])
api.update_page(page, pagedata)
- break
def pageinterwiki(self, page):
# No such function in the API (this method isn't called anywhere)
diff --git a/tests/site_tests.py b/tests/site_tests.py
index aed5620..8b8498e 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -964,6 +964,26 @@
self.assertFalse(mysite.hasExtension('anything', False))
del mysite._extensions
+ def test_API_limits_with_site_methods(self):
+ # test step/total parameters for different sitemethods
+ mypage = pywikibot.Page(mysite, 'Albert Einstein')
+ mycat = pywikibot.Page(mysite, 'Category:1879 births')
+
+ cats = [c for c in mysite.pagecategories(mypage, step=5, total=12)]
+ self.assertEqual(len(cats), 12)
+
+ cat_members = [cm for cm in mysite.categorymembers(mycat, step=5, total=12)]
+ self.assertEqual(len(cat_members), 12)
+
+ images = [im for im in mysite.pageimages(mypage, step=3, total=5)]
+ self.assertEqual(len(images), 5)
+
+ templates = [tl for tl in mysite.pagetemplates(mypage, step=3, total=5)]
+ self.assertEqual(len(templates), 5)
+
+ mysite.loadrevisions(mypage, step=5, total=12)
+ self.assertEqual(len(mypage._revisions), 12)
+
class TestSiteLoadRevisions(PywikibotTestCase):
"""Test cases for Site.loadrevision() method."""
@@ -984,6 +1004,12 @@
self.assertTrue(self.mainpage._revid in self.mainpage._revisions)
self.assertEqual(len(self.mainpage._revisions), 15)
+ def testLoadRevisions_querycontinue(self):
+ """Test the site.loadrevisions() method with query-continue"""
+
+ self.mysite.loadrevisions(self.mainpage, step=5, total=12)
+ self.assertEqual(len(self.mainpage._revisions), 12)
+
def testLoadRevisions_revdir(self):
"""Test the site.loadrevisions() method with rvdir=True"""
--
To view, visit https://gerrit.wikimedia.org/r/105522
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I80219732da947883f4b204c039d867996c26b37a
Gerrit-PatchSet: 8
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Yurik <yurik(a)wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>