Utente:ItwikiBot/wikiquotestats.py

Da Wikipedia, l'enciclopedia libera.
Vai alla navigazione Vai alla ricerca
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# (C) https://it.wikipedia.org/wiki/Utente:Rotpunkt, 2018, under the MIT License
# Aggiorna le statistiche di Wikiquote in https://it.wikiquote.org/wiki/Template:Lingue/Dati
# 

from pywikibot.data.wikistats import WikiStats
import pywikibot

def main():
	ws = WikiStats()
	stats = ws.sorted('wikiquote', 'good')
	text = '{{#switch:{{{1}}}\n'
	for n in range(8):
		text += '|lingua%d = %s\n' % (n + 1, stats[n]['prefix'])
		text += '|voci%d = %s\n' % (n + 1, stats[n]['good'])
	text += '}}'

	pywikibot.handle_args()
	site = pywikibot.Site()
	page = pywikibot.Page(site, 'Template:Lingue/Dati')
	page.put(text, 'Bot: aggiornamento dati')

if __name__ == '__main__':
	main()