#!/usr/bin/python
# -*- coding: utf-8 -*-
##
# 23.00 UTC -> 0.00 CET
# 22.00 UTC -> 0.00 CEST
##
import os
import time
import pywikibot
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 = pywikibot.handleArgs()
curYear = time.strftime("%Y")
curMonth = time.strftime("%m")
curDay = str(int(time.strftime("%d")))
pageBarTitle = pywikibot.Page(pywikibot.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:
pywikibot.output(str(pageBarTitle) + " already exists: skip.")
dayCatTitle = pywikibot.Page(pywikibot.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:
pywikibot.output(str(dayCatTitle) + " already exists: skip.")
monthCatTitle = pywikibot.Page(pywikibot.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:
pywikibot.output(str(monthCatTitle) + " already exists: skip.")
yearCatTitle = pywikibot.Page(pywikibot.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:
pywikibot.output(str(yearCatTitle) + " already exists: skip.")
weekCatTitle = pywikibot.Page(pywikibot.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:
pywikibot.output(str(weekCatTitle) + " already exists: skip.")
weekYearCatTitle = pywikibot.Page(pywikibot.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:
pywikibot.output(str(weekYearCatTitle) + " already exists: skip.")
pywikibot.stopme()