http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9463
Revision: 9463
Author: xqt
Date: 2011-08-28 14:29:29 +0000 (Sun, 28 Aug 2011)
Log Message:
-----------
doc fix
Modified Paths:
--------------
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2011-08-28 11:34:03 UTC (rev 9462)
+++ trunk/pywikipedia/wikipedia.py 2011-08-28 14:29:29 UTC (rev 9463)
@@ -1304,7 +1304,7 @@
The framework enforces this restriction by default. It is possible
to override this by setting ignore_bot_templates=True in
- user_config.py, or using page.put(force=True).
+ user-config.py, or using page.put(force=True).
"""
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9456
Revision: 9456
Author: russblau
Date: 2011-08-25 19:15:23 +0000 (Thu, 25 Aug 2011)
Log Message:
-----------
step down limits in case of server error, and use indexpageids option to iterate query results in correct order
Modified Paths:
--------------
branches/rewrite/pywikibot/data/api.py
Modified: branches/rewrite/pywikibot/data/api.py
===================================================================
--- branches/rewrite/pywikibot/data/api.py 2011-08-23 16:52:37 UTC (rev 9455)
+++ branches/rewrite/pywikibot/data/api.py 2011-08-25 19:15:23 UTC (rev 9456)
@@ -295,6 +295,16 @@
"Non-JSON response received from server %s; the server may be down."
% self.site)
pywikibot.debug(rawdata, _logger)
+ # there might also be an overflow, so try a smaller limit
+ for param in self.params:
+ if param.endswith("limit"):
+ value = self.params[param]
+ try:
+ self.params[param] = str(int(value) // 2)
+ pywikibot.output(u"Set %s = %s"
+ % (param, self.params[param]))
+ except:
+ pass
self.wait()
continue
if not result:
@@ -415,6 +425,7 @@
if name not in _modules:
self.get_module()
break
+ kwargs["indexpageids"] = "" # always ask for list of pageids
self.request = Request(**kwargs)
self.prefix = None
self.update_limit() # sets self.prefix
@@ -566,7 +577,14 @@
resultdata.keys(),
self.limit),
_logger)
- resultdata = [resultdata[k] for k in sorted(resultdata.keys())]
+ if "pageids" in self.data["query"]:
+ # this ensures that page data will be iterated
+ # in the same order as received from server
+ resultdata = [resultdata[k]
+ for k in self.data["query"]["pageids"]]
+ else:
+ resultdata = [resultdata[k]
+ for k in sorted(resultdata.keys())]
else:
pywikibot.debug(u"%s received %s; limit=%s"
% (self.__class__.__name__,
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9455
Revision: 9455
Author: xqt
Date: 2011-08-23 16:52:37 +0000 (Tue, 23 Aug 2011)
Log Message:
-----------
Create a new talk page if it does not exist
Modified Paths:
--------------
trunk/pywikipedia/unusedfiles.py
Modified: trunk/pywikipedia/unusedfiles.py
===================================================================
--- trunk/pywikipedia/unusedfiles.py 2011-08-21 18:31:37 UTC (rev 9454)
+++ trunk/pywikipedia/unusedfiles.py 2011-08-23 16:52:37 UTC (rev 9455)
@@ -13,6 +13,7 @@
#
# (C) Leonardo Gregianin, 2007
# (C) Filnik, 2008
+# (c) xqt, 2011
#
# Distributed under the terms of the MIT license.
#
@@ -61,15 +62,21 @@
def appendtext(page, apptext):
global always
- try:
+ if page.isRedirectPage():
+ page = page.getRedirectTarget()
+ if not page.exists():
+ if page.isTalkPage():
+ text = u''
+ else:
+ raise pywikibot.NoPage(u"Page '%s' does not exist" % page.title())
+ else:
text = page.get()
- except pywikibot.IsRedirectPage:
- return
# Here you can go editing. If you find you do not
# want to edit this page, just return
- text += apptext;
- if text != page.get():
- pywikibot.showDiff(page.get(),text)
+ oldtext = text
+ text += apptext
+ if text != oldtext:
+ pywikibot.showDiff(oldtext, text)
if not always:
choice = pywikibot.inputChoice(
u'Do you want to accept these changes?', ['Yes', 'No', 'All'],