Utilisateur:DSisyphBot/Script/listemaintenance.py

Une page de Wikipédia, l'encyclopédie libre.
# -*- coding: utf-8 -*-
 

import re
import time
import sys
import urllib
import re
import unicodedata
import pywikibot
#from pywikibot import interwiki
from pywikibot import pagegenerators
from pywikibot.pagegenerators import PreloadingGenerator
from pywikibot.compat import catlib
 
def testdefaulsort(text,pagename):
	cledetri = 1
	defo = u''
	if pagename.find(u' ')>0:
		if text.find(u'{{DEFAULTSORT')<0 and text.find(u'{{CLEDETRI')<0:
			lines = text.split(u'\n')
			for l in lines:
				if l.find(u'Catégorie:')>0 and l.find(u'|')<0:
					cledetri = 0
		if cledetri == 0:
			defo = u'# [['+pagename+u']]\n'
	return defo
 
 
def testportail(text,pagename,portail):
	po = u''
	if not re.search(u'{{[Pp]ortail',text):
		po = u'# [['+pagename+u']]\n'
	elif re.search(u'gorie:[Ss]tade ',text) or re.search(u'nfobox [Ss]tade',text):
		pass
	else:
		lines = text.split(u'\n')
		for l in lines:
			if re.search(u'{{[Pp]ortail',l) and (l.find(portail[0].upper()+portail[1:])<0 and l.find(portail[0].lower()+portail[1:])<0):
				if portail==u"sport automobile" and  re.search(u"[Ff]ormule 1",l):
					pass
				elif portail==u"jeux olympiques" and (re.search(u"JO",l) or re.search(u"Jeux Olympiques",l)):
					pass
				elif (portail==u"cyclisme" or portail==u"Cyclisme") and re.search(u"[Bb]icyclette",l):
					pass
				else:
					po = u'# [['+pagename+u']]\n'
	return po
 
def testbandeau(text,pagename):
	band = u''
	if re.search(u'{([ÀàAa][ _](wikifier|vérifier|sourcer|délister|(ré|)actualiser|désacadémiser|illustrer|recyclage)|[Mm]ettre à jour|BPV|[Ss]ource[rs]|[Aa]necdote|[Rr]ecyclage|[Pp]hoto|[Pp](ub|romotion)|[Oo](rphelin|rphan)|[Dd]élister|[Aa]dmissibilité|[Ss]uppression|[ÀàAa][ _]actualiser)',text):
		band = u'# [['+pagename+u']]'
		if re.search(u'{[ÀàAa][ _]wikifier',text):
			band += u' (à wikifier)'
		if re.search(u'{[Oo](rphelin|rphan)',text):
			band += u' (orphelin)'
		if re.search(u'{([ÀàAa]?[ _]?[Ss]ource[rs]?|BPV)',text):
			band += u' (à sourcer)'
		if re.search(u'{([ÀàAa][ _]|)[Dd]élister',text):
			band += u' (à délister)'
		if re.search(u'{[ÀàAa][ _]désacadémiser',text):
			band += u' (à désacadémiser)'
		if re.search(u'{[ÀàAa][ _]vérifier',text):
			band += u' (à vérifier)'
		if re.search(u'{([ÀàAa][ _]recycler|[Rr]ecyclage)',text):
			band += u' (à recycler)'
		if re.search(u'{([ÀàAa][ _]|)(illustrer|[Pp]hoto)',text):
			band += u' (à illustrer)'
		if re.search(u'{[Aa]dmissibilité',text):
			band += u' (admissibilité)'
		if re.search(u'{[Pp](ub|romotion)',text):
			band += u' (promotionnel)'
		if re.search(u'{[Aa]necdote',text):
			band += u' (anecdotes)'
		if re.search(u'{([ÀàAa][ _](ré|)actualiser|[Mm]ettre à jour)',text):
			band += u' (à actualiser)'
		if re.search(u'{[Tt]ravail inédit',text):
			band += u' (travail inédit)'
		if re.search(u'{[Ss]uppression',text):
			band += u' ([[Discussion:'+ pagename + u'/Suppression|suppression]])'
		band += u'\n'
	return band


def tableaumixte(txt,pagename):
	tableau = u''
	if re.search(u'{{[Ss]tat hockey/fin',txt)  and not re.search(u'{{[Ss]tat hockey/début',txt) :
		tableau = u'#[[' + pagename +u']] manque stat hockey/debut\n'
	elif not re.search(u'{{[Ss]tat hockey/fin',txt)  and re.search(u'{{[Ss]tat hockey/début',txt) :
		tableau = u'#[[' + pagename +u']] manque stat hockey/fin\n'
	elif re.search(u'{{[Cc]lassement hockey/fin',txt)  and not re.search(u'{{[Cc]lassement hockey/début',txt) :
		tableau = u'#[[' + pagename +u']] manque classement hockey/debut\n'
	elif not re.search(u'{{[Cc]lassement hockey/fin',txt)  and  re.search(u'{{[Cc]lassement hockey/début',txt) :
		tableau = u'#[[' + pagename +u']] manque classement hockey/fin\n'
	elif re.search(u'{{[Ee]ffectif hockey/fin',txt)  and not re.search(u'{{[Ee]ffectif hockey/début',txt) :
		tableau = u'#[[' + pagename +u']] manque effectif hockey/debut\n'
	elif not re.search(u'{{[Ee]ffectif hockey/fin',txt)  and  re.search(u'{{[Ee]ffectif hockey/début',txt) :
		tableau = u'#[[' + pagename +u']] manque effectif hockey/fin\n'
	elif txt.count(u' hockey/début')!=txt.count(u' hockey/fin'):
		tableau = u'#[[' + pagename +u']] 1 tableau OK, 1 tableau NOK\n'
	return tableau



	
 
def pagenameIW(text,lang):
	page = u''
	if text.find(u'[[' + lang + u':'):
		deb=text.find(u'[[' + lang + u':') + len(lang)
		fin=text.find(u']]',deb)
		page = text[deb:fin]
	return page
 
def ipdate(temps,pagename):
	ip = u"# [["+pagename+u"]]"
	temps = str(temps)
	temps = temps.replace(u"-",u"")
	temps = int(temps[:8])
	tempspresent = time.strftime('%Y%m%d%H%M%S',time.localtime())
	soustraction = int(tempspresent[:8])-temps
	temps = str(temps)
	if soustraction<100:
		ip = ip + u" '''" + temps[6:8] +u'/'+temps[4:6]+u'/'+temps[:4] +u"'''\n"
	else:
		ip = ip +u' '+ temps[6:8] +u'/'+temps[4:6]+u'/'+temps[:4] +u'\n'
	return ip

def datadeces(lstdecesen,lstdecesfr):
	c = len(lstdecesen)
	d = len(lstdecesfr)
	diffdec = u''
	if c!=d:
		pause = input('erreur nombre elements liste')
	d=0
	sitefr = pywikibot.getSite('fr','wikipedia')
	siteen = pywikibot.getSite('en','wikipedia')
	pywikibot.output(u'\03{lightpurple}\nDeces sur en.wp\03{default}')
	for pag in pagegenerators.PreloadingGenerator(lstdecesen,500):
		c = c-1
		try:
			text1 = pag.get()
			pagen = pag.title(withNamespace=False)
			if text1.find(u'deaths]]')>0:
				pagen = u'# [[:en:'+pagen+u']] [[:fr:'+lstdecesfr[d]+u']] \n'
				diffdec += pagen
		except pywikibot.NoPage:
			pass
		except pywikibot.IsRedirectPage:
			pass
		d += 1
	return diffdec 
 
