def run(self): for key, name in self.nominTypeDict.items(): cat = catlib.Category(Site(), u'Category:%s' % name) self.nominTypeDict[key] = catlib.unique([ article.title() for article in cat.articles()]) PAFPage = wikipedia.Page(Site(), u'Wikipédia:Pages à fusionner') self.listOfFusionTitles = fusionTitleP.findall(PAFPage.get()) print self.listOfFusionTitles
def extractedList(self, listString): formatTag = Tag('* [[',']]') titlesList = [] for line in listString.split('\n'): try: titlesList.append(formatTag.split(line)[1]) except IndexError: pass return catlib.unique(titlesList)
def maintenance(self, checklist = None): output(u"\n'''[[Projet:%s]]'''" % self.name) for portal in self.portalsList: portal.iconify() portal.listify() self.titlesList += portal.listUpdateRobot.list portal.listUpdateRobot.run() self.titlesList = catlib.unique(self.titlesList) self.totalUpdate() self.newArticlesUpdate() if checklist: self.nominationsListUpdate(checklist)
def newArticlesUpdate(self): backupList = [] for portal in self.portalsList: backupList += portal.listUpdateRobot.list sList = [] deletedList = [] for portal in self.portalsList: newList = [] for title in portal.listUpdateRobot.new: if title not in backupList: newList.append(title) backupList.append(title) if newList: sList.append(':[[Fichier:%s|12x24px|%s|link=Portail:%s]] ' % (portal.iconName, portal.name, portal.name) + u' • '.join([u'[[%s]]' % title for title in newList])) #backupList += newList for title in portal.listUpdateRobot.deleted: if title not in self.titlesList: deletedList.append(title) if deletedList: listString = ( u'\n{{Moins2}} ' + u' • '.join([u'[[%s]]' % title for title in catlib.unique(deletedList)])) else: listString = '' if sList: listString += ('\n;{{subst:CURRENTDAY}}' + ' {{subst:CURRENTMONTHNAME}}' + ' {{subst:CURRENTYEAR}}\n' + '\n'.join(sList)) if listString: newArticlesPage = BotEditPage(Site(), u'Projet:%s/Articles récents' % self.name, botTag = bot_tag, create = True) oldList = newArticlesPage.editContent().split('\n;') listString += '\n;'+'\n;'.join(oldList[1:10]) newArticlesPage.sectionUpdate( listString, changeWarning = ( u"Mise à jour des " + u"[[Projet:%s/Articles récents|articles récents]]." % self.name))
def listify(self): templist = [] #wikipedia.output(u"Recherche du bandeau de portail %s" % self.name) try: template = wikipedia.Page(Site(), u'Modèle:Portail %s' % self.name) #wikipedia.output(u'OK.') except wikipedia.NoPage: output = u"Bandeau introuvable avec le nom du portail." #return agreement(u"On continue ?", False) raise wikipedia.NoPage if template.isRedirectPage(): #wikipedia.output(u"Recherche du titre correct du bandeau.") template = template.getRedirectTarget() #wikipedia.output(u"OK.") for pg in template.getReferences(): if pg.namespace() == 0: templist.append(pg.title()) #wikipedia.output(u'Liste constituée') self.listUpdateRobot.load(catlib.unique(templist))