Utente:Sirbot/Script: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
mNessun oggetto della modifica
monitoraggio.py: bugfix; sfoltimento di routine inutili; ora è più snello e leggibile, dà meno output e fa una modifica al posto di molte
Riga 101:
<source lang="python">
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
README: Todo
Riga 127:
discussioni = categoria.articles()
for page in discussioni:
page = wikipedia.Page(wikipedia.getSite(), "Discussione:Snuff_(gruppo_musicale)") #DEBUG
if not page.isTalkPage():
continue
Line 135 ⟶ 137:
print e # Print the error and skip
continue
try:
talkText = page.get()
except wikipedia.Error, e:
print e # Print the error and skip
continue
wikipedia.output(">>>>> %s <<<<<" % associatedPage.title())
newTalkText = talkText
match = re.search(r'(\[\[Immagine|\[\[Image|\|Fotografia\s*=[^\|\n]+[^\|\n\s]+[^\|\n]+|\|Marchio\s*=[^\|\n]+[^\|\n\s]+[^\|\n]+)', pageText, re.IGNORECASE)
if match == None:
newTalkText = re.sub('\|\n? *?[Ii]mmagini ?= *?\n', '|immagini=d\n', newTalkText)
wikipedia.output(">>>>> %s <<<<<" % associatedPage.title())
try:
talkText = page.get()
except wikipedia.Error, e:
print e # Print the error and skip
continue
newTalkText = re.sub('\|\n? *?[Ii]mmagini ?= *?\n', '|immagini=d\n', talkText)
if talkText != newTalkText:
wikipedia.showDiff(talkText, newTalkText)
if not always:
choice = wikipedia.inputChoice(u"Apply the changes?", ['Yes', 'No', 'All'], ['y', 'N', 'a'], 'N')
else:
choice = 'y'
if choice in ['A', 'a']:
always = True
choice = 'y'
if choice in ['Y', 'y']:
try:
page.put(newTalkText, u'[[WP:BOT|Bot]]: Non ci sono immagini: valutazione "d"')
except wikipedia.Error, e:
print e # Print the error and skip
continue
if match is not None:
newTalkText = re.sub('\|\n? *?[Ii]mmagini ?= ?d\n', '|immagini= \n', newTalkText)
wikipedia.output(">>>>> %s <<<<<" % associatedPage.title())
try:
talkText = page.get()
except wikipedia.Error, e:
print e # Print the error and skip
continue
newTalkText = re.sub('\|\n? *?[Ii]mmagini ?= ?d\n', '|immagini= \n', talkText)
if talkText != newTalkText:
wikipedia.showDiff(talkText, newTalkText)
if not always:
choice = wikipedia.inputChoice(u"Apply the changes?", ['Yes', 'No', 'All'], ['y', 'N', 'a'], 'N')
else:
choice = 'y'
if choice in ['A', 'a']:
always = True
choice = 'y'
if choice in ['Y', 'y']:
try:
page.put(newTalkText, u'[[WP:BOT|Bot]]: Trovate immagini: rimuovo valutazione "d"')
except wikipedia.Error, e:
print e # Print the error and skip
continue
match = re.search('(<ref.*)', pageText, re.IGNORECASE)
if match == None:
wikipedianewTalkText = re.outputsub(">>>>>'\|\n? %s*?[Ff]onti <<<<<"?= %*?\n', associatedPage.title()'|fonti=d\n', newTalkText)
try:
talkText = page.get()
except wikipedia.Error, e:
print e # Print the error and skip
continue
newTalkText = re.sub('\|\n? *?[Ff]onti ?= *?\n', '|fonti=d\n', talkText)
if talkText != newTalkText:
wikipedia.showDiff(talkText, newTalkText)
if not always:
choice = wikipedia.inputChoice(u"Apply the changes?", ['Yes', 'No', 'All'], ['y', 'N', 'a'], 'N')
else:
choice = 'y'
if choice in ['A', 'a']:
always = True
choice = 'y'
if choice in ['Y', 'y']:
try:
page.put(newTalkText, u'[[WP:BOT|Bot]]: Non ci sono fonti: valutazione "d"')
except wikipedia.Error, e:
print e # Print the error and skip
continue
if match is not None:
wikipedianewTalkText = re.outputsub(">>>>>'\|\n? %s*?[Ff]onti <<<<<"?= %?d\n', associatedPage.title()'|fonti= \n', newTalkText)
try:
talkText = page.get()
except wikipedia.Error, e:
print e # Print the error and skip
continue
newTalkText = re.sub('\|\n? *?[Ff]onti ?= ?d\n', '|fonti= \n', talkText)
if talkText != newTalkText:
wikipedia.showDiff(talkText, newTalkText)
if not always:
choice = wikipedia.inputChoice(u"Apply the changes?", ['Yes', 'No', 'All'], ['y', 'N', 'a'], 'N')
else:
choice = 'y'
if choice in ['A', 'a']:
always = True
choice = 'y'
if choice in ['Y', 'y']:
try:
page.put(newTalkText, u'[[WP:BOT|Bot]]: Trovate fonti: rimuovo valutazione "d"')
except wikipedia.Error, e:
print e # Print the error and skip
continue
match = re.search('(\{\{[Vv]etrina)', pageText, re.IGNORECASE)
if match is not None:
newTalkText = re.sub('\|\n? *?[Aa]ccuratezza ?= *?\n', '|accuratezza=a\n', newTalkText)
wikipedia.output(">>>>> %s <<<<<" % associatedPage.title())
try:
talkText = page.get()
except wikipedia.Error, e:
print e # Print the error and skip
continue
newTalkText = re.sub('\|\n? *?[Aa]ccuratezza ?= *?\n', '|accuratezza=a\n', talkText)
if talkText != newTalkText:
wikipedia.showDiff(talkText, newTalkText)
if not always:
choice = wikipedia.inputChoice(u"Apply the changes?", ['Yes', 'No', 'All'], ['y', 'N', 'a'], 'N')
else:
choice = 'y'
if choice in ['A', 'a']:
always = True
choice = 'y'
if choice in ['Y', 'y']:
try:
page.put(newTalkText, u'[[WP:BOT|Bot]]: Voce in vetrina: completezza "a"')
except wikipedia.Error, e:
print e # Print the error and skip
continue
if match == None:
match = re.search('(\{\{[Ss]\|)', pageText, re.IGNORECASE)
if match is not None:
newTalkText = re.sub('\|\n? *?[Aa]ccuratezza ?=.*?\n', '|accuratezza=c\n', newTalkText)
wikipedia.output(">>>>> %s <<<<<" % associatedPage.title())
try:
if match talkText == page.get()None:
match = re.search('(\{\{[Aa]\|)', pageText, re.IGNORECASE)
except wikipedia.Error, e:
printif ematch #is Printnot the error and skipNone:
newTalkText = re.sub('\|\n? *?[Aa]ccuratezza ?= *?\n', '|accuratezza=d\n', newTalkText)
continue
newTalkText = re.sub('\|\n? *?[Aa]ccuratezza ?=.*?\n', '|accuratezza=c\n', talkText)
if talkTextmatch !== newTalkTextNone:
wikipedia newTalkText = re.showDiffsub(talkText'\|\n? *?[Aa]ccuratezza ?= ?[cd]\n', '|accuratezza= \n', newTalkText)
if not always:
choice = wikipedia.inputChoice(u"Apply the changes?", ['Yes', 'No', 'All'], ['y', 'N', 'a'], 'N')
else:
choice = 'y'
if choice in ['A', 'a']:
always = True
choice = 'y'
if choice in ['Y', 'y']:
try:
page.put(newTalkText, u'[[WP:BOT|Bot]]: Stub: completezza "c"')
except wikipedia.Error, e:
print e # Print the error and skip
continue
if match == None:
match = re.search('(\{\{[Aa]\|)', pageText, re.IGNORECASE)
if match is not None:
wikipedia.output(">>>>> %s <<<<<" % associatedPage.title())
try:
talkText = page.get()
except wikipedia.Error, e:
print e # Print the error and skip
continue
newTalkText = re.sub('\|\n? *?[Aa]ccuratezza ?= *?\n', '|accuratezza=d\n', talkText)
if talkText != newTalkText:
wikipedia.showDiff(talkText, newTalkText)
if not always:
choice = wikipedia.inputChoice(u"Apply the changes?", ['Yes', 'No', 'All'], ['y', 'N', 'a'], 'N')
else:
choice = 'y'
if choice in ['A', 'a']:
always = True
choice = 'y'
if choice in ['Y', 'y']:
try:
page.put(newTalkText, u'[[WP:BOT|Bot]]: Voce da aiutare: completezza "d"')
except wikipedia.Error, e:
print e # Print the error and skip
continue
if match == None:
wikipedia.output(">>>>> %s <<<<<" % associatedPage.title())
try:
talkText = page.get()
except wikipedia.Error, e:
print e # Print the error and skip
continue
newTalkText = re.sub('\|\n? *?[Aa]ccuratezza ?= ?[cd]\n', '|accuratezza= \n', talkText)
if talkText != newTalkText:
wikipedia.showDiff(talkText, newTalkText)
if not always:
choice = wikipedia.inputChoice(u"Apply the changes?", ['Yes', 'No', 'All'], ['y', 'N', 'a'], 'N')
else:
choice = 'y'
if choice in ['A', 'a']:
always = True
choice = 'y'
if choice in ['Y', 'y']:
try:
page.put(newTalkText, u'[[WP:BOT|Bot]]: Voce non da aiutare o stub: rimuovo completezza')
except wikipedia.Error, e:
print e # Print the error and skip
continue
match = re.search('(\{\{[Dd]a correggere)', pageText, re.IGNORECASE)
if match is not None:
newTalkText = re.sub('\|\n? *?[Ss]crittura ?= *?\n', '|scrittura=d\n', newTalkText)
wikipedia.output(">>>>> %s <<<<<" % associatedPage.title())
try:
talkText = page.get()
if talkText != except wikipedia.Error, enewTalkText:
wikipedia.showDiff(talkText, newTalkText)
print e # Print the error and skip
if not continuealways:
newTalkText choice = rewikipedia.subinputChoice('\|\n?u"Apply *the changes?", [Ss'Yes', 'No', 'All']crittura, ?=['y', *?\n'N', '|scrittura=d\na'], talkText'N')
if talkText != newTalkTextelse:
wikipedia.showDiff(talkText,choice newTalkText)= 'y'
if choice in ['A', if not always'a']:
always = True
choice = wikipedia.inputChoice(u"Apply the changes?", ['Yes', 'No', 'All'], ['y', 'N', 'a'], 'N')
else:choice = 'y'
if choice in choice =['Y', 'y']:
if choice in ['A', 'a']try:
page.put(newTalkText, u'[[WP:BOT|Bot]]: aggiorno [[Progetto:Qualità/Monitoraggio voci|monitoraggio]]')
always = True
except wikipedia.Error, choice = 'y'e:
if choice in ['Y', 'y']:print e # Print the error and skip
try:continue
page.put(newTalkText, u'[[WP:BOT|Bot]]: Voce da correggere: scrittura "d"')
except wikipedia.Error, e:
print e # Print the error and skip
continue
if __name__ == "__main__":
try: