Utente:Sirbot/Script: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Riga 103:
# -*- coding: utf-8 -*-
"""
Questo script serve a compilare automaticamente il template monitoraggio basandosi sulla ricerca di immagini, fonti e template. Si prega di prestare attenzione alle modifiche effettuate dal bot.
basandosi sulla ricerca di immagini, fonti e template.
Si prega di prestare attenzione alle modifiche effettuate dal bot.
"""
#
Line 149 ⟶ 147:
newTalkText = talkText
regex = re.compile(r'(\[\[File:|\[\[Immagine:|\[\[Image:|\|Fotografia\s*=\s*|\|Immagine\s*=\s*|\|Copertina\s*=\s*)(?!Flag|\n|\\)\w+', re.IGNORECASE)
match = regex.search(pageText)
result = None
if match == None:
result = r'|immagini=d\1d\n'
else:
lista = regex.findall(pageText)
if len(lista) > 5:
result = r'|immagini=a\1a\n'
elif len(lista) > 3:
result = r'|immagini=b\1b\n'
elif len(lista) > 0:
result = r'|immagini=c\1c\n'
if result != None:
newTalkText = re.sub(r'\|\n? *?[Ii]mmagini ?= (\s?)(.*?)\n', result, newTalkText)
match regex= re.searchcompile(r'(\{\{ref|<ref.*)', pageText, re.IGNORECASE)
match = regex.search(pageText)
if match == None:
newTalkText = re.sub(r'\|\n? *?[Ff]onti ?= (\s?)(.*?)\n', r'|fonti=d\1d\n', newTalkText)
else:
newTalkText = re.sub(r'\|\n? *?[Ff]onti ?= ?d\n', r'|fonti= \n', newTalkText)
matchregex = re.searchcompile(r'(\{\{[Vv]etrina)', pageText, re.IGNORECASE)
match = regex.search(pageText)
if match is not None:
newTalkText = re.sub(r'\|\n? *?[Aa]ccuratezza ?= (\s?)(.*?)\n', r'|accuratezza=a\1a\n', newTalkText)
else:
matchregex = re.searchcompile(r'(\{\{[Ss]\|)', pageText, re.IGNORECASE)
match= regex.search(pageText)
if match is not None:
newTalkText = re.sub(r'\|\n? *?[Aa]ccuratezza ?=(\s?)(.*?)\n', r'|accuratezza=c\1c\n', newTalkText)
else:
matchregex = re.searchcompile(r'(\{\{[Aa]\|)', pageText, re.IGNORECASE)
match = regex.search(pageText)
if match is not None:
newTalkText = re.sub(r'\|\n? *?[Aa]ccuratezza ?= (\s?)(.*?)\n', r'|accuratezza=d\1d\n', newTalkText)
else:
newTalkText = re.sub(r'\|\n? *?[Aa]ccuratezza ?= ?[cd]\n', r'|accuratezza= \n', newTalkText)
matchregex = re.searchcompile(r'(\{\{[Dd]a correggere)', pageText, re.IGNORECASE)
match = regex.search(pageText)
if match is not None:
newTalkText = re.sub(r'\|\n? *?[Ss]crittura ?= (\s?)(.*?)\n', r'|scrittura=d\1d\n', newTalkText)
if talkText != newTalkText:
uName = wikipedia.getSite().username()
newTalkText = re.sub('\|\n? *?[Uu]tente ?= [^\n]*?\n', '|utente=' + uName + '<!-- monitoraggio eseguito via bot -->\n', newTalkText)
newTalkText = re.sub('\|\n? *?[Dd]ata ?= [^\n]*?\n', '|data={{subst:LOCALMONTHNAME}} {{subst:LOCALYEAR}}\n', newTalkText)
wikipedia.showDiff(talkText, newTalkText)
if not always:
choice = 'y' #wikipedia.inputChoice(u"Apply the changes?", ['Yes', 'No', 'All'], ['y', 'N', 'a'], 'N')
else:
choice = 'y'