Utente:BimBot/Scripts: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
prefissiTelefonici.py: put asincrono, ché non si perde tempo.
prefissiTelefonici.py: con questa casistica dovrei aver eliminato i falsi positivi!
Riga 815:
def main():
all = False
args = wikipedia.handleArgs()
startWith=""
for argh in args:
if argh.startswith("-start:"):
startWith = argh[len("-start:"):]
% p.title())
mySite = wikipedia.getSite(code='it', fam='wikipedia')
cat = catlib.Category(mySite, "Categoria:Prefissi telefonici italiani")
gen = pagegenerators.CategorizedPageGenerator(cat, False, startWith)
for p in gen:
voceOk = 1
try:
oldText = p.get()
Line 827 ⟶ 833:
except wikipedia.IsRedirectPage:
p = p.getRedirectTarget()
oldText = currentPagep.get()
# Per sicurezza se non esegue tutti i match salta la voce
if not re.search("== ?[Nn]ote ?==", oldText):
continue
# Ottengo il prefisso "nudo" dal titolo
m = re.match("^(\d+)", p.title());
if m == None:
continue
prefisso = m.group(1)
newText = oldText
# Sostituzione 1
m = re.subn(r"il \[\[prefisso telefonico\]\] del \[\[distretto telefonico\|distretto\]\] di \[\[(.*?)\]\],",
r"il [[prefisso telefonico]] del [[distretto telefonico|distretto]] di [[\1]]" + note1 + ",",
newText, 1)
if not allm[1]==0:
continue
else:
newText = m[0]
# Sostituzione 2
newTextm = re.subsubn(r"\.\s*\{\{[Cc]ompartimento",
"' "' + note2 % prefisso + ".\n\n" + sezioneNote + "\n{{Compartimento",
newText, 1)
if m[1]==0:
continue
else:
newText = m[0]
# Sostituzione 3
newText = re.sub("\{\{[Ff](\|.*?)\}\}\s+", "", newText, 1)
# Visualizza le differenze, chiede e salva
if not re.search("== ?[Nn]ote ?==", oldText):
wikipedia.output(u"\n\n>>> \03{lightpurple}%s\03{default} <<<"
m = re.match("^(\d+)", p.title());
prefisso =% mp.grouptitle(1))
wikipedia.showDiff(oldText, newText)
newText = oldText
if not all:
wikipedia.output(u"\n\n>>> \03{lightpurple}%s\03{default} <<<"
choice = wikipedia.inputChoice(u"Modificare?",
% p.title())
['Yes', 'No', 'All', "Quit"],
newText ['y', = re.sub(","'N', note1 + ","'a', newText'q'], 1'N')
else:
newText = re.sub("\.\s*\{\{[Cc]ompartimento",
choice = 'y'
" " + note2 % prefisso + ".\n\n" + sezioneNote + "\n{{Compartimento",
if choice in ['A', 'a']:
newText, 1)
all = True
newText = re.sub("\{\{[Ff](\|.*?)\}\}\s+", "", newText, 1)
choice = 'y'
if choice in ['Y', 'y']:
wikipedia.showDiff(oldText, newText)
p.put_async(newText, minorEdit=False, comment=oggetto)
if not all:
elif choice in ['Q', 'q']:
choice = wikipedia.inputChoice(u"Modificare?",
return
['Yes', 'No', 'All', "Quit"],
['y', 'N', 'a', 'q'], 'N')
else:
choice = 'y'
if choice in ['A', 'a']:
all = True
choice = 'y'
if choice in ['Y', 'y']:
p.put_async(newText, minorEdit=False, comment=oggetto)
elif choice in ['Q', 'q']:
return
if __name__ == "__main__":