Utente:IPork/Sandbox/10: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
snellito e migliorato
tolgo classe inutile
 
Riga 857:
listString = listString + "{{Testo|%s}}\n" % article.title()
listString = listString + "\n -->\n<noinclude>[[Categoria:Liste alfabetiche %s| ]]</noinclude>" % testoCat
if self.listPage.exists() and not self.overwrite:
wikipedia.output(u'Page %s already exists, aborting.' % self.listPage.title())
else:
self.listPage.put(listString)
 
class CreateTableRobot:
'''
Creates a table.
'''
table_msg={
'en':u'Robot: Listifying (%d - %d - %d - %d - %d - %d)',
'it':u'Aggiornamento statistiche SAL (%d - %d - %d - %d - %d - %d)',
}
 
def __init__(self, infoPagine, editSummary, overwrite = True, subCats = False, talkPages = False):
catTitle1, catTitle2, catTitle3, catTitle4, catTitle5, catTitle6, catTitle7, catTitle8, catTitle9, catTitle10, catTitle11, catTitle12, catTitle13, catTitle14, catTitle15, catTitle16, catTitle17, catTitle18, catTitle19, catTitle20, catTitle21, catTitle22, catTitle23, catTitle24, catTitle25, catTitle26, listTitle = infoPagine
self.editSummary = editSummary
self.overwrite = overwrite
self.catName1 = catTitle1
self.catName2 = catTitle2
self.catName3 = catTitle3
self.catName4 = catTitle4
self.catName5 = catTitle5
self.catName6 = catTitle6
self.catName7 = catTitle7
self.catName8 = catTitle8
self.catName9 = catTitle9
self.catName10 = catTitle10
self.catName11 = catTitle11
self.catName12 = catTitle12
self.catName13 = catTitle13
self.catName14 = catTitle14
self.catName15 = catTitle15
self.catName16 = catTitle16
self.catName17 = catTitle17
self.catName18 = catTitle18
self.catName19 = catTitle19
self.catName20 = catTitle20
self.catName21 = catTitle21
self.catName22 = catTitle22
self.catName23 = catTitle23
self.catName24 = catTitle24
self.catName25 = catTitle25
self.catName26 = catTitle26
 
self.cat1 = catlib.Category(wikipedia.getSite(), 'Category:' + catTitle1)
self.cat2 = catlib.Category(wikipedia.getSite(), 'Category:' + catTitle2)
self.cat3 = catlib.Category(wikipedia.getSite(), 'Category:' + catTitle3)
self.cat4 = catlib.Category(wikipedia.getSite(), 'Category:' + catTitle4)
self.cat5 = catlib.Category(wikipedia.getSite(), 'Category:' + catTitle5)
self.listPage = wikipedia.Page(wikipedia.getSite(), listTitle)
self.subCats = subCats
self.talkPages = talkPages
 
def run(self):
nomeCat1 = self.catName1
nomeCat2 = self.catName2
nomeCat3 = self.catName3
nomeCat4 = self.catName4
nomeCat5 = self.catName5
listOfArticles1 = self.cat1.articlesList()
listOfArticles2 = self.cat2.articlesList()
listOfArticles3 = self.cat3.articlesList()
listOfArticles4 = self.cat4.articlesList()
listOfArticles5 = self.cat5.articlesList()
totale1 = len(listOfArticles1)
totale2 = len(listOfArticles2)
totale3 = len(listOfArticles3)
totale4 = len(listOfArticles4)
totale5 = len(listOfArticles5)
totaleTotale = totale1 + totale2 + totale3 + totale4 + totale5
 
if self.editSummary:
wikipedia.setAction(self.editSummary)
else:
wikipedia.setAction(wikipedia.translate(wikipedia.getSite(), self.table_msg) % (totale1, totale2, totale3, totale4, totale5, totaleTotale))
 
listString = "{|{{prettytable|width=|align=|text-align=}}\n| colspan=\"6\"|'''<big>Statistiche</big>'''<br/><div style=\"float:right; margin-top:-19px;\"><small>[[Aiuto:Elenchi generati da bot|aggiornate il {{Data ultima revisione|" + self.listPage.title() + "}}]]</small></div>\n|-\n| width=\"100\" align=\"center\" style=\"background:#efefef;\" | [[Immagine:25%%.svg|12px]] '''[[:Categoria:%s|SAL 25%%]]'''\n| width=\"100\" align=\"center\" style=\"background:#efefef;\" | [[Immagine:50%%.svg|12px]] '''[[:Categoria:%s|SAL 50%%]]'''\n| width=\"100\" align=\"center\" style=\"background:#efefef;\" | [[Immagine:75%%.svg|12px]] '''[[:Categoria:%s|SAL 75%%]]'''\n| width=\"100\" align=\"center\" style=\"background:#efefef;\" | [[Immagine:100%%.svg|12px]] '''[[:Categoria:%s|SAL 100%%]]''' \n| width=\"100\" align=\"center\" style=\"background:#efefef;\" | [[Immagine:101%%.png|12px]] '''[[:Categoria:%s|Ed. WS]]'''\n| width=\"100\" align=\"center\" style=\"background:#efefef;\" | '''Totale'''\n|- style=\"text-align: center;\"\n| %d || %d || %d || %d || %d || %d \n|}" % (nomeCat1, nomeCat2, nomeCat3, nomeCat4, nomeCat5, totale1, totale2, totale3, totale4, totale5, totaleTotale)
if self.listPage.exists() and not self.overwrite:
wikipedia.output(u'Page %s already exists, aborting.' % self.listPage.title())