Revision: 7185
Author: a_engels
Date: 2009-08-28 20:52:34 +0000 (Fri, 28 Aug 2009)
Log Message:
-----------
adding command-line option -lack, to only work on pages lacking an interwiki to a
specified language.
Modified Paths:
--------------
trunk/pywikipedia/interwiki.py
Modified: trunk/pywikipedia/interwiki.py
===================================================================
--- trunk/pywikipedia/interwiki.py 2009-08-28 17:09:46 UTC (rev 7184)
+++ trunk/pywikipedia/interwiki.py 2009-08-28 20:52:34 UTC (rev 7185)
@@ -81,6 +81,11 @@
-skipauto use to skip all pages that can be translated automatically,
like dates, centuries, months, etc. (note: without ending colon)
+ -lack: used as -lack:xx with xx a language code: only work on pages
+ without links to language xx. You can also add a number nn
+ lick -lack:xx:nn, so that the bot only works on pages with
+ at least n interwiki links (the default value for n is 1).
+
These arguments are useful to provide hints to the bot:
-hint: used as -hint:de:Anweisung to give the robot a hint
@@ -506,6 +511,8 @@
nobackonly = False
hintsareright = False
contentsondisk = config.interwiki_contents_on_disk
+ lacklanguage = None
+ minlinks = 0
class StoredPage(wikipedia.Page):
"""
@@ -745,6 +752,7 @@
self.untranslated = None
self.hintsAsked = False
self.forcedStop = False
+ self.workonme = True
def getFoundDisambig(self, site):
"""
@@ -1007,6 +1015,9 @@
f.close()
def askForHints(self, counter):
+ if not self.workonme:
+ # Do not ask hints for pages that we don't work on anyway
+ return
if (self.untranslated or globalvar.askhints) and not self.hintsAsked and not
self.originPage.isRedirectPage():
# Only once!
self.hintsAsked = True
@@ -1138,6 +1149,13 @@
if globalvar.untranslatedonly:
# Ignore the interwiki links.
iw = ()
+ if globalvar.lacklanguage:
+ if globalvar.lacklanguage in [link.site().language() for link in
iw]:
+ iw = ()
+ self.workonme = False
+ if len(iw) < globalvar.minlinks:
+ iw = ()
+ self.workonme = False
elif globalvar.autonomous and duplicate:
@@ -1324,6 +1342,8 @@
be told to make another get request first."""
if not self.isDone():
raise "Bugcheck: finish called before done"
+ if not self.workonme:
+ return
if self.forcedStop:
wikipedia.output(u"======Aborted processing %s======" %
self.originPage.aslink(True))
return
@@ -2080,6 +2100,13 @@
globalvar.minsubjects = int(arg[7:])
elif arg.startswith('-query:'):
globalvar.maxquerysize = int(arg[7:])
+ elif arg.startswith('-lack:'):
+ remainder = arg[6:].split(':')
+ globalvar.lacklanguage = remainder[0]
+ if len(remainder) > 1:
+ globalvar.minlinks = int(remainder[1])
+ else:
+ globalvar.minlinks = 1
elif arg == '-back':
globalvar.nobackonly = True
else:
Show replies by date