Utente:Ricordisamoa/createbar.py

Versione del 5 mag 2014 alle 10:13 di Ricordisamoa (discussione | contributi) (da Speciale:LinkPermanente/20996762)
(diff) ← Versione meno recente | Versione attuale (diff) | Versione più recente → (diff)
#!/usr/bin/python
# -*- coding: utf-8 -*-
 
##
# 23.00 UTC -> 0.00 CET
# 22.00 UTC -> 0.00 CEST 
##
 
import os
import time
import wikipedia
 
os.environ['TZ'] = 'Europe/Rome'
 
monthConv = {1:     'gennaio',
        2:     'febbraio',
        3:     'marzo',
        4:     'aprile',
        5:     'maggio',
        6:     'giugno',
        7:     'luglio',
        8:     'agosto',
        9: 'settembre',
        10:  'ottobre',
        11: 'novembre',
        12: 'dicembre',
}
 
args = wikipedia.handleArgs()
 
curYear = time.strftime("%Y")
curMonth = time.strftime("%m")
curDay = str(int(time.strftime("%d")))
 
pageBarTitle = wikipedia.Page(wikipedia.getSite('it', 'wikipedia'), "Wikipedia:Bar/" + curYear + '_' + curMonth + '_' + curDay)
pageBarText = "<noinclude>\n{{Bar4/light}}\n=" + curDay + ' ' + monthConv[int(curMonth)] + "=\n__TOC__\n[[Categoria:Wikipedia Bar - " + curDay + ' ' + monthConv[int(curMonth)] + ' ' + curYear + "]]\n[[Categoria:Archivio bar]]\n</noinclude>"
 
if not pageBarTitle.exists():
    pageBarTitle.put(pageBarText, u"Bot: Creo sottopagina del bar odierno")
else:
    wikipedia.output(str(pageBarTitle) + " already exists: skip.")
 
dayCatTitle = wikipedia.Page(wikipedia.getSite('it', 'wikipedia'), "Categoria:Wikipedia Bar - " + curDay + ' ' + monthConv[int(curMonth)] + ' ' + curYear)
dayCatText = "[[Categoria:Wikipedia Bar - " + monthConv[int(curMonth)] + ' ' + curYear + "]]"
 
if not dayCatTitle.exists():
    dayCatTitle.put(dayCatText, u"Bot: Creo categoria del bar odierno")
else:
    wikipedia.output(str(dayCatTitle) + " already exists: skip.")
 
monthCatTitle = wikipedia.Page(wikipedia.getSite('it', 'wikipedia'), "Categoria:Wikipedia Bar - " + monthConv[int(curMonth)] + ' ' + curYear)
monthCatText = "[[Categoria:Wikipedia Bar - Archivi per mese " + curYear + "| " + curMonth + "]]"
 
if not monthCatTitle.exists():
    monthCatTitle.put(monthCatText, u"Bot: Creo categoria mensile del bar")
else:
    wikipedia.output(str(monthCatTitle) + " already exists: skip.")
 
yearCatTitle = wikipedia.Page(wikipedia.getSite('it', 'wikipedia'), "Categoria:Wikipedia Bar - Archivi per mese " + curYear)
yearCatText = "In questa categoria sono raggruppate le categorie che raccolgono tutte le sottopagine del bar di uno stesso mese del " + curYear + ". Ogni categoria mensile contiene le categorie giornaliere, che contengono le pagine giornaliere e tutte le sottopagine di discussione del giorno.\n\n[[Categoria:Wikipedia Bar - Archivi per mese| " + curYear +  "]]"
 
if not yearCatTitle.exists():
    yearCatTitle.put(yearCatText, u"Bot: Creo categoria annuale del bar")
else:
    wikipedia.output(str(yearCatTitle) + " already exists: skip.")
 
weekCatTitle = wikipedia.Page(wikipedia.getSite('it', 'wikipedia'), "Categoria:Wikipedia Bar - Archivio" + time.strftime(" %G-") + str(int(time.strftime("%V"))))
weekCatText = "[[Categoria:Wikipedia Bar - Archivi per settimana " + time.strftime("%G") + "]]"
 
if not weekCatTitle.exists():
    weekCatTitle.put(weekCatText, u"Bot: Creo categoria settimanale del bar")
else:
    wikipedia.output(str(weekCatTitle) + " already exists: skip.")
 
weekYearCatTitle = wikipedia.Page(wikipedia.getSite('it', 'wikipedia'), "Categoria:Wikipedia Bar - Archivi per settimana" + time.strftime(" %G"))
weekYearCatText = "In questa categoria sono raggruppate le categorie che raccolgono tutte le sottopagine del bar di una stessa settimana del " + time.strftime("%G") + ". Ogni categoria settimanale contiene direttamente ogni sottopagina di discussione della settimana corrispondente.\n\n[[Categoria:Wikipedia Bar - Archivi per settimana| " + time.strftime("%G") + "]]"
 
if not weekYearCatTitle.exists():
    weekYearCatTitle.put(weekYearCatText, u"Bot: Creo categoria annuale del bar")
else:
    wikipedia.output(str(weekYearCatTitle) + " already exists: skip.")
 
wikipedia.stopme()