Utente:BimBot/Scripts: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Nessun oggetto della modifica
Riga 76:
Prende le pagine da [[Speciale:Lonelypages]], verifica che siano veramente orfane e inserisce l'avviso in quelle che non lo hanno già.
 
Script spostato [http://www.botwiki.sno.cc/wiki/Python:Lonelypages.py qui].
<source lang="python">
# -*- coding: utf-8 -*-
 
#
# (C) Pietrodn it.wiki
# (C) Filnik it.wiki
# lonelypages.py - version: 1.5
#
 
import wikipedia
import re
from pagegenerators import AllpagesPageGenerator
 
def main():
args = wikipedia.handleArgs()
wikiSite = wikipedia.getSite()
allfunction = False
allpages = wikiSite.lonelypages(number = 10000, repeat = True)
for i in allpages:
#if i.title()[0] in ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I']:
#continue
if i.isRedirectPage() or i.isDisambig():
wikipedia.output("%s is a Redirect or a disambig, skip..." % i.title())
continue
refs = i.getReferences()
refsList = list()
for j in refs:
if j == None:
continue
refsList = refsList.append(j)
if refsList != []:
wikipedia.output("The page isn't orphan...")
continue
elif refsList == None:
continue # FIXME: ????
else:
try:
oldtxt = i.get()
except wikipedia.NoPage:
wikipedia.output("%s doesn't exist! Skip.." % i.title())
except wikipedia.IsRedirectPage:
wikipedia.output("%s is a redirect! Skip..." % i.title())
if '{{o}}' in oldtxt.lower() or '{{o|' in oldtxt.lower():
wikipedia.output("The page has already the template!")
continue
else:
newtxt = u'{{O||mese={{subst:CURRENTMONTH}} {{subst:CURRENTYEAR}}}}\n' + oldtxt
wikipedia.output("\t\t>>> %s <<<" % i.title())
wikipedia.showDiff(oldtxt, newtxt)
choice = 'y'
if not allfunction:
choice = wikipedia.inputChoice(u'Pagina orfana non segnalata! Posso procedere?', [u'Yes', u'No', u'All'], [u'y', u'n', u'a'], [u'Y', u'N', 'A'])
if choice in [u'A', u'a', u'all', u'All']:
allfunction = True
choice = 'y'
if choice.lower() in [u'y', u'yes']:
try:
i.put(newtxt, u'Bot: Voce orfana, aggiungo template {{O}}')
except wikipedia.EditConflict:
wikipedia.output('Edit Conflict! Skip...')
 
if "__main__" == __name__:
try:
main()
finally:
wikipedia.stopme()
 
</source>
 
== Il mio <tt>benvenuto.py</tt> ==