def data(lsten,lstdate):
	c = len(lsten)
	d = len(lstdate)
	diffna = u''
	if c!=d:
		pause = input('erreur nombre elements liste')
	d=0
	sitefr = pywikibot.getSite('fr','wikipedia')
	siteen = pywikibot.getSite('en','wikipedia')
	pywikibot.output(u'\03{lightpurple}\nNaissance sur en.wp\03{default}')
	for pag in pagegenerators.PreloadingGenerator(lsten,500):
		c = c-1
		try:
			text1 = pag.get()
			pagen = pag.title(withNamespace=False)
			date = u''
			date = lstdate[d][0]
			if text1.find(u'births]]')>0:
				if not re.search(date + u'[ _]births *\]\]',text1):
					pagen = u'# [[:en:'+pagen+u']] [[:fr:'+lstdate[d][1]+u']] \n'
					diffna += pagen
		except pywikibot.NoPage:
			pass
		except pywikibot.IsRedirectPage:
			pass
		d += 1
	return diffna
 
 
def verifimage(lstsansimageen,lstsansimagefr,lang):
	c = len(lstsansimageen)
	print len(lstsansimageen), len(lstsansimagefr)
	d=-1
	liste = u''
	sitefr = pywikibot.getSite('fr','wikipedia')
	siteen = pywikibot.getSite(lang,'wikipedia')
	for pag in pagegenerators.PreloadingGenerator(lstsansimageen):
		c = c-1
		d = d+1
		if not pag.exists():
			pywikibot.output(pag.exists())
			pag = pywikibot.Page(siteen,pag.title())
      
		try:
			text1 = pag.get()
			print c,
			pagename = pag.title(withNamespace=False)
			if re.search(u'.\.(jpg|JPG|jpeg|JPEG)',text1) and not re.search(u'Gorm.?silver.?cup\.jpg',text1):
				print c
				imagenom = re.search(u"([^:^=^\|]*)\.(jpg|JPG|jpeg|JPEG|Jpeg)",text1).group(1)
				extension = re.search(u"([^:^=^\|]*)\.(jpg|JPG|jpeg|JPEG|Jpeg)",text1).group(2)
				image = imagenom +u'.' +extension
				pywikibot.output(image)
				pimage = pywikibot.ImagePage(siteen,image)
				try : 
					if pimage.fileIsOnCommons():
						pagename = u'# [['+lstsansimagefr[d]+u']] [[Fichier:' + image + u'|40px]] ( [[:Fichier:' +image+u']] ) importé de '+lang+u'.wp\n'
						liste += pagename
						pywikibot.output(pagename)
				except : pass
		except pywikibot.NoPage:
			print 'nopage'
			pass
		except pywikibot.IsRedirectPage:
			print 'isredirect'
			pass
		except: pass
	return liste
 
def verifson(lstsansson,lang):
	c = len(lstsansson)
	liste = u''
	sitefr = pywikibot.getSite('fr','wikipedia')
	siteen = pywikibot.getSite(lang,'wikipedia')
	for pag in pagegenerators.PreloadingGenerator(lstsansson,500):
		c = c-1
		try:
			text1 = pag.get()
			#pagename = pag.title(withNamespace=False)
			if re.search(u'.\.(ogg|OGG)',text1) and text1.find(u'[[fr:')>=0:
				imagenom = re.search(u"([^:^=^\|]*)\.(ogg|OGG)",text1).group(1)
				extension = re.search(u"([^:^=^\|]*)\.(ogg|OGG)",text1).group(2)
				son = imagenom +u'.' +extension
				pimage = pywikibot.ImagePage(sitefr,son)
				try:
					if pimage.fileIsOnCommons() and not re.search(u'Gorm silver sup',son):
						deb = text1.find(u'[[fr:')+5
						fin =text1.find(u']]',deb)
						pagename = u'# [['+text1[deb:fin]+u']] ([[:Fichier:' +son+u']]) [[Fichier:' + son + u'|40px]]\n'
						liste += pagename
				except:
					pass
		except pywikibot.NoPage:
			pass
		except pywikibot.IsRedirectPage:
			pass
	return liste
 
