Utente:Sirbot/Script

Versione del 9 giu 2008 alle 13:40 di Sirabder87 (discussione | contributi) (non più necessario dopo spostamento del portale)

monitoraggioimmagini.py modificato

Basato su Utente:BimBot/Scripts#monitoraggioimmagini.py

#!/usr/bin/env python
# -*- utf-8 -*-
"""
README: Todo
"""
#
# (C) Pietrodn, 2007
# (C) Sirabder87, 2008
# (C) Filnik, 2008
#
# Distributed under the terms of the MIT license.
#
__version__ = '$Id: $'
#

import wikipedia, catlib, re

def main():
    always = False
    for arg in wikipedia.handleArgs():
        if arg.startswith("-always"):
            always = True
    site = wikipedia.getSite()
    category_name = 'Categoria:Progetto:Musica/Punk/Tabella monitoraggio automatico - immagini nc'
    categoria = catlib.Category(site, category_name)
    discussioni = categoria.articles()
    for page in discussioni:
        if not page.isTalkPage():
            continue
        associatedPage = page.toggleTalkPage()
        try:
            pageText = associatedPage.get()
        except Wikipedia.Error, e:
            wikipedia.output(e) # Print the error and skip
            continue
        match = re.search('(\[\[(image|immagine):|Fotografia ?= ?.)', pageText, re.IGNORECASE)
        if match == None:
            wikipedia.output(">>>>> %s <<<<<" % associatedPage.title())
            try:
                talkText = page.get()
            except Wikipedia.Error, e:
                wikipedia.output(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'Bot: Non ci sono immagini: valutazione "d"')
                    except Wikipedia.Error, e:
                        wikipedia.output(e) # Print the error and skip
                        continue
                
if __name__ == "__main__": 
    try:
        main()
    finally:
        wikipedia.stopme()

monitoraggiofonti.py

#!/usr/bin/env python
# -*- utf-8 -*-
"""
README: Todo
"""
#
# (C) Pietrodn, 2007
# (C) Sirabder87, 2008
# (C) Filnik, 2008
#
# Distributed under the terms of the MIT license.
#
__version__ = '$Id: $'
#
 
import wikipedia, catlib, re
 
def main():
    always = False
    for arg in wikipedia.handleArgs():
        if arg.startswith("-always"):
            always = True
    site = wikipedia.getSite()
    category_name = 'Categoria:Progetto:Musica/Punk/Tabella monitoraggio automatico - fonti nc'
    categoria = catlib.Category(site, category_name)
    discussioni = categoria.articles()
    for page in discussioni:
        if not page.isTalkPage():
            continue
        associatedPage = page.toggleTalkPage()
        try:
            pageText = associatedPage.get()
        except Wikipedia.Error, e:
            wikipedia.output(e) # Print the error and skip
            continue
        match = re.search('(\<ref.*\>|\{\{references|\{\{cit)', pageText, re.IGNORECASE)
        if match == None:
            wikipedia.output(">>>>> %s <<<<<" % associatedPage.title())
            try:
                talkText = page.get()
            except Wikipedia.Error, e:
                wikipedia.output(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'Bot: Non ci sono fonti: valutazione "d"')
                    except Wikipedia.Error, e:
                        wikipedia.output(e) # Print the error and skip
                        continue
 
if __name__ == "__main__": 
    try:
        main()
    finally:
        wikipedia.stopme()