Utente:BimBot/Scripts: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
m ops...
adesso dovrebbe andare
Riga 21:
ic = inputchoice()
if ic == u'.':
breaksafeexit()
if ic == u'P':
name = wikipedia.input(u'Inserisci il nome della pagina da cui ricavare i redirect [punto per terminare]:')
if name == u'.':
breaksafeexit()
page = wikipedia.Page(wikipedia.getSite(), name)
redirectLinks = getlinkstoredirectstopage(page)
Riga 31:
name = wikipedia.input(u'Inserisci il nome del redirect [punto per terminare]:')
if name == u'.':
breaksafeexit()
page = wikipedia.Page(wikipedia.getSite(), name)
redirectLinks[page.title()] = page.getReferences()
for i in redirectLinks:
print i
page = wikipedia.Page(wikipedia.getSite(), i)
dest = wikipedia.Page(wikipedia.getSite(), page.getRedirectTarget())
ref = redirectLinks[i]
for j in ref:
oldtext = j.get()
print j
lnks = sgamalink(i, oldtext)
for k in lnks:
print i"\n"
print "Nome del redirect: " + page.aslink()
print "Pagina a cui punta il redirect: " + dest.aslink()
print "Link in via di correzione: " + k
print "Pagina che contiene il link: " + j.aslink()
print j"\n"
if u'|' in k:
regex = u"\[\[%s\|(.*?)\]\]" % i
p = re.compile(regex, re.IGNORECASE)
lstdopolink = re.findallsearch(p, oldtext)
choice = u"[[" + dest.title() + u"|" + lst[0]dopolink.group(1) + u"]]"
else:
choice = linkchoice(dest.title(), i)
if choice == u'.':
exitsafeexit()
newtext = sistema(oldtext, page.title(), choice)
wikipedia.showDiff(oldtext, newtext)
choice = wikipedia.inputChoice(u'Posso procedere?', ['Yes', 'No'], ['y', 'N'], 'N')
if choice in ['Y', 'y']:
wikipedia.setAction(u'Correggo i link che puntano al redirect "%s"' % page.title())
j.put(newtext)
wikipedia.stopme();
 
def safeexit():
wikipedia.stopme()
exit()
 
def getlinkstoredirectstopage(page):
Line 96 ⟶ 104:
 
def sgamalink(oldtitle, oldtext):
regex = u"\[\[%s(.*?)\]\]" % oldtitle
p = re.compile(regex, re.IGNORECASE)
lst = re.findall(p, oldtext)
Line 104 ⟶ 112:
regex = u"\[\[%s.*?\]\]" % oldtitle
p = re.compile(regex, re.IGNORECASE)
text = re.sub(p, textchoice, choicetext)
return text
Line 110 ⟶ 118:
if __name__==u"__main__":
main()
 
</pre>