# Define the main function
def main():
	site = pywikibot.getSite('fr','wikipedia')
	sitefr = pywikibot.getSite('fr','wikipedia')
	siteen = pywikibot.getSite('en','wikipedia')
	sitede = pywikibot.getSite('de','wikipedia')
	page = pywikibot.Page(site,u"Utilisateur:Sisyph/Demande outil maintenance")
	listetemp = []
	lsthomon = []
	for tt in page.getReferences():
		listetemp.append(tt.title())
	listetemp.sort()
	for l in listetemp:
		choice = u''
		tt = pywikibot.Page(site,l)
		if tt.namespace()==102 and not re.search(u'(DSisyphBot|Modèle|Archive)',tt.title()):
			pywikibot.output(tt.title())
			choice = pywikibot.inputChoice(u'upload, Skip', [ 'upload', 'Skip' ], ['u', 'S'], 's')
		if tt.namespace()==102 and choice=='u':
			text = tt.get()
			text1st = text
			nom_page = tt.title()
			nom_infobox = u"Infobox"
			nom_projet = re.search(u"nom_projet *= *(.*)(\n|\|)",text).group(1)
			nom_portail = re.search(u"nom_portail *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"nom_infobox *= *(.*)(\n|\|)",text): nom_infobox = re.search(u"nom_infobox *= *(.*)(\n|\|)",text).group(1)
			nom_wikiprojet = re.search(u"nom_wikiprojet *= *(.*)(\n|\|)",text).group(1)
			nom_eval = re.search(u"nom_eval *= *(.*)(\n|\|)",text).group(1)
			nom_portail2=u'VIDE'
			nom_portail3=u'VIDE'
			nom_portail4=u'VIDE'
			nom_portail5=u'VIDE'
			nom_domaine =u'VIDE'
			nom_eval2=u'VIDE'
			nom_eval3=u'VIDE'
			pdd_lastip=p_lastip=p_orph=nom_catbio2=p_deadurl=u"0"
			p_noportal=p_longeb=p_noref=p_boneval=p_bandeau=p_homo=p_isbn=b_nokey=u"1"
			b_nofile=b_nosound=b_nobirth=b_nodeath=b_deathen=b_birthen=b_nobox=b_boxbio2=pdd_noeval=pdd_badeval= u"1"
			lstisbn = []
			t_longeb=u"7000"
			t_noref=u"10000"
			t_boneval=u"2000"
			if re.search(u"nom_portail2 *= *(.*)(\n|\|)",text): nom_portail2 = re.search(u"nom_portail2 *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"nom_portail3 *= *(.*)(\n|\|)",text): nom_portail3 = re.search(u"nom_portail3 *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"nom_portail4 *= *(.*)(\n|\|)",text): nom_portail4 = re.search(u"nom_portail4 *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"nom_portail5 *= *(.*)(\n|\|)",text): nom_portail5 = re.search(u"nom_portail5 *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"nom_eval2 *= *(.*)(\n|\|)",text): nom_eval2 = re.search(u"nom_eval2 *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"nom_eval3 *= *(.*)(\n|\|)",text): nom_eval3 = re.search(u"nom_eval3 *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"nom_domaine *= *(.*)(\n|\|)",text): nom_domaine = re.search(u"nom_domaine *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"nom_catbio1 *= *(.*)(\n|\|)",text): nom_catbio1 = re.search(u"nom_catbio1 *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"nom_catbio2 *= *(.*)(\n|\|)",text): nom_catbio2 = re.search(u"nom_catbio2 *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"p_noportal *= *(.*)(\n|\|)",text): p_noportal = re.search(u"p_noportal *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"p_longeb *= *(.*)(\n|\|)",text): p_longeb = re.search(u"p_longeb *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"p_noref *= *(.*)(\n|\|)",text): p_noref = re.search(u"p_noref *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"p_boneval *= *(.*)(\n|\|)",text): p_boneval = re.search(u"p_boneval *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"p_bandeau *= *(.*)(\n|\|)",text): p_bandeau = re.search(u"p_bandeau *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"p_orph *= *(.*)(\n|\|)",text): p_orph = re.search(u"p_orph *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"p_homo *= *(.*)(\n|\|)",text): p_homo = re.search(u"p_homo *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"p_isbn *= *(.*)(\n|\|)",text): p_homo = re.search(u"p_homo *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"p_lastip *= *(.*)(\n|\|)",text): p_lastip = re.search(u"p_lastip *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"p_deadurl *= *(.*)(\n|\|)",text): p_deadurl = re.search(u"p_deadurl *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"b_nokey *= *(.*)(\n|\|)",text): b_nokey = re.search(u"b_nokey *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"b_nofile *= *(.*)(\n|\|)",text): b_nofile = re.search(u"b_nofile *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"b_nosound *= *(.*)(\n|\|)",text): b_nofile = re.search(u"b_nofile *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"b_nobirth *= *(.*)(\n|\|)",text): b_nobirth = re.search(u"b_nobirth *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"b_nodeath *= *(.*)(\n|\|)",text): b_nodeath = re.search(u"b_nodeath *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"b_deathen *= *(.*)(\n|\|)",text): b_birthen = re.search(u"b_birthen *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"b_birthen *= *(.*)(\n|\|)",text): b_birthen = re.search(u"b_birthen *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"b_nobox *= *(.*)(\n|\|)",text): b_nobox = re.search(u"b_nobox *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"b_boxbio2 *= *(.*)(\n|\|)",text): b_nobox = re.search(u"b_nobox *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"pdd_noeval *= *(.*)(\n|\|)",text): pdd_noeval = re.search(u"pdd_noeval *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"pdd_badeval *= *(.*)(\n|\|)",text): pdd_badeval = re.search(u"pdd_badeval *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"pdd_lastip *= *(.*)(\n|\|)",text): pdd_lastip = re.search(u"pdd_lastip *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"t_longeb *= *(.*)(\n|\|)",text): t_longeb = re.search(u"t_longeb *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"t_noref *= *(.*)(\n|\|)",text): t_noref = re.search(u"t_noref *= *(.*)(\n|\|)",text).group(1)
			if re.search(u"t_boneval *= *(.*)(\n|\|)",text): t_boneval = re.search(u"t_boneval *= *(.*)(\n|\|)",text).group(1)
			p_homo=b_nokey=u"1" #activé par defaut
 
##Conditions forcées
			#nom_catbio1 = u"Pongiste espagnol"
			#nom_catbio2 = u"Pongiste espagnol"
			#p_orph =2
			p_deadurl = 0
			#p_lastip=0
			#pdd_lastip=0
##                      nom_portail2 = u'Rock'
##                      nom_wikiprojet = u'Wikiprojet Rock'
##                      nom_eval       = u'Article de Rock'
			pywikibot.output(u'XXXXX '+nom_projet+u' XXXXX')
##			nom_portail = nom_portail.replace(u'-','\-')
##			nom_portail2 = nom_portail2.replace(u'-','\-')
##			nom_portail3 = nom_portail3.replace(u'-','\-')
##			nom_portail4 = nom_portail4.replace(u'-','\-')
##			nom_portail5 = nom_portail5.replace(u'-','\-')
 
## Prétravail pour l'homonymie commun a tous les projets
			if site.messages():
					message = input(u'Un message est arrive, nimporte quelle touche pour continuer')
			print len(lsthomon)
			if p_homo==u'1' and len(lsthomon) == 0:
				pywikibot.output("\03{lightpurple}\nCreation liste homonymes\03{default}")
				cat = catlib.Category(sitefr, u"Homonymie de personnes") #Homonymie de personnes #Homonymie de saints chrétiens
				pages = cat.articlesList(False)
 
				for p in pagegenerators.PreloadingGenerator(pages,500):
					lsthomon.append(p.title())
 
				cat = catlib.Category(sitefr, u"Homonymie de toponyme") #Homonymie de toponyme 
				pages = cat.articlesList(False)

				for p in pagegenerators.PreloadingGenerator(pages,500):
					lsthomon.append(p.title())

				cat = catlib.Category(sitefr, u"Homonymie de clubs sportifs") #Homonymie de clubs sportifs 
				pages = cat.articlesList(False)

				for p in pagegenerators.PreloadingGenerator(pages,500):
					lsthomon.append(p.title())

				pywikibot.output("\03{lightpurple}\nFait\03{default}")

				cat = catlib.Category(sitefr, u"Ouvrage avec ISBN invalide") 
				pages = cat.articlesList(False)

				for p in pagegenerators.PreloadingGenerator(pages,500):
					lstisbn.append(p.title())
					
			lsthomon = list(set(lsthomon)) # à vérifier
			lstisbn  = list(set(lstisbn)) # à vérifier
 
			result = u''
			defo = eb = noref = band = eva = tableevaleb = homon = isbn = orph = sanstitre = parenthese= nolegend = tableau = u''
			comm, ip, interwiki = u'', u'', u''
			pages  , pagesevalNW = [], []
## Attribution des valeurs des variables                        
			portail = nom_portail
			portail2 = nom_portail2
			portail3 = nom_portail3
			portail4 = nom_portail4
			portail5 = nom_portail5
			nompage = nom_projet[0].upper()+nom_projet[1:]
			nomsport= nom_catbio1
			nomsport2=nom_catbio2
			infobox = nom_infobox
			evaluation = nom_wikiprojet
			evaleb= nom_eval +u" d'avancement ébauche"
 
			pageex = pywikibot.Page(sitefr, u"Discussion " + nom_page[0].lower()+nom_page[1:])
			pywikibot.output(u'\03{lightpurple}\nExclusion\03{default}')
			if pageex.exists():
				exclusion = pageex.get()
			else:
				exclusion = u'Aucune exclusion de rentrée'
			pywikibot.output(exclusion)
 
	##### Wikiprojet
			ippdd = u''
			evalsport = u''
			evalBD = evaleb.replace(u'ébauche',u'BD')
			evalB = evaleb.replace(u'ébauche',u'B')
			evalA = evaleb.replace(u'ébauche',u'A')
			evalAdQ = evaleb.replace(u'ébauche',u'AdQ')
			evalBA = evaleb.replace(u'ébauche',u'BA')
			evalinc = evaleb.replace(u'ébauche',u'inconnu')
			pddeb , pddBD ,pddB , pddA ,pddAdQ , pddBA, pddinc =[],[],[],[],[],[],[]
			cateb = catlib.Category(sitefr, evaleb)
			catBD = catlib.Category(sitefr, evalBD)
			catBA = catlib.Category(sitefr, evalBA)
			catB = catlib.Category(sitefr, evalB)
			catA = catlib.Category(sitefr, evalA)
			catAdQ = catlib.Category(sitefr, evalAdQ)
			catinc = catlib.Category(sitefr, evalinc)
			lsteb = cateb.articlesList(False)
			lstBD = catBD.articlesList(False)
			lstBA = catBA.articlesList(False)
			lstB  = catB.articlesList(False)
			lstA  = catA.articlesList(False)
			lstAdQ = catAdQ.articlesList(False)
			lstinc = catinc.articlesList(False)
			pywikibot.output(u'\03{lightpurple}\nAvancement eb\03{default}')
			for p in pagegenerators.PreloadingGenerator(lsteb,500):
				if p.namespace()==1:
					pddeb.append(p.title(withNamespace=False))
					if not re.search(u'[Ss]port',p.get()):evalsport+=u'# [['+p.title()+u']]\n'
					if p.isIpEdit() and pdd_lastip=='1':
						pagename = p.title()
						temps = p.editTime()
						ippdd += ipdate(temps,pagename)
			pywikibot.output(u'\03{lightpurple}\nAvancement BD\03{default}')
			for p in pagegenerators.PreloadingGenerator(lstBD,500):
				if p.namespace()==1:
					pddBD.append(p.title(withNamespace=False))
					if not re.search(u'[Ss]port',p.get()):evalsport+=u'# [['+p.title()+u']]\n'
					if p.isIpEdit() and pdd_lastip=='1':
						pagename = p.title()
						temps = p.editTime()
						ippdd += ipdate(temps,pagename)
			pywikibot.output(u'\03{lightpurple}\nAvancement BA\03{default}')
			for p in pagegenerators.PreloadingGenerator(lstBA,500):
				if p.namespace()==1:
					pddBA.append(p.title(withNamespace=False))
					if not re.search(u'[Ss]port',p.get()):evalsport+=u'# [['+p.title()+u']]\n'
					if p.isIpEdit() and pdd_lastip=='1':
						pagename = p.title()
						temps = p.editTime()
						ippdd += ipdate(temps,pagename)
			for p in pagegenerators.PreloadingGenerator(lstB,500):
				if p.namespace()==1:
					pddB.append(p.title(withNamespace=False))
					if not re.search(u'[Ss]port',p.get()):evalsport+=u'# [['+p.title()+u']]\n'
					if p.isIpEdit() and pdd_lastip=='1':
						pagename = p.title()
						temps = p.editTime()
						ippdd += ipdate(temps,pagename)
			for p in pagegenerators.PreloadingGenerator(lstA,500):
				if p.namespace()==1:
					pddA.append(p.title(withNamespace=False))
					if not re.search(u'[Ss]port',p.get()):evalsport+=u'# [['+p.title()+u']]\n'
					if p.isIpEdit() and pdd_lastip=='1':
						pagename = p.title()
						temps = p.editTime()
						ippdd += ipdate(temps,pagename)
			for p in pagegenerators.PreloadingGenerator(lstAdQ,500):
				if p.namespace()==1:
					pddAdQ.append(p.title(withNamespace=False))
					if not re.search(u'[Ss]port',p.get()):evalsport+=u'# [['+p.title()+u']]\n'
					if p.isIpEdit() and pdd_lastip=='1':
						pagename = p.title()
						temps = p.editTime()
						ippdd += ipdate(temps,pagename)
			pywikibot.output(u'\03{lightpurple}\nAvancement inc\03{default}')
			for p in pagegenerators.PreloadingGenerator(lstinc,500):
				if p.namespace()==1:
					pddinc.append(p.title(withNamespace=False))
					if not re.search(u'[Ss]port',p.get()):evalsport+=u'# [['+p.title()+u']]\n'
					if p.isIpEdit() and pdd_lastip=='1':
						pagename = p.title()
						temps = p.editTime()
						ippdd += ipdate(temps,pagename)
 
 
			po = info = boxbio2 = na = deces = diffna = diffdec = evadiff = evalredirect = BD = CS= u''
			tableeb , tableinfo = [],[]
 
 
			lsteval = []
			lsteval.extend(pddeb)
			lsteval.extend(pddBD)
			lsteval.extend(pddB)
			lsteval.extend(pddBA)
			lsteval.extend(pddA)
			lsteval.extend(pddAdQ)
			lsteval.extend(pddinc)
			lsteval.sort()

			pywikibot.output(u'\03{lightpurple}\nFin pdd\03{default}')
 
			lstevalPage = []
			for l in lsteval:
			      lstevalPage.append(pywikibot.Page(sitefr,l))
			      
			for p in pagegenerators.PreloadingGenerator(lstevalPage,500):
				pagename = p.title()
				if p.namespace() == 0:
					      
					if not p.exists():
						po = po + u'# [[Discussion:'+pagename+u']] (article inexistant)\n'
					else :
						if p.isRedirectPage():
							evalredirect += u'# [[Discussion:'+pagename+u']]\n'
						if p.isRedirectPage():
							p = p.getRedirectTarget()
						if p.title().find(u'#')<0 and p_noportal=='1':
							pagename = p.sectionFreeTitle()
							text = p.get()
							if len(testportail(text,pagename,portail))>=1:
								po += testportail(text,pagename,portail)[:-1]+ u" (évaluation présente en pdd)\n"
 
 
	##### Portail
			liste_p_portail = []
			pywikibot.output(u'\03{lightpurple}\nDébut portail\03{default}')
 
			page = pywikibot.Page(site,u"Modèle:Portail "+portail)
			if not page.exists():
				page = pywikibot.Page(site,u"Modèle:Portail "+portail[0].upper()+portail[1:])
			if page.isRedirectPage():                       page = page.getRedirectTarget()
			for t in page.getReferences():
				if t.namespace()==0:
					titre = t.title()
					if exclusion.find(titre)<0:
						pages.append(pywikibot.Page(site, titre))
						liste_p_portail.append(titre)
			page = pywikibot.Page(site,u"Modèle:Portail "+portail2)
			if not page.exists():
				page = pywikibot.Page(site,u"Modèle:Portail "+portail2[0].upper()+portail2[1:])
			if page.isRedirectPage():                       page = page.getRedirectTarget()
			for t in page.getReferences():
				if t.namespace()==0:
					titre = t.title()
					if exclusion.find(titre)<0:
						pages.append(pywikibot.Page(site, titre))
						liste_p_portail.append(titre)
			page = pywikibot.Page(site,u"Modèle:Portail "+portail3)
			if not page.exists():
				page = pywikibot.Page(site,u"Modèle:Portail "+portail3[0].upper()+portail3[1:])
			if page.isRedirectPage():                       page = page.getRedirectTarget()
			for t in page.getReferences():
				if t.namespace()==0:
					titre = t.title()
					if exclusion.find(titre)<0:
						pages.append(pywikibot.Page(site, titre))
						liste_p_portail.append(titre)
			page = pywikibot.Page(site,u"Modèle:Portail "+portail4)
			if not page.exists():
				page = pywikibot.Page(site,u"Modèle:Portail "+portail4[0].upper()+portail4[1:])
			if page.isRedirectPage():                       page = page.getRedirectTarget()
			for t in page.getReferences():
				if t.namespace()==0:
					titre = t.title()
					if exclusion.find(titre)<0:
						pages.append(pywikibot.Page(site, titre))
						liste_p_portail.append(titre)
			page = pywikibot.Page(site,u"Modèle:Portail "+portail5)
			if not page.exists():
				page = pywikibot.Page(site,u"Modèle:Portail "+portail5[0].upper()+portail5[1:])
			if page.isRedirectPage():                       page = page.getRedirectTarget()
			for t in page.getReferences():
				if t.namespace()==0:
					titre = t.title()
					if exclusion.find(titre)<0:
						pages.append(pywikibot.Page(site, titre))
						liste_p_portail.append(titre)
			liste_p_portail.sort()
 
			for r in lsteval:
				if not r in liste_p_portail and exclusion.find(r)<0:
					po += u"# [["+r+ u"]] (évaluation présente en pdd)\n"
			for r in liste_p_portail:
				if not r in lsteval:
					eva += u"# [[Discussion:"+r+ u"]]\n"
         
 
			a=len(pages)
			pages.sort()
			print a
			poathleseul = u''
			tableeb = []
			tableinfo =[]
			tableebtot=[]

			lsthomon2= []
			lsthomon3 = []

			pywikibot.output(u'\03{lightpurple}\nFin portail\03{default}')

			for t in lsthomon:
				lsthomon2.append(u'[[%s]]' %t)
				lsthomon3.append(u'[[%s|' %t)
 
			for p in pagegenerators.PreloadingGenerator(pages,500):
##                              pagenamefull = p.title()
##                              pagename = p.title(withNamespace=False)
				if p.isRedirectPage():
					p = p.getRedirectTarget()
				if p.namespace()!=0:
					pywikibot.output(u"%s n'est pas un article (%s)" % (pagename, pagenamefull))
				else:
					try :
						pagenamefull = p.title()
						pagename = p.title(withNamespace=False)
						catborn = 0
						catdeces = 1 
						text = p.get()
						lines = text.split('\n')
						#lienintern = p.linkedPages()
						indexLienIntern = 0
						indexISBN = 0
						countorph = 0
						listlienintern = []
	 
						if p_orph == '1' and 1==1: ## Section pages orphelines
							mots = p.getReferences()
							for m in mots:
								if m.namespace()==0:
									countorph += 1
							if countorph ==0:
								orph +=u'# [[%s]]\n' % pagename
						if p_homo == '1':
							#print time.strftime('%Y%m%d%H%M%S',time.localtime()), p.title()
							for t in lsthomon2:
								if t in text:
									t = t.replace(u'[',u'')
									t = t.replace(u']',u'')
									if indexLienIntern == 0:
										homon += u'\n# [[%s]] ({{lh|%s}})' % (pagename, t)
									else:
										homon += u' ({{lh|%s}})' %t
									indexLienIntern =1
							for t in lsthomon3:
								if t in text:
									t = t.replace(u'[',u'')
									t = t.replace(u'|',u'')
									if indexLienIntern == 0:
										homon += u'\n# [[%s]] ({{lh|%s}})' % (pagename, t)
									else:
										homon += u' ({{lh|%s}})' %t
									indexLienIntern =1
						if p_isbn == '1':
							for t in lstisbn:
								if pagename in lstisbn:
									if indexISBN == 0:
										isbn += u'# [[%s]]\n' % pagename
									indexISBN = 1

						if len(testbandeau(text,pagename))>=4 and p_bandeau == '1':
							band += testbandeau(text,pagename)
						if len(text)>int(t_noref):
							if text.find(u'<ref')<0 and not re.search(u'{{[Rr]éférence(s|) (ITF|FedCup|Joueur FC Bruges)',text):
								noref += u'# [['+pagename+u']]\n'
						if re.search(u'\[\[(Fichier|Image|File)\:.+\.\w{3}\|thumb\]\]',text):
							nolegend += u'# [[%s]]\n' % pagename
						if re.search(u'{{[éÉEe]bauche',text):
							tableebtot.append(pagename)
							if (not pagename in pddeb) and pagename in lsteval and pdd_badeval == '1':
									tableevaleb += u'# [[' + pagename + u']]\n'
							if len(text)>int(t_longeb) and p_longeb == '1':
								eb += u'# [[' + pagename + u']]\n' #longue ébauche
						elif (not pagename in pddeb) and (not pagename in pddinc):
							if len(text)<int(t_boneval):
								BD += u'# [[%s]]\n' % pagename
						if p.isIpEdit() and p_lastip == '1':
							temps = p.editTime()
							ip += ipdate(temps,pagename)
						if len(pywikibot.getLanguageLinks(text))>0:
							lieniw = pywikibot.getLanguageLinks(text)
							#raw_input(str(lieniw))
							if not re.search(u'#',str(lieniw)):
								interwiki += u'# [[%s]]\n' % pagename #9999 à améliorer, filter les interlangue à section
						intro = text
						if text.find(u'==')>0:
							intro = text[:text.find(u'==')]
						if not re.search(u"'''",intro) and not re.search(u'<dfn>',intro) and not re.search(u'{{([Tt]erme défini|[Ss]ujet)',intro):
							sanstitre += u'# [[%s]]\n' % pagename
						if re.search(u"{{[Pp]ortail.?.?[Aa]thlétisme}}",text):
							poathleseul += u'# [[%s]]\n' % pagename
						if pagename.count(u'(')>0 and pagename.count(u'rugby à XV')==0:
							parenthese += u'# [[Discussion:%s]]\n' % pagename
						if len(tableaumixte(text,pagename))>=4:
							tableau += tableaumixte(text,pagename)
						if not re.search(u'{{ *[Aa]rbre généalogique',text):
							if re.search(u'\[\[\:\w\w\w?\:\w+',text) and not re.search(u'\[\[\:\w\w\w?\:\w+#',text):
								CS+= u'# [[%s]] (lien interwiki <nowiki>[[:xx:abc]]</nowiki> dans le corps de texte, à remplacer par [[modèle:lien]])\n' % pagename
							if re.search(u'\[\[\[^].]*\|[^].]*\|[^].]*\]\]',text):
								CS+= u'# [[%s]] (double pipe dans lien interne)\n' % pagename
							if text.find(u'[[Catégorie:')>0 and (text.find(u'[[Catégorie:')<text.find(u'{{Portail') or text.find(u'[[Catégorie:')<text.find(u'{{portail')):
								CS += u'# [[%s]] (catégorie avant portail)\n' % pagename
							if text.find(u'{{Portail')>0 and (text.find(u'{{Portail')<text.find(u'{{Palette') or text.find(u'{{Portail')<text.find(u'{{palette')):
								CS += u'# [[%s]] (portail avant palette)\n' % pagename
							if text.find(u'{{portail')>0 and (text.find(u'{{portail')<text.find(u'{{Palette') or text.find(u'{{portail')<text.find(u'{{palette')):
								CS += u'# [[%s]] (portail avant palette)\n' % pagename
							if text.count(u'[')!=text.count(u']'):
								if text.count(u'[')<text.count(u']'):
									#print "DEDANS 300", pagename
									countco = 0
									countcf = 0
									position1 = -1
									position2 = -1
									for t in text:
										position1 += 1
										position2 += 1
										if t == u'[': countco += 1
										if t == u']': countcf += 1
										#print pagename, countpo, countpf, text.count(u'('), text.count(u')')
										if countcf>countco:
											if position1<20: position1 =20
											if position2>len(text)-20 : position2 = len(text)-20
											lieu = text[position1-20:position1]+u"</nowiki>'''"+text[position1]+u"'''<nowiki>"+text[position1+1:position2+20]
											lieu = re.sub(u'\n',u"",lieu)
											CS+= u"# [[%s]] ''crochet ] en trop ou crochet [ manquant : ''<nowiki>...%s...</nowiki>\n" % (pagename, lieu)
											break
								else :
									#print "DEDANS 30", pagename
									if re.search(u'\[[^\n^]]+\n',text):
										lieu = re.search(u'(\[[^\n^]]+)\n',text).group(1)
										CS+= u"# [[%s]] ''crochet [ qui ne se ferme pas avant retour à la ligne ''<nowiki>...%s</nowiki>\n" % (pagename, lieu)		
							if text.count(u'(')!=text.count(u')'):
								if text.count(u'(')<text.count(u')'):
									countpo = 0
									countpf = 0
									positionp1 = -1
									positionp2 = -1
									for t in text:
										positionp1 += 1
										positionp2 += 1
										if t == u'(': countpo += 1
										if t == u')': countpf += 1
										if countpf>countpo:

											if positionp1<20: positionp1 =20
											if positionp2>len(text)-20 : positionp2 = len(text)-20
											lieu = text[positionp1-20:positionp1]+u"</nowiki>'''"+text[positionp1]+u"'''<nowiki>"+text[positionp1+1:positionp2+20]
											lieu = re.sub(u'\n',u"",lieu)
											CS+= u"# [[%s]] ''parenthèse ) en trop ou parenthèse ( manquante : ''<nowiki>...%s...</nowiki>\n" % (pagename, lieu)

											break
							else :
								#print "DEDANS 40", pagename
								if re.search(u'\([^\n^)]+\n',text):
									lieu = re.search(u'(\([^\n^)]+)\n',text).group(1)
									if not re.search(u'{{ *([Ll]ien web|[Aa]rticle)',lieu):
										CS+= u"# [[%s]] ''parenthèse ( qui ne se ferme pas avant retour à la ligne : ''<nowiki>...%s</nowiki>\n" % (pagename, lieu)

					except : pass                              
							
 
			pywikibot.output(u'\03{lightpurple}Portail terminé\03{default}')
 
 
	########### Categorie Bio ############################################
			lsten , lstdate , lstdecesen,lstdecesfr = [],[],[],[]
			lstsansimage, lstsansimagefr ,lstsansson, gtennis , lstgtennis = [],[],[],[],[]
			deadurl = u''
			iaaf = u''
			fis = u''
			eurohockey, entetehockey = u'',u''
			porecord = u''
			langimage = u'en' #99999 choix du site à parcourir pour les images
			pywikibot.output(u'\03{lightpurple}\nDébut biographies (catégorie)\03{default}')
			if len(nomsport)>0:
				pywikibot.output( nomsport)
				cat = catlib.Category(site, nomsport)
				pages = cat.articlesList(True)
				pywikibot.output( nomsport2)
				cat2 = catlib.Category(site, nomsport2)
				pages2 = cat2.articlesList(True)
				pages3 = []

				listeaexclure = [u"Sigmund Freud",u"Livre de Sigmund Freud‎",u"Métapsychologie‎",u"Terminologie lacanienne‎",u"Livre de Jacques Lacan",u"Jacques Lacan",u"Livre de Carl Gustav Jung‎",u"Archétype jungien",u"Carl Jung",u"Jean Bouin",u"Famille Brontë‎",u"Mary Wollstonecraft",u"Barbara Cartland‎",u"Agatha Christie‎",u"Arthur Conan Doyle",u"Ian McEwan"]
				pywikibot.output( 'listeaexclure')
				for l in listeaexclure:
					pywikibot.output(l)
					cat = catlib.Category(site, l)
					pages3= pages3 + cat.articlesList(True)

				pages0 =  list(set(pages+pages2)-set(pages3))
				pages0.sort()
				pywikibot.output(u'\03{lightpurple}\nDébut biographies\03{default}')
				d = len(pages0)
				
				for p in pagegenerators.PreloadingGenerator(pages0,500):
					pagename = p.title()
					d = d-1
					if d%50==0:
						print d
					if p.isRedirectPage():
						p = p.getRedirectTarget()
					if p.namespace()!=0 or exclusion.find(pagename)>0:
						print u'n est pas un article ou article exclus'
						pywikibot.output(pagename)
					else:
						#try:
						if 1==1:
							catborn = 0
							catdeces = 1
							decesen =1
							text = p.get()
							lines = text.split('\n')
							listeinterwiki = p.interwiki()
							lienen = u''
							index =-1

							## mis en commentaire car
##							    sitetest = l.site()
##                                                                TypeError: 'APISite' object is not callable
##							if b_nofile=='1' or b_nobirth=='1' or b_nodeath=='1':
##								for l in listeinterwiki:
##									sitetest = l.site()
##									if l.site()== pywikibot.getSite(langimage,'wikipedia'):
##										lienen = l
##										index = 1
##										#print pagename, l.title()

							if not re.search(u'.\.(jpg|JPG|jpeg|JPEG|png|PNG|gif|GIF|svg|SVG|tif|TIF)',text) and not re.search(u"roperty\:[Pp]18",text) and not re.search(u"[Ww]ikipedia\|[Pp]18",text) and b_nofile=='1' and index>0:
								#lstsansimage.append(pywikibot.Page(siteen, lienen))
								lstsansimage.append(lienen)
								lstsansimagefr.append(p.title())
							if not re.search(u'{{ *[Ii]nfobox',text) and not re.search(u'{{'+infobox[0].lower()+infobox[1:],text) and not re.search(u'{{'+infobox,text) and len(text)>0 and b_nobox=='1':
								if not re.search(u'{{[jJ]oueur de bas',text): #exclusion autre modèle
									longueur=len(text)
									tableinfo.append([longueur,pagename])
							if re.search(u"{{ *[Ii]nfobox [Bb]iographie2",text) and not re.search(u'{{'+infobox,text) :
								boxbio2 += u'# [[%s]]\n' % pagename
							if not re.search(u"{{ *[IAFiaf]* name\|",text) and re.search(u"Naissance en .*19[789]\d",text) and len(text)>3000:
								iaaf += u'# [[%s]]\n' % pagename
							if not re.search(u"{{ *FIS",text):# and re.search(u"Naissance en .*19\d",text):
								fis += u'# [[%s]]\n' % pagename
							if re.search(u"{{ *[Pp]ortail.*[Rr]ecord",text):
								porecord += u'# [[%s]]\n' % pagename
	 
							if nompage==u'Hockey':
								
								if not re.search(u"{{ *[Ss]tat hockey */ *début (joueur|gardien)",text) and len(text)>2000:
									entetehockey += u'# [['+pagename+u']]\n'
									
								if re.search(u"eurohockey\.net",text):
									eurohockey += u'# [['+pagename+u']]\n'
							if p_noportal=='1':
								if not pagename in liste_p_portail:
									po += testportail(text,pagename,portail)
							if len(testdefaulsort(text,pagename))>=1 and b_nokey=='1':
								defo += testdefaulsort(text,pagename)
							if re.search(u'atégorie *\: *[nN]aissance (en|le)',text) or re.search(u'atégorie *\: *[Dd]ate de naissance',text):
								catborn=1
								#print 'dedans1',pagename, re.search(u'atégorie\: ?[Dd]écès',text)
								if not re.search(u'atégorie\: ?[Dd]écès',text) and not re.search(u'atégorie\: ?[dD]ate de décès',text) and index>0:
									lstdecesen.append(lienen)
									lstdecesfr.append(p.title())
									if re.search(u'aissance en 1(90|8|7|6|5|4)',text):
										catdeces = 0
##								if re.search(u'atégorie\: ?[Nn]aissance en 1',text) and len(l)<33: ##pour éviter les villes
##									deb = l.find(u'aissance en ')+12
##									date = u''
##									date = l[deb:deb+4]
##									for ll in lines:
##										if index>0 and 1==2: #99999 désactivé pour faire des tests
##											lsten.append(lienen)
##											lstdate.append([date,pagename])
							lines = text.split('\n')
							if p_deadurl == 1:
								if text.find(u'results.beijing2008.cn')<0: #exception 
									for l in lines:
										if re.search(u'\[ *(http://[^\s^|^\]^\ ]+) *',l): #espace, pipe, crochet, espace insécable
											url = re.search(u'\[ *(http://[^\s^|^\ ]+) *',l).group(1)
											#print url
											try :
												page=urllib.urlopen(url)
											except :
												if url.count(u' ')==0:
													deadurl += u'# [['+pagename+u']] '+url+u'\n'
													pywikibot.output(pagename)
													pywikibot.output(url)
						#except : pass
					if catborn==0 and b_nobirth=='1' and exclusion.find(pagename)<0 and not re.search(u'Catégorie:Mohamed Ali',text):
						na = na + u'# [['+pagename+u']]\n'
					if catdeces==0 and b_nodeath=='1' and exclusion.find(pagename)<0 and not re.search(u'Catégorie:Mohamed Ali',text):
						deces = deces + u'# [['+pagename+u']]\n'
			if b_nofile=='1':
				print "#### VERIFIE IMAGE ####"
				#sansimage = verifimage(lstsansimage,lstsansimagefr,langimage) #désactivé
				#sansimage = verifimage(lstdecesen[:10],lstdecesfr[:10],langimage)
			if b_nosound=='1':
				print "#### VERIFIE SON ####"
				#sansson = verifson(lstsansson,'en') #désactivé
			if b_deathen=='1':
				print "#### VERIFIE DATE DE DECES ####"
				diffdec = datadeces(lstdecesen,lstdecesfr)
				#diffdec = datadeces(lstsansimage,lstsansimagefr)
			if b_birthen=='1':
				print "#### VERIFIE DATE DE NAISSANCE ####"
				diffna = data(lsten,lstdate)
			pywikibot.output(u'\03{lightpurple}\nFinal\03{default}')
			for t in tableinfo:
				info = info + u'# [[' + t[1] + u']]\n' #+ str(t[0]) +u')\n'
 
			if not nompage==u'Athlétisme' or (nompage==u'Athlétisme' and not re.search(u'ultra',text)):
				iaaf = u''
				porecord = u''
				poathleseul = u''
			if not nom_projet==u'Combiné nordique' and not nom_projet==u'Saut à ski' and not nom_projet==u'Ski de fond':
				fis = u''
			if not nompage==u'Hockey':
				eurohockey = u''
				tableau = u''
				entetehockey=u''
			if not nompage==u'Rugby à XV' or 1==1: #désactivé pour le rugby
				parenthese = u''
			if nompage==u'Sport automobile':
				#po  = u'désactivé, en cours de réglages'
				info =u'désactivé, en cours de réglages'
			if not re.search(u'[Ss]port',nom_domaine):
				evalsport = u''
			#po = u'Désactivé temporairement'

			
 
			result = u'Mise à jour le ~~~~~\n\n== Page du projet =='
			if po.count('#')>20:    result = result+ u'\n=== Sans portail ===\n{{boîte déroulante début|titre=Articles sans le portail du projet}}\n' + po+u'{{boîte déroulante fin}}\n'
			elif len(po)>1:         result = result+ u'\n=== Sans portail ===\n' + po
			if eb.count('#')>20:    result = result+ u'\n=== Longues ébauches ===\n{{boîte déroulante début|titre=Articles en ébauches de plus de '+t_longeb+u' octets}}\n' + eb+u'{{boîte déroulante fin}}\n'
			elif len(eb)>1:         result = result+ u'\n=== Longues ébauches ===\n' + eb
			if noref.count('#')>20: result = result+ u'\n=== Longs articles sans ref ===\n{{boîte déroulante début|titre=Articles de plus de '+t_noref+u' octets sans ref}}\n' + noref+u'{{boîte déroulante fin}}\n'
			elif len(noref)>1:      result = result+ u'\n=== Longs articles sans ref ===\n' + noref
			if BD.count('#')>20:    result = result+ u'\n=== Articles bien évalués mais courts ===\n{{boîte déroulante début|titre=Articles bien évalués de moins de '+t_boneval+u' octets}}\n' + BD+u'{{boîte déroulante fin}}\n'
			elif len(BD)>1:         result = result+ u'\n=== Articles bien évalués mais courts ===\n' + BD
			if p_orph ==2: result = result+ u'\n=== Orphelins ===\nForcé désactivé, test en cours\n'
			elif orph.count('#')>20:  result = result+ u'\n=== Orphelins ===\n{{boîte déroulante début|titre=Articles orphelins}}\n' + orph +u'{{boîte déroulante fin}}\n'
			elif len(orph)>1:       result = result+ u'\n=== Orphelins ===\n' + orph
			if band.count('#')>20:  result = result+ u'\n=== Bandeaux ===\n{{boîte déroulante début|titre=Articles avec un bandeau de maintenance}}\n' + band+u'{{boîte déroulante fin}}\n'
			elif len(band)>1:       result = result+ u'\n=== Bandeaux ===\n' + band
			if nolegend.count('#')>20:      result = result+ u'\n=== Images sans légende ===\n{{boîte déroulante début|titre=Articles avec une image non légendée}}\n' + nolegend+u'{{boîte déroulante fin}}\n'
			elif len(nolegend)>1:   result = result+ u'\n=== Images sans légende ===\n' + nolegend
			if ip.count('#')>20:    result = result+ u'\n=== IP ===\n{{boîte déroulante début|titre=Articles ayant une IP comme dernier contributeur}}\n' + ip+u'{{boîte déroulante fin}}\n'
			elif len(ip)>1:         result = result+ u'\n=== IP ===\n' + ip
			if poathleseul.count('#')>20:   result = result+ u'\n=== Portail athlétisme seul ===\n{{boîte déroulante début|titre=Articles avec un seul portail}}\n' + poathleseul+u'{{boîte déroulante fin}}\n'
			elif len(poathleseul)>1:        result = result+ u'\n=== Portail athlétisme seul ===\n' + poathleseul
			if homon.count('#')>20: result = result+ u"\n=== Homonymie ===\n{{boîte déroulante début|titre=Articles ayant un lien interne vers une page d'homonymie}}\n" + homon+u'{{boîte déroulante fin}}\n'
			elif len(homon)>1:      result = result+ u"\n=== Homonymie ===\n" + homon
			if isbn.count('#')>20: result = result+ u"\n=== ISBN invalide ===\n{{boîte déroulante début|titre=Articles ayant un numéro ISBN invalie}}\n" + isbn+u'{{boîte déroulante fin}}\n'
			elif len(isbn)>1:      result = result+ u"\n=== ISBN invalide ===\n" + isbn
			if sanstitre.count('#')>20:     result = result+ u"\n=== Sans titre en gras ===\n{{boîte déroulante début|titre=Articles sans titre en gras}}\n" + sanstitre+u'{{boîte déroulante fin}}\n'
			elif len(sanstitre)>1:  result = result+ u"\n=== Sans titre en gras ===\n" + sanstitre
			if parenthese.count('#')>20:    result = result+ u"\n=== Parenthèse sans rugby à XV ===\n{{boîte déroulante début|titre=Articles avec parenthèse sans rugby à XV}}\n" + parenthese+u'{{boîte déroulante fin}}\n'
			elif len(parenthese)>1: result = result+ u"\n=== Parenthèse sans rugby à XV ===\n" + parenthese
			if interwiki.count('#')>20:    result = result+ u"\n=== Reste liens interlangues===\n{{boîte déroulante début|titre=Reste liens interlangues à transférer vers wikidata}}\n" + interwiki+u'{{boîte déroulante fin}}\n'
			elif len(interwiki)>1: result = result+ u"\n=== Reste liens interlangues ===\n" + interwiki
			if CS.count('#')>20:    result = result+ u"\n=== Détection [[P:CS]] ===\n{{boîte déroulante début|titre=Liste d'erreurs syntaxiques}}\n" + CS+u'{{boîte déroulante fin}}\n'
			elif len(CS)>1: result = result+ u"\n=== Détection [[P:CS]] ===\n" + CS
			if tableau.count('#')>20:    result = result+ u"\n=== Tableau mixte ===\n{{boîte déroulante début|titre=articles avec un tableau mixte}}\n" + tableau+u'{{boîte déroulante fin}}\n'
			elif len(tableau)>1: result = result+ u"\n=== Tableau mixte ===\n" + tableau
 
			result = result+ u'\n== Biographie ==\n'
			if na.count('#')>20:    result = result+ u'\n=== Sans catégorie de date de naissance ===\n{{boîte déroulante début|titre=Articles biographique sans catégorie de date de naissance}}\n' + na+u'{{boîte déroulante fin}}\n'
			elif len(na)>1:         result = result+ u'\n=== Sans catégorie de date de naissance ===\n' + na
			if len(deces)>1:        result = result+ u'\n=== Sans date de décès ===\n' + deces
			if len(diffna)>1:       result = result+ u'\n=== Naissance différente sur en.wp (basé sur les catégories) ===\n' + diffna
			if len(diffdec)>1:     result = result+ u'\n=== Personne déclarée morte sur en.wp (basé sur les catégories) ===\n' + diffdec
			if len(defo)>1:         result = result+ u'\n=== Sans clé de tri ===\n' + defo
			#if len(sansimage)>1:    result = result+ u'\n=== Sans image ===\n' + sansimage
			#if len(sansson)>1:      result = result+ u'\n=== Sans fichier son ===\n' + sansson                                                                                 
			if len(entetehockey)>1:         result = result+ u'\n=== Joueurs sans modèle Stat hockey ===\n{{boîte déroulante début|titre=Joueur de hockey sans modèle Stat hockey}}\n' + entetehockey+u'{{boîte déroulante fin}}\n' 
			#if len(iaaf)>1:         result = result+ u'\n=== Athlètes sans profil IAAF* ===\n{{boîte déroulante début|titre=Biographies sans profil IAAF}}\n' + iaaf+u'{{boîte déroulante fin}}\n'
			#if len(fis)>1:         result = result+ u'\n=== Sportifs sans profil FIS* ===\n{{boîte déroulante début|titre=Biographies sans profil FIS}}\n' + fis+u'{{boîte déroulante fin}}\n'
			if len(porecord)>1:             result = result+ u'\n=== Portail record ===\n' + porecord+u'\n'
			if len(eurohockey)>1:   result = result+ u'\n=== Lien eurohockey ===\n{{boîte déroulante début|titre=Biographies avec lien eurohockey.net}}\n' + eurohockey+u'{{boîte déroulante fin}}\n'
			if deadurl.count('#')>20: result = result+ u'\n=== Lien externe potentiellement mort ===\n{{boîte déroulante début|titre=Lien externe sans chargement}}\n' + deadurl +u'{{boîte déroulante fin}}\n'
			elif len(deadurl)>1:   result = result+ u'\n=== Lien externe potentiellement mort ===\n' + deadurl+u'\n'
			if info.count('#')>20:  result = result+ u'\n=== Sans infobox ===\n{{boîte déroulante début|titre=Biographies sans infobox}}\n' + info +u'{{boîte déroulante fin}}\n'
			elif len(info)>1:       result = result+ u'\n=== Sans infobox ===\n' + info
			if boxbio2.count('#')>20:  result = result+ u'\n=== Infobox Biographie2 ===\n{{boîte déroulante début|titre=Biographies sans infobox}}\n' + boxbio2 +u'{{boîte déroulante fin}}\n'
			elif len(boxbio2)>1:       result = result+ u'\n=== Infobox Biographie2 ===\n' + boxbio2

			result = result+ u'\n== Page de discussion ==\n'
			if eva.count('#')>20:           result = result+ u'\n=== Sans l\'évaluation du projet ===\n{{boîte déroulante début|titre=Sans éval}}\n' + eva+u'{{boîte déroulante fin}}\n'
			elif len(eva)>1:                result = result+ u'\n=== Sans l\'évaluation du projet ===\n' + eva
			if tableevaleb.count('#')>20:   result = result+ u'\n=== Évaluation contraire ===\n{{boîte déroulante début|titre=Évaluations contraires}}\n' + tableevaleb+u'{{boîte déroulante fin}}\n'
			elif len(tableevaleb)>1:        result = result+ u'\n=== Évaluation contraire ===\n' + tableevaleb
			if evalsport.count('#')>20:     result = result+ u'\n=== Manque évaluation sport ===\n{{boîte déroulante début|titre=Évaluation du projet sport manquante}}\n' + evalsport+u'{{boîte déroulante fin}}\n'
			elif len(evalsport)>1:  result = result+ u'\n=== Manque évaluation sport ===\n' + evalsport
			if len(evalredirect)>1: result = result+ u"\n=== Évaluation d'une redirection ===\n" + evalredirect
			if ippdd.count('#')>20: result = result+ u"\n=== IP ===\n{{boîte déroulante début|titre=Dernière modification faite par une IP}}\n" + ippdd+u'{{boîte déroulante fin}}\n'
			elif len(ippdd)>1:      result = result+ u"\n=== IP ===\n" + ippdd
 
			deb= text1st.find('{{Utili')
			fin= text1st.find('}}',deb)+2
			entete = text1st[:fin]+u'\n'
			if nom_domaine == u'sport':
				result = entete + result + u'\n{{utilisateur:Sisyph/Modèle Portail Sport}}'
			elif nom_domaine == u'Arménie':
				result = entete + result + u'\n[[Catégorie:Projet:Arménie/Suivi]]'
			else : result = entete + result
 
			f= open(u'Result.txt','w')
			f.write(result.encode('utf-8'))
			f.close()
			pywikibot.output(u'\03{lightpurple}\nFin ecriture .txt\03{default}')
			######################################################################################################
 
			if site.messages():
					message = input(u'Un message est arrive, nimporte quelle touche pour continuer')
 
			text = u''
			pywikibot.showDiff(text1st, result)
			choice = 'u'
			choice = pywikibot.inputChoice(u'upload, Skip', [ 'upload', 'Skip' ], ['u', 'S'], 's')
			if choice == 'u':
				comment = u'Bot, mise à jour'
				tt.put(result,comment)
 
 
if __name__ == '__main__':
	try:
		main()
	finally:
		pywikibot.stopme()