Revision: 8807
Author: purodha
Date: 2010-12-27 21:34:11 +0000 (Mon, 27 Dec 2010)
Log Message:
-----------
Cosmetic changes.
Typos in documentation and more logical code ordering.
Modified Paths:
--------------
trunk/pywikipedia/basic.py
trunk/pywikipedia/config.py
trunk/pywikipedia/interwiki.py
Modified: trunk/pywikipedia/basic.py
===================================================================
--- trunk/pywikipedia/basic.py 2010-12-26 16:44:25 UTC (rev 8806)
+++ trunk/pywikipedia/basic.py 2010-12-27 21:34:11 UTC (rev 8807)
@@ -58,7 +58,7 @@
"""
Constructor. Parameters:
@param generator: The page generator that determines on which pages
- to work on.
+ to work.
@type generator: generator.
@param dry: If True, doesn't do any real changes, but only shows
what would have been changed.
Modified: trunk/pywikipedia/config.py
===================================================================
--- trunk/pywikipedia/config.py 2010-12-26 16:44:25 UTC (rev 8806)
+++ trunk/pywikipedia/config.py 2010-12-27 21:34:11 UTC (rev 8807)
@@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
#
# (C) Rob W.W. Hooft, 2003
+# parts by holger(a)trillke.net 2002/03/18
# Purodha Blissenbach (Modifier), 2010
-
+# (C) Pywikipedia bot team, 2007-2010
#
# Distributed under the terms of the MIT license.
#
@@ -467,7 +468,44 @@
# End of configuration section
# ============================
+def makepath(path):
+ """Return a normalized absolute version of the path argument.
+ - if the given path already exists in the filesystem
+ the filesystem is not modified.
+
+ - otherwise makepath creates directories along the given path
+ using the dirname() of the path. You may append
+ a '/' to the path if you want it to be a directory path.
+
+ from holger(a)trillke.net 2002/03/18
+
+ """
+ from os import makedirs
+ from os.path import normpath, dirname, exists, abspath
+
+ dpath = normpath(dirname(path))
+ if not exists(dpath): makedirs(dpath)
+ return normpath(abspath(path))
+
+def datafilepath(*filename):
+ """Return an absolute path to a data file in a standard location.
+
+ Argument(s) are zero or more directory names, optionally followed by a
+ data file name. The return path is offset to config.base_dir. Any
+ directories in the path that do not already exist are created.
+
+ """
+ import os
+ return makepath(os.path.join(base_dir, *filename))
+
+def shortpath(path):
+ """Return a file path relative to config.base_dir."""
+ import os
+ if path.startswith(base_dir):
+ return path[len(base_dir) + len(os.path.sep) : ]
+ return path
+
# is config verbose?
_verbose = False
for _arg in __sys.argv[1:]:
@@ -546,46 +584,6 @@
# Save base_dir for use by other modules
base_dir = _base_dir
-
-def makepath(path):
- """Return a normalized absolute version of the path argument.
-
- - if the given path already exists in the filesystem
- the filesystem is not modified.
-
- - otherwise makepath creates directories along the given path
- using the dirname() of the path. You may append
- a '/' to the path if you want it to be a directory path.
-
- from holger(a)trillke.net 2002/03/18
-
- """
- from os import makedirs
- from os.path import normpath, dirname, exists, abspath
-
- dpath = normpath(dirname(path))
- if not exists(dpath): makedirs(dpath)
- return normpath(abspath(path))
-
-def datafilepath(*filename):
- """Return an absolute path to a data file in a standard location.
-
- Argument(s) are zero or more directory names, optionally followed by a
- data file name. The return path is offset to config.base_dir. Any
- directories in the path that do not already exist are created.
-
- """
- import os
- return makepath(os.path.join(base_dir, *filename))
-
-def shortpath(path):
- """Return a file path relative to config.base_dir."""
- import os
- if path.startswith(base_dir):
- return path[len(base_dir) + len(os.path.sep) : ]
- return path
-
-
if _verbose:
print "- base_dir: ", base_dir
@@ -615,7 +613,7 @@
for _name in _k:
if _name[0] != '_':
if not type(globals()[_name]) in [types.FunctionType, types.ModuleType]:
- try:
+ try:
if _all or _glv[_name] != globals()[_name]:
print _name, "=", repr(globals()[_name])
except KeyError:
Modified: trunk/pywikipedia/interwiki.py
===================================================================
--- trunk/pywikipedia/interwiki.py 2010-12-26 16:44:25 UTC (rev 8806)
+++ trunk/pywikipedia/interwiki.py 2010-12-27 21:34:11 UTC (rev 8807)
@@ -276,7 +276,7 @@
For example, if the local page has links to de and fr,
this option will make sure that only the local site and
the de: (larger) sites are updated. This option is useful
- to quickly set two way links without updating all of
+ to quickly set two way links without updating all of the
wiki families sites.
(note: without ending colon)
Revision: 8806
Author: xqt
Date: 2010-12-26 16:44:25 +0000 (Sun, 26 Dec 2010)
Log Message:
-----------
Some Russian and Ukrainian translations (r8805); some update from trunk
Modified Paths:
--------------
branches/rewrite/scripts/basic.py
branches/rewrite/scripts/blockpageschecker.py
branches/rewrite/scripts/category.py
branches/rewrite/scripts/category_redirect.py
branches/rewrite/scripts/interwiki.py
branches/rewrite/scripts/interwiki_graph.py
branches/rewrite/scripts/replace.py
Modified: branches/rewrite/scripts/basic.py
===================================================================
--- branches/rewrite/scripts/basic.py 2010-12-26 16:43:08 UTC (rev 8805)
+++ branches/rewrite/scripts/basic.py 2010-12-26 16:44:25 UTC (rev 8806)
@@ -43,12 +43,14 @@
'fa': u'ربات: تغییر ...',
'fr': u'Robot: Changé ...',
'ja':u'ロボットによる:編集',
- 'ksh': u'Bot: Ännern ...',
- 'nds': u'Bot: Änderung ...',
+ 'ksh': u'Bot: Änderung ...',
+ 'nds': u'Bot: Ännern ...',
'nl': u'Bot: wijziging ...',
'pl': u'Bot: zmienia ...',
'pt': u'Bot: alterando...',
+ 'ru': u'Бот: изменил ...',
'sv': u'Bot: Ändrar ...',
+ 'uk': u'Бот: змінив ...',
'zh': u'機器人:編輯.....',
}
@@ -56,10 +58,10 @@
"""
Constructor. Parameters:
@param generator: The page generator that determines on which pages
- to work on.
+ to work on.
@type generator: generator.
@param dry: If True, doesn't do any real changes, but only shows
- what would have been changed.
+ what would have been changed.
@type dry: boolean.
"""
self.generator = generator
@@ -88,7 +90,7 @@
text = 'Test ' + text
if not self.save(text, page, self.summary):
- pywikibot.output(u'Page %s not saved.' % page.aslink())
+ pywikibot.output(u'Page %s not saved.' % page.title(asLink=True))
def load(self, page):
"""
@@ -99,10 +101,10 @@
text = page.get()
except pywikibot.NoPage:
pywikibot.output(u"Page %s does not exist; skipping."
- % page.title(asLink=True))
+ % page.title(asLink=True))
except pywikibot.IsRedirectPage:
pywikibot.output(u"Page %s is a redirect; skipping."
- % page.title(asLink=True))
+ % page.title(asLink=True))
else:
return text
return None
@@ -119,8 +121,8 @@
pywikibot.output(u'Comment: %s' %comment)
if not self.dry:
choice = pywikibot.inputChoice(
- u'Do you want to accept these changes?',
- ['Yes', 'No'], ['y', 'N'], 'N')
+ u'Do you want to accept these changes?',
+ ['Yes', 'No'], ['y', 'N'], 'N')
if choice == 'y':
try:
page.text = text
@@ -130,11 +132,13 @@
pywikibot.output(u"Page %s is locked; skipping."
% page.title(asLink=True))
except pywikibot.EditConflict:
- pywikibot.output(u'Skipping %s because of edit conflict'
- % (page.title()))
+ pywikibot.output(
+ u'Skipping %s because of edit conflict'
+ % (page.title()))
except pywikibot.SpamfilterError, error:
- pywikibot.output(u'Cannot change %s because of spam blacklist entry %s'
- % (page.title(), error.url))
+ pywikibot.output(
+u'Cannot change %s because of spam blacklist entry %s'
+ % (page.title(), error.url))
else:
return True
return False
Modified: branches/rewrite/scripts/blockpageschecker.py
===================================================================
--- branches/rewrite/scripts/blockpageschecker.py 2010-12-26 16:43:08 UTC (rev 8805)
+++ branches/rewrite/scripts/blockpageschecker.py 2010-12-26 16:44:25 UTC (rev 8806)
@@ -318,7 +318,10 @@
text, changes = re.subn('<noinclude>(%s)</noinclude>' % replaceToPerform, '', text)
if changes == 0:
text, changes = re.subn('(%s)' % replaceToPerform, '', text)
- pywikibot.output(u'The page is editable for all, deleting the template...')
+ msg = u'The page is editable for all'
+ if not moveBlockCheck:
+ msg += u', deleting the template..'
+ pywikibot.output(u'%s.' % msg)
elif editRestr[0] == 'sysop':
# total edit protection
@@ -371,23 +374,27 @@
# move-total-protection
if (TemplateInThePage[0] == 'sysop-move' and TTMP != None) or (TemplateInThePage[0] == 'unique' and TU != None):
pywikibot.output(u'The page is protected from moving to the sysop, skipping...')
+ if TU != None:
+ text = oldtext # no changes needed, better to revert the old text.
else:
pywikibot.output(u'The page is protected from moving to the sysop, but the template seems not correct. Fixing...')
- if TU != None:
- text, changes = re.subn(TemplateInThePage[1], TNR[4], text)
- else:
- text, changes = re.subn(TemplateInThePage[1], TNR[3], text)
+ if TU != None:
+ text, changes = re.subn(TemplateInThePage[1], TNR[4], text)
+ else:
+ text, changes = re.subn(TemplateInThePage[1], TNR[3], text)
elif TSMP != None or TU != None:
# implicitely moveRestr[0] = 'autoconfirmed', move-semi-protection
if TemplateInThePage[0] == 'autoconfirmed-move' or TemplateInThePage[0] == 'unique':
pywikibot.output(u'The page is movable only for the autoconfirmed users, skipping...')
+ if TU != None:
+ text = oldtext # no changes needed, better to revert the old text.
else:
pywikibot.output(u'The page is movable only for the autoconfirmed users, but the template seems not correct. Fixing...')
- if TU != None:
- text, changes = re.subn(TemplateInThePage[1], TNR[4], text)
- else:
- text, changes = re.subn(TemplateInThePage[1], TNR[2], text)
+ if TU != None:
+ text, changes = re.subn(TemplateInThePage[1], TNR[4], text)
+ else:
+ text, changes = re.subn(TemplateInThePage[1], TNR[2], text)
if changes == 0:
# We tried to fix move-protection templates, but it did not work.
Modified: branches/rewrite/scripts/category.py
===================================================================
--- branches/rewrite/scripts/category.py 2010-12-26 16:43:08 UTC (rev 8805)
+++ branches/rewrite/scripts/category.py 2010-12-26 16:44:25 UTC (rev 8806)
@@ -137,7 +137,7 @@
'sr':u'Бот: Додаје [[Категорија:%s]]',
'sv':u'Robot: Lägger till [[Kategori:%s]]',
'szl':u'Bot dodowo: [[Kategoria:%s]]',
- 'uk':u'Робот: додано [[Категорія:%s]]',
+ 'uk':u'Робот: додавання [[Категорія:%s]]',
'zh':u'機器人:新增目錄 [[Category:%s]]',
}
@@ -176,7 +176,7 @@
'sk':u'Robot zmenil [[%(oldcat)s]]→[[%(newcat)s]]',
'sr':u'Бот: Измена категорије %(oldcat)s',
'sv':u'Robot: Ändrar %(oldcat)s',
- 'uk':u'Робот: змінено [[Категорія:%(oldcat)s]]',
+ 'uk':u'Робот: зміна %(oldcat)s',
'zh':u'機器人:變更目錄 [[%(oldcat)s]]→[[%(newcat)s]]',
}
@@ -469,7 +469,7 @@
minorEdit=minorEdit, botflag=botflag)
except pywikibot.LockedPage:
pywikibot.output(u"Page %s is locked; skipping."
- % page.aslink())
+ % page.title(asLink=True))
except pywikibot.EditConflict:
pywikibot.output(
u'Skipping %s because of edit conflict'
@@ -502,11 +502,12 @@
else:
if self.sort:
catpl = self.sorted_by_last_name(catpl, page)
- pywikibot.output(u'Adding %s' % catpl.aslink())
+ pywikibot.output(u'Adding %s' % catpl.title(asLink=True))
cats.append(catpl)
text = pywikibot.replaceCategoryLinks(text, cats)
if not self.save(text, page, self.editSummary):
- pywikibot.output(u'Page %s not saved.' % page.aslink())
+ pywikibot.output(u'Page %s not saved.'
+ % page.title(asLink=True))
class CategoryMoveRobot:
@@ -982,6 +983,7 @@
'pt': u'(também em %s)',
'ru': u'(также в %s)',
'sv': u'(också i %s)',
+ 'uk': u'(також у %s)',
'ср': u'(такође у %s)',
'zh': u'(也在 %s)',
}
@@ -1066,8 +1068,6 @@
restore = False
create_pages = False
for arg in pywikibot.handleArgs(*args):
- if genFactory.handleArg(arg):
- continue
if arg == 'add':
action = 'add'
elif arg == 'remove':
@@ -1118,6 +1118,8 @@
recurse = True
elif arg == '-create':
create_pages = True
+ else:
+ genFactory.handleArg(arg)
gen = genFactory.getCombinedGenerator()
if action == 'add':
Modified: branches/rewrite/scripts/category_redirect.py
===================================================================
--- branches/rewrite/scripts/category_redirect.py 2010-12-26 16:43:08 UTC (rev 8805)
+++ branches/rewrite/scripts/category_redirect.py 2010-12-26 16:44:25 UTC (rev 8806)
@@ -118,6 +118,8 @@
'ksh': u"Bot: dubbel Ömleidung eruß jemaat.",
'pl': u"Robot: Poprawia podwójne przekierowanie",
'pt': u"Bot: Corrigindo redirecionamento duplo",
+ 'ru': u"Бот: исправление двойного перенаправления",
+ 'uk': u"Бот: виправлення подвійного перенаправлення",
'vi': u"Robot: sửa thể loại đổi hướng kép",
'zh': u"Bot: 修复双重重定向",
}
@@ -227,21 +229,16 @@
# an update due to changes in a transcluded template
article.put(newtext, comment)
if newtext == oldtext:
- pywikibot.output(
- u'No changes in made in page %s.'
- % article.title(asLink=True)
- )
+ pywikibot.output(u'No changes in made in page %s.'
+ % article.title(asLink=True))
return False
return True
except pywikibot.EditConflict:
- pywikibot.output(
- u'Skipping %s because of edit conflict'
- % article.title(asLink=True)
- )
+ pywikibot.output(u'Skipping %s because of edit conflict'
+ % article.title(asLink=True))
except pywikibot.LockedPage:
pywikibot.output(u'Skipping locked page %s'
- % article.title(asLink=True)
- )
+ % article.title(asLink=True))
self.edit_requests.append(
(article.title(asLink=True, textlink=True),
oldCat.title(asLink=True, textlink=True),
Modified: branches/rewrite/scripts/interwiki.py
===================================================================
--- branches/rewrite/scripts/interwiki.py 2010-12-26 16:43:08 UTC (rev 8805)
+++ branches/rewrite/scripts/interwiki.py 2010-12-26 16:44:25 UTC (rev 8806)
@@ -96,13 +96,15 @@
These arguments control miscellanous bot behaviour:
- -quiet: Use this option to get less output
+ -quiet Use this option to get less output
+ (note: without ending colon)
- -async: Put page on queue to be saved to wiki asynchronously. This
+ -async Put page on queue to be saved to wiki asynchronously. This
enables loading pages during saving throtteling and gives a
better performance.
NOTE: For post-processing it always assumes that saving the
the pages was sucessful.
+ (note: without ending colon)
-summary: Set an additional action summary message for the edit. This
could be used for further explainings of the bot action.
@@ -120,15 +122,15 @@
There are some special hints, trying a number of languages
at once:
- * all: All languages with at least ca. 100 articles.
- * 10: The 10 largest languages (sites with most
- articles). Analogous for any other natural
- number.
- * arab: All languages using the Arabic alphabet.
- * cyril: All languages that use the Cyrillic alphabet.
- * chinese: All Chinese dialects.
- * latin: All languages using the Latin script.
- * scand: All Scandinavian languages.
+ * all: All languages with at least ca. 100 articles.
+ * 10: The 10 largest languages (sites with most
+ articles). Analogous for any other natural
+ number.
+ * arab: All languages using the Arabic alphabet.
+ * cyril: All languages that use the Cyrillic alphabet.
+ * chinese: All Chinese dialects.
+ * latin: All languages using the Latin script.
+ * scand: All Scandinavian languages.
-hintfile: similar to -hint, except that hints are taken from the given
file, enclosed in [[]] each, instead of the command line.
@@ -248,9 +250,10 @@
-limittwo only update two pages - one in the local wiki (if logged-in)
and one in the top available one.
For example, if the local page has links to de and fr,
- this option will make sure that only local and de: (larger)
- site is updated. This option is useful to quickly set two
- way links without updating all of wiki's sites.
+ this option will make sure that only the local site and
+ the de: (larger) sites are updated. This option is useful
+ to quickly set two way links without updating all of
+ wiki families sites.
(note: without ending colon)
-whenneeded works like limittwo, but other languages are changed in the
@@ -298,8 +301,8 @@
to the interwiki-dumps subdirectory. The program will read it if invoked with
the "-restore" or "-continue" option, and finish all the subjects in that list.
After finishing the dump file will be deleted. To run the interwiki-bot on all
-pages on a language, run it with option "-start:!", and if it takes so long that
-you have to break it off, use "-continue" next time.
+pages on a language, run it with option "-start:!", and if it takes so long
+that you have to break it off, use "-continue" next time.
"""
#
@@ -1307,8 +1310,8 @@
elif not newhint:
break
else:
- pages = titletranslate.translate(self.originPage, hints = [newhint], auto = globalvar.auto, removebrackets
-= globalvar.hintnobracket)
+ pages = titletranslate.translate(self.originPage, hints=[newhint],
+ auto = globalvar.auto, removebrackets=globalvar.hintnobracket)
for page in pages:
self.addIfNew(page, counter, None)
if globalvar.hintsareright:
@@ -1597,6 +1600,7 @@
pywikibot.output(u" (%d) Found link to %s in:" % (i, page2))
self.whereReport(page2, indent = 8)
while True:
+ #TODO: allow answer to repeat previous or go back after a mistake
answer = pywikibot.input(u"Which variant should be used? (<number>, [n]one, [g]ive up) ").lower()
if answer:
if answer == 'g':
@@ -1627,6 +1631,7 @@
if acceptall:
answer = 'a'
else:
+ #TODO: allow answer to repeat previous or go back after a mistake
answer = pywikibot.inputChoice(u'What should be done?', ['accept', 'reject', 'give up', 'accept all'], ['a', 'r', 'g', 'l'], 'a')
if answer == 'l': # accept all
acceptall = True
Modified: branches/rewrite/scripts/interwiki_graph.py
===================================================================
--- branches/rewrite/scripts/interwiki_graph.py 2010-12-26 16:43:08 UTC (rev 8805)
+++ branches/rewrite/scripts/interwiki_graph.py 2010-12-26 16:44:25 UTC (rev 8806)
@@ -14,10 +14,6 @@
import pywikibot
from pywikibot import config2 as config
-# for speedyshare
-import re
-import httplib, urllib2, mimetypes
-
class GraphImpossible(Exception):
"Drawing a graph is not possible on your system."
@@ -87,8 +83,12 @@
sourceLabel = self.getLabel(refPage)
targetLabel = self.getLabel(page)
edge = pydot.Edge(sourceLabel, targetLabel)
+
oppositeEdge = self.graph.get_edge(targetLabel, sourceLabel)
if oppositeEdge:
+ if isinstance(oppositeEdge, list):
+ # bugfix for pydot >= 1.0.3
+ oppositeEdge = oppositeEdge[0]
#oppositeEdge.set_arrowtail('normal')
oppositeEdge.set_dir('both')
# workaround for bug [ 1722739 ]: prevent duplicate edges
@@ -140,96 +140,6 @@
self.addDirectedEdge(page, refPage)
self.saveGraphFile()
-class SpeedyShareUploader:
- def __init__(self):
- pass
-
- def getToken(self):
- formR = re.compile(
- '<form target=_top method="post" action="upload\.php\?(\d+)"')
-
- uploadPage = urllib2.urlopen(
- 'http://www.speedyshare.com/index_upload.php')
- text = uploadPage.read()
- token = formR.search(text).group(1)
- return token
-
- def post_multipart(self, host, selector, fields, files):
- """
- Post fields and files to an http host as multipart/form-data.
- fields is a sequence of (name, value) elements for regular form fields.
- files is a sequence of (name, filename, value) elements for data to be
- uploaded as files. Return the server's response page.
- """
- content_type, body = self.encode_multipart_formdata(fields, files)
- h = httplib.HTTP(host)
- h.putrequest('POST', selector)
- h.putheader('Content-Type', content_type)
- h.putheader('Content-Length', str(len(body)))
- h.putheader('User-Agent',
- 'Mozilla/5.0 (X11; U; Linux i686; de; rv:1.8) Gecko/20051128 SUSE/1.5-0.1 Firefox/1.5')
- h.putheader('Referer', 'http://www.speedyshare.com/index_upload.php')
- h.putheader('Accept',
- 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5')
- h.putheader('Accept-Language', 'de-de,de;q=0.8,en-us;q=0.5,en;q=0.3')
- h.putheader('Accept-Charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.7')
- h.putheader('Keep-Alive', '30')
- h.putheader('Connection', 'keep-alive')
-
- h.endheaders()
- h.send(body)
- errcode, errmsg, headers = h.getreply()
- return errcode, h.file.read()
-
- def encode_multipart_formdata(self, fields, files):
- """
- fields is a sequence of (name, value) elements for regular form fields.
- files is a sequence of (name, filename, value) elements for data to be
- uploaded as files. Return (content_type, body) ready for httplib.HTTP
- instance
- """
- BOUNDARY = '----------ThIs_Is_tHe_bouNdaRY_$'
- CRLF = '\r\n'
- L = []
- for (key, value) in fields:
- L.append('--' + BOUNDARY)
- L.append('Content-Disposition: form-data; name="%s"' % key)
- L.append('')
- L.append(value)
- for (key, filename, value) in files:
- L.append('--' + BOUNDARY)
- L.append(
- 'Content-Disposition: form-data; name="%s"; filename="%s"'
- % (key, filename))
- L.append('Content-Type: %s' % self.get_content_type(filename))
- L.append('')
- L.append(value)
- L.append('--' + BOUNDARY + '--')
- L.append('')
- body = CRLF.join(L)
- content_type = 'multipart/form-data; boundary=%s' % BOUNDARY
- return content_type, body
-
- def get_content_type(self, filename):
- return mimetypes.guess_type(filename)[0] \
- or 'application/octet-stream'
-
- def upload(self, filename):
- token = self.getToken()
-
- file = open(filename)
- encodedFilename = filename#.encode('utf-8')
- contents = file.read()
- formdata = []
-
- response, returned_html = self.post_multipart('www.speedyshare.com',
- 'upload.php?' + token,
- formdata,
- [('fileup0', encodedFilename, contents)])
- print response
- print returned_html
-
-
def getFilename(page, extension = None):
filename = '%s-%s-%s' % (page.site.family.name,
page.site.language(),
@@ -238,7 +148,3 @@
filename += '.%s' % extension
return filename
-if __name__ == "__main__":
- uploader = SpeedyShareUploader()
- uploader.upload(
- '/home/daniel/projekte/pywikipedia/interwiki-graphs/wikipedia-de-CEE.svg')
Modified: branches/rewrite/scripts/replace.py
===================================================================
--- branches/rewrite/scripts/replace.py 2010-12-26 16:43:08 UTC (rev 8805)
+++ branches/rewrite/scripts/replace.py 2010-12-26 16:44:25 UTC (rev 8806)
@@ -122,8 +122,9 @@
import sys, re, time
import pywikibot
-from pywikibot import pagegenerators, catlib, config
+from pywikibot import pagegenerators
from scripts import editarticle
+from pywikibot import catlib, config
import webbrowser
# Imports predefined replacements tasks from fixes.py
@@ -379,12 +380,12 @@
if self.isTextExcepted(new_text):
pywikibot.output(
u'Skipping %s because it contains text that is on the exceptions list.'
- % page.title(asLink=True))
+ % page.title(asLink=True))
break
new_text = self.doReplacements(new_text)
if new_text == original_text:
pywikibot.output(u'No changes were necessary in %s'
- % page.title(asLink=True))
+ % page.title(asLink=True))
break
if self.recursive:
newest_text = self.doReplacements(new_text)
@@ -406,7 +407,8 @@
break
choice = pywikibot.inputChoice(
u'Do you want to accept these changes?',
- ['Yes', 'No', 'Edit', 'open in Browser', 'All', "Quit"],
+ ['Yes', 'No', 'Edit', 'open in Browser', 'All',
+ 'Quit'],
['y', 'N', 'e', 'b', 'a', 'q'], 'N')
if choice == 'e':
editor = editarticle.TextEditor()
Revision: 8805
Author: xqt
Date: 2010-12-26 16:43:08 +0000 (Sun, 26 Dec 2010)
Log Message:
-----------
Some Russian and Ukrainian translations; minor changes from rewrite
Modified Paths:
--------------
trunk/pywikipedia/basic.py
trunk/pywikipedia/capitalize_redirects.py
trunk/pywikipedia/category.py
trunk/pywikipedia/category_redirect.py
trunk/pywikipedia/commonscat.py
trunk/pywikipedia/copyright_clean.py
trunk/pywikipedia/copyright_put.py
trunk/pywikipedia/delete.py
trunk/pywikipedia/disambredir.py
trunk/pywikipedia/interwiki.py
trunk/pywikipedia/replace.py
Modified: trunk/pywikipedia/basic.py
===================================================================
--- trunk/pywikipedia/basic.py 2010-12-26 15:06:15 UTC (rev 8804)
+++ trunk/pywikipedia/basic.py 2010-12-26 16:43:08 UTC (rev 8805)
@@ -48,17 +48,21 @@
'nl': u'Bot: wijziging ...',
'pl': u'Bot: zmienia ...',
'pt': u'Bot: alterando...',
+ 'ru': u'Бот: изменил ...',
'sv': u'Bot: Ändrar ...',
+ 'uk': u'Бот: змінив ...',
'zh': u'機器人:編輯.....',
}
def __init__(self, generator, dry):
"""
Constructor. Parameters:
- * generator - The page generator that determines on which pages
- to work on.
- * dry - If True, doesn't do any real changes, but only shows
- what would have been changed.
+ @param generator: The page generator that determines on which pages
+ to work on.
+ @type generator: generator.
+ @param dry: If True, doesn't do any real changes, but only shows
+ what would have been changed.
+ @type dry: boolean.
"""
self.generator = generator
self.dry = dry
Modified: trunk/pywikipedia/capitalize_redirects.py
===================================================================
--- trunk/pywikipedia/capitalize_redirects.py 2010-12-26 15:06:15 UTC (rev 8804)
+++ trunk/pywikipedia/capitalize_redirects.py 2010-12-26 16:43:08 UTC (rev 8805)
@@ -45,7 +45,9 @@
'ksh': u'Bot: oemleidung aanjelaat op [[%s]]',
'nl': u'Bot: doorverwijzing gemaakt naar [[%s]]',
'pt': u'Bot: Criando redirecionamento para [[%s]]',
+ 'ru': u'Бот: Создано перенаправление на [[%s]]',
'sv': u'Bot: Omdirigerar till [[%s]]',
+ 'uk': u'Бот: Створено перенаправлення на [[%s]]',
'zh': u'機器人: 建立重定向至[[%s]]',
}
Modified: trunk/pywikipedia/category.py
===================================================================
--- trunk/pywikipedia/category.py 2010-12-26 15:06:15 UTC (rev 8804)
+++ trunk/pywikipedia/category.py 2010-12-26 16:43:08 UTC (rev 8805)
@@ -428,7 +428,8 @@
except pywikibot.IsRedirectPage:
redirTarget = pywikibot.Page(site, arg.args[0])
pywikibot.output(u"WARNING: Page %s is a redirect to %s; skipping."
- % (page.title(asLink=True), redirTarget.title(asLink=True)))
+ % (page.title(asLink=True),
+ redirTarget.title(asLink=True)))
else:
return text
return None
Modified: trunk/pywikipedia/category_redirect.py
===================================================================
--- trunk/pywikipedia/category_redirect.py 2010-12-26 15:06:15 UTC (rev 8804)
+++ trunk/pywikipedia/category_redirect.py 2010-12-26 16:43:08 UTC (rev 8805)
@@ -127,6 +127,8 @@
'ksh': u"Bot: dubbel Ömleidung eruß jemaat.",
'pl': u"Robot: Poprawia podwójne przekierowanie",
'pt': u"Bot: Corrigindo redirecionamento duplo",
+ 'ru': u"Бот: исправление двойного перенаправления",
+ 'uk': u"Бот: виправлення подвійного перенаправлення",
'vi': u"Robot: sửa thể loại đổi hướng kép",
'zh': u"Bot: 修复双重重定向",
}
Modified: trunk/pywikipedia/commonscat.py
===================================================================
--- trunk/pywikipedia/commonscat.py 2010-12-26 15:06:15 UTC (rev 8804)
+++ trunk/pywikipedia/commonscat.py 2010-12-26 16:43:08 UTC (rev 8805)
@@ -163,7 +163,9 @@
'fr': u'Robot: Changé commonscat link de [[:Commons:Category:%(oldcat)s|%(oldcat)s]] à [[:Commons:Category:%(newcat)s|%(newcat)s]]',
'frr':u'Bot: Feranere commonscat link faan [[:Commons:Category:%(oldcat)s|%(oldcat)s]] tu [[:Commons:Category:%(newcat)s|%(newcat)s]]',
'pdc': u'Waddefresser: commonscat Gleecher vun [[:Commons:Category:%(oldcat)s|%(oldcat)s]] nooch [[:Commons:Category:%(newcat)s|%(newcat)s]] geennert',
+ 'ru': u'Бот: Изменение commonscat-ссылки с [[:Commons:Category:%(oldcat)s|%(oldcat)s]] на [[:Commons:Category:%(newcat)s|%(newcat)s]]',
'sk': u'Robot zmenil šablónu Commonscat z [[:Commons:Category:%(oldcat)s|%(oldcat)s]] na [[:Commons:Category:%(newcat)s|%(newcat)s]]',
+ 'uk': u'Бот: Зміна commonscat-посилання з [[:Commons:Category:%(oldcat)s|%(oldcat)s]] на [[:Commons:Category:%(newcat)s|%(newcat)s]]',
'th': u'บอต: เปลี่ยนลิงก์หมวดหมู่คอมมอนส์จาก [[:Commons:Category:%(oldcat)s|%(oldcat)s]] เป็น [[:Commons:Category:%(newcat)s|%(newcat)s]]',
}
Modified: trunk/pywikipedia/copyright_clean.py
===================================================================
--- trunk/pywikipedia/copyright_clean.py 2010-12-26 15:06:15 UTC (rev 8804)
+++ trunk/pywikipedia/copyright_clean.py 2010-12-26 16:43:08 UTC (rev 8805)
@@ -24,6 +24,8 @@
'fa': u'حذف',
'fr': u'Retiré',
'it': u'Rimozione',
+ 'ru': u'Удаление',
+ 'uk': u'Видалення',
}
headC = re.compile("(?m)^=== (?:<strike>)?(?:<s>)?(?:<del>)?\[\[(?::)?(.*?)\]\]")
Modified: trunk/pywikipedia/copyright_put.py
===================================================================
--- trunk/pywikipedia/copyright_put.py 2010-12-26 15:06:15 UTC (rev 8804)
+++ trunk/pywikipedia/copyright_put.py 2010-12-26 16:43:08 UTC (rev 8805)
@@ -35,19 +35,29 @@
'fa': {'_default': [u'محتویات جدید', u'محتویات جدید']},
'it': {'_default': [u'Pagine nuove', u'Nuove voci'],
'feed': [u'Aggiunte a voci esistenti', u'Testo aggiunto in']},
+ 'ru': {'_default': [u'Новые записи', u'Новые записи']},
+ 'uk': {'_default': [u'Нові записи', u'Нові записи']},
}
template_cat = {
- '_default': [u'This template is used by copyright.py, a script part of [[:m:Using the python wikipediabot|PyWikipediaBot]].', u''],
- 'it': [u'Questo template è usato dallo script copyright.py del [[:m:Using the python wikipediabot|PyWikipediaBot]].', u'Template usati da bot'],
+ '_default': [u'This template is used by copyright.py, a script part of [[:m:Using the python wikipediabot|PyWikipediaBot]].',
+ u''],
+ 'it': [u'Questo template è usato dallo script copyright.py del [[:m:Using the python wikipediabot|PyWikipediaBot]].',
+ u'Template usati da bot'],
}
stat_msg = {
'ar': [u'إحصاءات', u'صفحة', u'مدخلات', u'حجم', u'إجمالي', 'تحديث'],
'en': [u'Statistics', u'Page', u'Entries', u'Size', u'Total', 'Update'],
- 'es': [u'Estadísticas', u'Página', u'Entradas', u'Tamaño', u'Total', u'Actualizacion'],
+ 'es': [u'Estadísticas', u'Página', u'Entradas', u'Tamaño', u'Total',
+ u'Actualizacion'],
'fa': [u'آمار', u'صفحه', u'محتویات', u'اندازه', u'مجموع', 'بروزرسانی'],
- 'it': [u'Statistiche', u'Pagina', u'Segnalazioni', u'Lunghezza', u'Totale', u'Ultimo aggiornamento'],
+ 'it': [u'Statistiche', u'Pagina', u'Segnalazioni', u'Lunghezza', u'Totale',
+ u'Ultimo aggiornamento'],
+ 'ru': [u'Статистика', u'Страница', u'Записи', u'Размер', u'Всего',
+ u'Изменено'],
+ 'uk': [u'Статистика', u'Сторінка', u'Записи', u'Розмір', u'Разом',
+ u'Змінено'],
}
separatorC = re.compile('(?m)^== +')
Modified: trunk/pywikipedia/delete.py
===================================================================
--- trunk/pywikipedia/delete.py 2010-12-26 15:06:15 UTC (rev 8804)
+++ trunk/pywikipedia/delete.py 2010-12-26 16:43:08 UTC (rev 8805)
@@ -44,7 +44,9 @@
'nl': u'Bot: verwijdert een lijst met pagina\'s.',
'pl': u'Robot usuwa pliki z listy.',
'pt': u'Bot: Apagando um lista de arquivos.',
+ 'ru': u'Бот: Удаление списка файлов.',
'sv': u'Bot: Tar bort fillista.',
+ 'uk': u'Бот: Видалення списку файлів.',
}
msg_delete_category = {
'ar': u'روبوت - حذف كل الصفحات من التصنيف %s',
@@ -59,7 +61,9 @@
'nl': u'Bot: verwijdert alle pagina\'s uit categorie %s',
'pl': u'Robot usuwa wszystkie artykuły z kategorii %s',
'pt': u'Bot: Apagando todas as páginas da categoria %s',
+ 'ru': u'Бот: Удаление всех страниц из категории %s',
'sv': u'Bot: Tar bort alla sidor i kategori %s',
+ 'uk': u'Бот: Видалення усіх сторінок з категорії %s',
}
msg_delete_links = {
'ar': u'روبوت - حذف كل الصفحات الموصولة من %s',
@@ -73,7 +77,9 @@
'nl': u'Bot: verwijdert alle pagina\'s met een verwijzing naar %s',
'pl': u'Robot usuwa wszystkie artykuły zlinkowane z %s',
'pt': u'Bot: Apagando todas as páginas ligadas a %s',
+ 'ru': u'Бот: Удаление всех страниц связанных с %s',
'sv': u'Bot: Tar bort alla sidor länkade från %s',
+ 'uk': u'Бот: Видалення усіх сторінок, пов\'язаних із %s',
}
msg_delete_ref = {
'ar': u'روبوت - حذف كل الصفحات الراجعة من %s',
@@ -87,6 +93,8 @@
'nl': u'Bot: verwijdert alle pagina\'s met referentie van %s',
'pl': u'Robot usuwa wszystkie artykuły odnoszące się do %s',
'pt': u'Bot: Apagando todas as páginas afluentes a %s',
+ 'ru': u'Бот: Удаление всех страниц, относящихся к %s',
+ 'uk': u'Бот: Видалення усіх сторінок, що відносяться до %s',
}
msg_delete_images = {
'ar': u'روبوت -حذف كل الصور في الصفحة %s',
@@ -98,7 +106,9 @@
'nl': u'Bot: verwijdert alle media op pagina %s',
'pl': u'Robot usuwa wszystkie obrazy w artykule %s',
'pt': u'Bot: Apagando todas as imagens da página %s',
+ 'ru': u'Бот: Удаление всех изображений на странице %s',
'sv': u'Bot: Tar bort alla bilder på sida %s',
+ 'uk': u'Бот: Видалення усіх зображень із сторінки %s',
}
Modified: trunk/pywikipedia/disambredir.py
===================================================================
--- trunk/pywikipedia/disambredir.py 2010-12-26 15:06:15 UTC (rev 8804)
+++ trunk/pywikipedia/disambredir.py 2010-12-26 16:43:08 UTC (rev 8805)
@@ -25,6 +25,8 @@
'nl': u'Verandering van redirects op een doorverwijspagina',
'pl': u'Zmiana przekierowań na stronie ujednoznaczającej',
'pt': u'Arrumando redirects na página de desambiguação',
+ 'ru': u'Изменение перенаправлений на странице неоднозначности',
+ 'uk': u'Зміна перенаправлень на сторінці багатозначності',
'zh': u'機器人: 修改消歧義頁中的重定向連結',
}
Modified: trunk/pywikipedia/interwiki.py
===================================================================
--- trunk/pywikipedia/interwiki.py 2010-12-26 15:06:15 UTC (rev 8804)
+++ trunk/pywikipedia/interwiki.py 2010-12-26 16:43:08 UTC (rev 8805)
@@ -124,7 +124,7 @@
These arguments are useful to provide hints to the bot:
- -hint: used as -hint:de:Anweisung to give the robot a hint
+ -hint: used as -hint:de:Anweisung to give the robot a hint
where to start looking for translations. If no text
is given after the second ':', the name of the page
itself is used as the title for the hint, unless the
@@ -275,7 +275,7 @@
and one in the top available one.
For example, if the local page has links to de and fr,
this option will make sure that only the local site and
- the de: (larger) sites are updated. This option is useful
+ the de: (larger) sites are updated. This option is useful
to quickly set two way links without updating all of
wiki families sites.
(note: without ending colon)
@@ -1249,8 +1249,8 @@
else:
choice = pywikibot.inputChoice(u'WARNING: %s is a disambiguation page, but %s doesn\'t seem to be one. Follow it anyway?'
% (self.originPage.aslink(True), page.aslink(True)),
- ['Yes', 'No', 'Add an alternative', 'Give up'],
- ['y', 'n', 'a', 'g'])
+ ['Yes', 'No', 'Add an alternative', 'Give up'],
+ ['y', 'n', 'a', 'g'])
elif not self.originPage.isDisambig() and page.isDisambig():
nondisambig = self.getFoundNonDisambig(page.site())
if nondisambig:
@@ -1260,8 +1260,8 @@
else:
choice = pywikibot.inputChoice(u'WARNING: %s doesn\'t seem to be a disambiguation page, but %s is one. Follow it anyway?'
% (self.originPage.aslink(True), page.aslink(True)),
- ['Yes', 'No', 'Add an alternative', 'Give up'],
- ['y', 'n', 'a', 'g'])
+ ['Yes', 'No', 'Add an alternative', 'Give up'],
+ ['y', 'n', 'a', 'g'])
if choice == 'n':
return (True, None)
elif choice == 'a':
@@ -1318,8 +1318,8 @@
elif not newhint:
break
else:
- pages = titletranslate.translate(self.originPage, hints = [newhint],
- auto = globalvar.auto, removebrackets = globalvar.hintnobracket)
+ pages = titletranslate.translate(self.originPage, hints=[newhint],
+ auto = globalvar.auto, removebrackets=globalvar.hintnobracket)
for page in pages:
self.addIfNew(page, counter, None)
if globalvar.hintsareright:
Modified: trunk/pywikipedia/replace.py
===================================================================
--- trunk/pywikipedia/replace.py 2010-12-26 15:06:15 UTC (rev 8804)
+++ trunk/pywikipedia/replace.py 2010-12-26 16:43:08 UTC (rev 8805)
@@ -73,7 +73,7 @@
the bot will check every regex without waiting using all the
resources. This will slow it down between a regex and another
in order not to waste too much CPU.
-
+
-query: The maximum number of pages that the bot will load at once.
Default value is 60. Ignored when reading an XML file.
Revision: 8803
Author: xqt
Date: 2010-12-26 14:55:43 +0000 (Sun, 26 Dec 2010)
Log Message:
-----------
remove deprecated parameter -subcat; minor changes for dec strings
Modified Paths:
--------------
trunk/pywikipedia/pagegenerators.py
Modified: trunk/pywikipedia/pagegenerators.py
===================================================================
--- trunk/pywikipedia/pagegenerators.py 2010-12-26 14:54:05 UTC (rev 8802)
+++ trunk/pywikipedia/pagegenerators.py 2010-12-26 14:55:43 UTC (rev 8803)
@@ -323,7 +323,7 @@
genToReturn = NamespaceFilterPageGenerator(genToReturn, map(int, self.namespaces))
return genToReturn
- def getCategoryGen(self, arg, length, recurse = False):
+ def getCategoryGen(self, arg, length, recurse=False):
site = pywikibot.getSite()
if len(arg) == length:
categoryname = pywikibot.input(u'Please enter the category name:')
@@ -463,9 +463,6 @@
gen = self.setSubCategoriesGen(arg, 9, recurse = True)
elif arg.startswith('-subcats'):
gen = self.setSubCategoriesGen(arg, 8)
- # This parameter is deprecated, catr should be used instead.
- elif arg.startswith('-subcat'):
- gen = self.getCategoryGen(arg, 7, recurse = True)
elif arg.startswith('-page'):
if len(arg) == len('-page'):
gen = [pywikibot.Page(site,
@@ -699,38 +696,40 @@
yield page
def CategorizedPageGenerator(category, recurse=False, start=None):
- '''
- Yields all pages in a specific category.
+ """Yield all pages in a specific category.
If recurse is True, pages in subcategories are included as well; if
recurse is an int, only subcategories to that depth will be included
(e.g., recurse=2 will get pages in subcats and sub-subcats, but will
not go any further).
+
If start is a string value, only pages whose title comes after start
alphabetically are included.
- '''
+
+ """
# TODO: page generator could be modified to use cmstartsortkey ...
for a in category.articles(recurse=recurse, startFrom=start):
if start is None or a.title() >= start:
yield a
def SubCategoriesPageGenerator(category, recurse=False, start=None):
- '''
- Yields all subcategories in a specific category.
+ """Yield all subcategories in a specific category.
If recurse is True, pages in subcategories are included as well; if
recurse is an int, only subcategories to that depth will be included
(e.g., recurse=2 will get pages in subcats and sub-subcats, but will
not go any further).
+
If start is a string value, only categories whose sortkey comes after
start alphabetically are included.
- '''
+
+ """
# TODO: page generator could be modified to use cmstartsortkey ...
for s in category.subcategories(recurse=recurse, startFrom=start):
yield s
def LinkedPageGenerator(linkingPage):
- """Yields all pages linked from a specific page."""
+ """Yield all pages linked from a specific page."""
for page in linkingPage.linkedPages():
yield page
@@ -1314,7 +1313,7 @@
-if __name__ == "__main__":
+def main(*args):
try:
genFactory = GeneratorFactory()
for arg in pywikibot.handleArgs():
@@ -1332,3 +1331,7 @@
pywikibot.showHelp('pagegenerators')
finally:
pywikibot.stopme()
+
+
+if __name__=="__main__":
+ main()
Revision: 8802
Author: xqt
Date: 2010-12-26 14:54:05 +0000 (Sun, 26 Dec 2010)
Log Message:
-----------
doc for -page parameter
Modified Paths:
--------------
branches/rewrite/pywikibot/pagegenerators.py
Modified: branches/rewrite/pywikibot/pagegenerators.py
===================================================================
--- branches/rewrite/pywikibot/pagegenerators.py 2010-12-26 14:14:49 UTC (rev 8801)
+++ branches/rewrite/pywikibot/pagegenerators.py 2010-12-26 14:54:05 UTC (rev 8802)
@@ -150,6 +150,9 @@
-yahoo Work on all pages that are found in a Yahoo search.
Depends on python module pYsearch. See yahoo_appid in
config.py for instructions.
+
+-page Work on a single page. Argument can also be given as
+ "-page:pagetitle".
"""
docuReplacements = {'¶ms;': parameterHelp}
@@ -318,11 +321,11 @@
self.limit = int(arg[len('-limit:'):])
return True
elif arg.startswith('-catr'):
- gen = self.getCategoryGen(arg, len("-catr"), recurse = True)
+ gen = self.getCategoryGen(arg, len('-catr'), recurse = True)
elif arg.startswith('-category'):
gen = self.getCategoryGen(arg, len('-category'))
elif arg.startswith('-cat'):
- gen = self.getCategoryGen(arg, len("-cat"))
+ gen = self.getCategoryGen(arg, len('-cat'))
elif arg.startswith('-subcatsr'):
gen = self.setSubCategoriesGen(arg, 9, recurse = True)
elif arg.startswith('-subcats'):
Revision: 8801
Author: xqt
Date: 2010-12-26 14:14:49 +0000 (Sun, 26 Dec 2010)
Log Message:
-----------
enable unlimit mediawiki search but limit all generators by -limit:n
Modified Paths:
--------------
trunk/pywikipedia/pagegenerators.py
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/pagegenerators.py
===================================================================
--- trunk/pywikipedia/pagegenerators.py 2010-12-26 12:30:13 UTC (rev 8800)
+++ trunk/pywikipedia/pagegenerators.py 2010-12-26 14:14:49 UTC (rev 8801)
@@ -84,6 +84,9 @@
pages on several wiki sites, this is not well tested,
so check your edits!
+-limit:n When used with any other argument that specifies a set
+ of pages, work on no more than n pages in total
+
-links Work on all pages that are linked from a certain page.
Argument can also be given as "-links:linkingpagetitle".
@@ -298,6 +301,7 @@
def __init__(self):
self.gens = []
self.namespaces = []
+ self.limit = None
def getCombinedGenerator(self, gen=None):
"""Returns the combination of all accumulated generators,
@@ -314,7 +318,7 @@
gensList = self.gens[0]
else:
gensList = CombinedPageGenerator(self.gens)
- genToReturn = DuplicateFilterPageGenerator(gensList)
+ genToReturn = DuplicateFilterPageGenerator(gensList, total=self.limit)
if (self.namespaces):
genToReturn = NamespaceFilterPageGenerator(genToReturn, map(int, self.namespaces))
return genToReturn
@@ -443,6 +447,12 @@
else:
self.namespaces.extend(arg[len('-ns:'):].split(","))
return True
+ elif arg.startswith('-limit'):
+ if len(arg) == len('-limit'):
+ self.limit = int(pywikibot.input("What is the limit value?"))
+ else:
+ self.limit = int(arg[len('-limit:'):])
+ return True
elif arg.startswith('-catr'):
gen = self.getCategoryGen(arg, len('-catr'), recurse = True)
elif arg.startswith('-category'):
@@ -565,7 +575,7 @@
mediawikiQuery = pywikibot.input(
u'What do you want to search for?')
# In order to be useful, all namespaces are required
- gen = SearchPageGenerator(mediawikiQuery, namespaces = [])
+ gen = SearchPageGenerator(mediawikiQuery, number=None, namespaces=[])
elif arg.startswith('-google'):
gen = GoogleSearchPageGenerator(arg[8:])
elif arg.startswith('-titleregex'):
@@ -1148,16 +1158,21 @@
if not page.isRedirectPage():
yield page
-def DuplicateFilterPageGenerator(generator):
+def DuplicateFilterPageGenerator(generator, total=None):
"""
Wraps around another generator. Yields all pages, but prevents
duplicates.
"""
seenPages = dict()
+ count = 0
for page in generator:
_page = u"%s:%s:%s" % (page._site.family.name, page._site.lang, page._title)
if _page not in seenPages:
seenPages[_page] = True
+ if total:
+ count += 1
+ if count > total:
+ break
yield page
def RegexFilterPageGenerator(generator, regex, inverse=False, ignore_namespace=True):
@@ -1309,8 +1324,10 @@
else:
gen = genFactory.getCombinedGenerator()
if gen:
+ i = 0
for page in gen:
- pywikibot.output(page.title(), toStdout = True)
+ i+=1
+ pywikibot.output("%s: %s" % (repr(i).rjust(4), page.title()), toStdout = True)
else:
pywikibot.showHelp('pagegenerators')
finally:
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2010-12-26 12:30:13 UTC (rev 8800)
+++ trunk/pywikipedia/wikipedia.py 2010-12-26 14:14:49 UTC (rev 8801)
@@ -5938,7 +5938,7 @@
self._getUserDataOld(text, sysop = sysop, force = force)
- def search(self, key, number = 10, namespaces = None):
+ def search(self, key, number=10, namespaces=None):
"""
Yield search results for query.
Use API when enabled use_api and version >= 1.11,
@@ -5950,13 +5950,14 @@
'action': 'query',
'list': 'search',
'srsearch': key,
- 'srlimit': number
}
+ if number:
+ params['srlimit'] = number
if namespaces:
params['srnamespace'] = namespaces
offset = 0
- while offset < number:
+ while offset < number or not number:
params['sroffset'] = offset
data = query.GetData(params, self)['query']
if 'error' in data: