« FormatBot » : différence entre les versions
(Wikipastbot update) |
(Wikipastbot update) |
||
Ligne 10 : | Ligne 10 : | ||
* Il détecte si la date contient une année, ou une année et un mois, ou une année et un mois et un jour. | * Il détecte si la date contient une année, ou une année et un mois, ou une année et un mois et un jour. | ||
* Pour chacun de ces trois cas, il vérifie que la date est dans le bon ordre et qu'elle est bien séparée par des points. Si ce n'est pas le cas, elle réécrit la date dans le bon ordre et avec les bons séparateurs. | * Pour chacun de ces trois cas, il vérifie que la date est dans le bon ordre et qu'elle est bien séparée par des points. Si ce n'est pas le cas, elle réécrit la date dans le bon ordre et avec les bons <span style="color:red">séparateurs</span> (correction(s): <span style="color:green">séparateur, réparateurs | ||
</span>). | |||
* Lorsque l'hypermot a une distinction entre le lien vers une autre page et l'affichage de cet hypermot (l'hypermot est affiché sous la forme \[ lien | affichage\], il ne modifie que la partie affichage de l'hypermot pour ne pas casser le lien. | * Lorsque l'hypermot a une distinction entre le lien vers une autre page et l'affichage de cet hypermot (l'hypermot est affiché sous la forme \[ lien | affichage\], il ne modifie que la partie affichage de l'hypermot pour ne pas casser le lien. | ||
Ligne 22 : | Ligne 23 : | ||
**Année. | **Année. | ||
*L'année doit avoir 3 ou 4 chiffres, et les mois et les jours doivent avoir 2 chiffres au plus. | *L'année doit avoir 3 ou 4 chiffres, et les mois et les jours doivent avoir 2 chiffres au plus. | ||
*Chaque séparateur est compris est dans une liste prédéfinie | *Chaque séparateur est compris est dans une liste <span style="color:red">prédéfinie</span> (correction(s): <span style="color:green">prédéfini, prédéfinies | ||
</span>) | |||
===Exemple 1=== | ===Exemple 1=== | ||
Ligne 36 : | Ligne 38 : | ||
===Exemple 2=== | ===Exemple 2=== | ||
Si la date en question a une redirection différente de celle affichée, la redirection n'est pas modifiée tandis que la date inscrite le sera. | Si la date en question a une <span style="color:red">redirection</span> (correction(s): <span style="color:green"> | ||
</span>) différente de celle affichée, la <span style="color:red">redirection</span> (correction(s): <span style="color:green"> | |||
</span>) n'est pas modifiée <span style="color:red">tandis</span> (correction(s): <span style="color:green">candis, tendis, taudis | |||
</span>) que la date inscrite le sera. | |||
Code wiki | Code <span style="color:red">wiki</span> (correction(s): <span style="color:green">kiki, tiki | ||
</span>) | |||
<nowiki> | <nowiki> | ||
*[[1874-10-30|1874/10/30]] / [[Woodstock, Oxfordshire]]. [[Naissance]] de '''Winston Churchill''' | *[[1874-10-30|1874/10/30]] / [[Woodstock, Oxfordshire]]. [[Naissance]] de '''Winston Churchill''' | ||
Ligne 72 : | Ligne 78 : | ||
from bs4 import BeautifulSoup | from bs4 import BeautifulSoup | ||
user="formatbot" | user="<span style="color:red">formatbot</span> (correction(s): <span style="color:green"> | ||
</span>)" | |||
passw='accjjlms' | passw='accjjlms' | ||
baseurl='http://wikipast.epfl.ch/wikipast/' | baseurl='http://wikipast.epfl.ch/wikipast/' | ||
Ligne 110 : | Ligne 117 : | ||
#fonction qui détecte le début d'une ligne et retourne l'indice du premier caractere apres '*' | #fonction qui détecte le début d'une ligne et retourne l'indice du premier caractere apres '*' | ||
def line_start_detect(code): | <span style="color:red">def</span> (correction(s): <span style="color:green">zef, der, des, nef, de, dey | ||
</span>) line_start_detect(code): | |||
line_index_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)=[] | |||
for i in range(len(code)): | for i in range(len(code)): | ||
if (code[i]=='\n'): | if (code[i]=='\n'): | ||
line_index_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>).append(i+2) | |||
return | line_index_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | ||
</span>).append(len(code)) | |||
<span style="color:red">return</span> (correction(s): <span style="color:green"> | |||
</span>) line_index_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>) | |||
def hypertext(code, line_index1, line_index2): | <span style="color:red">def</span> (correction(s): <span style="color:green">zef, der, des, nef, de, dey | ||
</span>) hypertext(code, line_index1, line_index2): | |||
hypermot_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)=[] | |||
for i in range(line_index1, line_index2): | for i in range(line_index1, line_index2): | ||
if (code[i]== '[' and code[i+1]=='['): | if (code[i]== '[' and code[i+1]=='['): | ||
Ligne 128 : | Ligne 143 : | ||
for k in range(i+2,i+j+1): | for k in range(i+2,i+j+1): | ||
hypermot+=code[k] | hypermot+=code[k] | ||
hypermot_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>).append(hypermot) | |||
j=0 | j=0 | ||
i=i+j+2 | i=i+j+2 | ||
return | <span style="color:red">return</span> (correction(s): <span style="color:green"> | ||
</span>) hypermot_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>) | |||
def | <span style="color:red">def</span> (correction(s): <span style="color:green">zef, der, des, nef, de, dey | ||
</span>) <span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis | |||
</span>)_<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | |||
</span>)(char): | |||
if(char=='0' or char=='1' or char=='2' or char=='3' or | if(char=='0' or char=='1' or char=='2' or char=='3' or | ||
char=='4' or char=='5' or char=='6' or char=='7' or | char=='4' or char=='5' or char=='6' or char=='7' or | ||
char=='8' or char=='9'): | char=='8' or char=='9'): | ||
return True | <span style="color:red">return</span> (correction(s): <span style="color:green"> | ||
</span>) True | |||
else : | else : | ||
return False | <span style="color:red">return</span> (correction(s): <span style="color:green"> | ||
</span>) False | |||
#decode l'hypermot | #<span style="color:red">decode</span> (correction(s): <span style="color:green">décode | ||
</span>) l'hypermot | |||
#retourne s'il s'agit d'une date, si le format est correct, et le vecteur de date | #retourne s'il s'agit d'une date, si le format est correct, et le vecteur de date | ||
#sortie : [ | #sortie : [<span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis | ||
</span>)_date, (bool) est-ce que cet hypermot peut etre vu comme une date ? | |||
# date_format_correct, (bool) le format de date est-il respecte ? | # date_format_correct, (bool) le format de date est-il respecte ? | ||
# date_format, (int) 1:aaaa 2:aaaa.mm 3:aaaa.mm.jj | # date_format, (<span style="color:red">int</span> (correction(s): <span style="color:green">ont, oint, inti, tint, vint, in | ||
# ['aaaa','mm','jj'] ] vecteur de la date interpretee | </span>)) 1:<span style="color:red">aaaa</span> (correction(s): <span style="color:green"> | ||
#Si | </span>) 2:<span style="color:red">aaaa</span> (correction(s): <span style="color:green"> | ||
def | </span>).mm 3:<span style="color:red">aaaa</span> (correction(s): <span style="color:green"> | ||
</span>).mm.<span style="color:red">jj</span> (correction(s): <span style="color:green">je, j, jà | |||
</span>) | |||
# ['<span style="color:red">aaaa</span> (correction(s): <span style="color:green"> | |||
</span>)','mm','<span style="color:red">jj</span> (correction(s): <span style="color:green">je, j, jà | |||
</span>)'] ] vecteur de la date interpretee | |||
#Si <span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis | |||
</span>)_date est False, le vecteur de date et data_format_correct sont incorrects | |||
<span style="color:red">def</span> (correction(s): <span style="color:green">zef, der, des, nef, de, dey | |||
</span>) date_<span style="color:red">decode</span> (correction(s): <span style="color:green">décode | |||
</span>)(hypermot): | |||
date_format_correct=True | date_format_correct=True | ||
<span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis | |||
</span>)_date=True | |||
date_format=0; | date_format=0; | ||
accepted_<span style="color:red">separator</span> (correction(s): <span style="color:green"> | |||
</span>) = ['.','-','. ',' .',' . ',',','/','\ ','_','pizza'] | |||
<span style="color:red">temp</span> (correction(s): <span style="color:green">tem, tempi, temps, tempe, tempo | |||
</span>)_bool_<span style="color:red">separator</span> (correction(s): <span style="color:green"> | |||
</span>)_in_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>) = False | |||
year_index=-1 | year_index=-1 | ||
Ligne 160 : | Ligne 200 : | ||
day_index=-1 | day_index=-1 | ||
#cree si possible la liste des annee/mois/jours, et les listes des séparateurs | #cree si possible la liste des annee/mois/jours, et les listes des <span style="color:red">séparateurs</span> (correction(s): <span style="color:green">séparateur, réparateurs | ||
</span>) | |||
<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)=[''] | |||
num_index=0 | num_index=0 | ||
<span style="color:red">separator</span> (correction(s): <span style="color:green"> | |||
</span>)_index_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)=[] | |||
<span style="color:red">separator</span> (correction(s): <span style="color:green"> | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)=[] | |||
sep_index=-1 | sep_index=-1 | ||
boo=False | boo=False | ||
for i in range(len(hypermot)): | for i in range(len(hypermot)): | ||
if | if <span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis | ||
</span>)_<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | |||
</span>)(hypermot[i]): | |||
boo=True | boo=True | ||
if boo==False: | if boo==False: | ||
return [False, False, 0,[]] | <span style="color:red">return</span> (correction(s): <span style="color:green"> | ||
</span>) [False, False, 0,[]] | |||
if not | if not <span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis | ||
</span>)_<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | |||
</span>)(hypermot[0]): | |||
if hypermot[0]== ' ': | if hypermot[0]== ' ': | ||
date_format_correct=False | date_format_correct=False | ||
if not | if not <span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis | ||
</span>)_<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | |||
return [ | </span>)(hypermot[1]): #un espace accepté mais pas deux | ||
<span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis | |||
</span>)_date=False | |||
<span style="color:red">return</span> (correction(s): <span style="color:green"> | |||
</span>) [<span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis | |||
</span>)_date,date_format_correct,date_format,<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)] | |||
else: | else: | ||
<span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis | |||
return [ | </span>)_date=False | ||
<span style="color:red">return</span> (correction(s): <span style="color:green"> | |||
</span>) [<span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis | |||
</span>)_date,False,0,[]] | |||
else: | else: | ||
<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)[num_index]+=hypermot[0] | |||
for i in range(1,len(hypermot)): | for i in range(1,len(hypermot)): | ||
if not | if not <span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis | ||
if | </span>)_<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | ||
</span>)(hypermot[i]): | |||
if <span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis | |||
</span>)_<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | |||
</span>)(hypermot[i-1]): | |||
num_index+=1 | num_index+=1 | ||
<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>).append('') | |||
sep_index+=1 | sep_index+=1 | ||
<span style="color:red">separator</span> (correction(s): <span style="color:green"> | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>).append(hypermot[i]) | |||
else: | else: | ||
<span style="color:red">separator</span> (correction(s): <span style="color:green"> | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)[sep_index]+=hypermot[i] | |||
<span style="color:red">separator</span> (correction(s): <span style="color:green"> | |||
</span>)_index_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>).append(i) | |||
else: | else: | ||
<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)[num_index]+=hypermot[i] | |||
#test de la validite des separateurs | #test de la validite des separateurs | ||
for i in range(len( | for i in range(len(<span style="color:red">separator</span> (correction(s): <span style="color:green"> | ||
if | </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | ||
</span>))): | |||
if <span style="color:red">separator</span> (correction(s): <span style="color:green"> | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)[i]!='.': | |||
date_format_correct=False | date_format_correct=False | ||
if len( | if len(<span style="color:red">separator</span> (correction(s): <span style="color:green"> | ||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>))>2: | |||
date_format_correct=False | date_format_correct=False | ||
if len( | if len(<span style="color:red">separator</span> (correction(s): <span style="color:green"> | ||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
for i in range(len( | </span>))!=3 or <span style="color:red">separator</span> (correction(s): <span style="color:green"> | ||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
for j in range(len( | </span>)[2]!=' ': | ||
if | <span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis | ||
</span>)_date=False | |||
if not | for i in range(len(<span style="color:red">separator</span> (correction(s): <span style="color:green"> | ||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>))): | |||
<span style="color:red">temp</span> (correction(s): <span style="color:green">tem, tempi, temps, tempe, tempo | |||
</span>)_<span style="color:red">separator</span> (correction(s): <span style="color:green"> | |||
</span>)_in_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>) = False | |||
for j in range(len(accepted_<span style="color:red">separator</span> (correction(s): <span style="color:green"> | |||
</span>))): | |||
if <span style="color:red">separator</span> (correction(s): <span style="color:green"> | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)[i]== accepted_<span style="color:red">separator</span> (correction(s): <span style="color:green"> | |||
</span>)[j]: | |||
<span style="color:red">temp</span> (correction(s): <span style="color:green">tem, tempi, temps, tempe, tempo | |||
</span>)_bool_<span style="color:red">separator</span> (correction(s): <span style="color:green"> | |||
</span>)_in_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>) = True | |||
if not <span style="color:red">temp</span> (correction(s): <span style="color:green">tem, tempi, temps, tempe, tempo | |||
</span>)_bool_<span style="color:red">separator</span> (correction(s): <span style="color:green"> | |||
</span>)_in_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>): | |||
<span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis | |||
</span>)_date=False | |||
#test de la validite de la date, classification du format de date | #test de la validite de la date, classification du format de date | ||
if len( | if len(<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | ||
if | </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | ||
</span>))==4: | |||
if <span style="color:red">number</span> (correction(s): <span style="color:green">nimber | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)[3]=='': | |||
date_format=3 | date_format=3 | ||
elif len( | elif len(<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | ||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>))<1 or len(<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>))>3: | |||
<span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis | |||
</span>)_date=False | |||
date_format_correct=False | date_format_correct=False | ||
else: | else: | ||
date_format=len( | date_format=len(<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | ||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)) | |||
#print( | #print(<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | ||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)) | |||
for i in range(date_format): #detection de l'annee dans la liste | for i in range(date_format): #detection de l'annee dans la liste | ||
if(len( | if(len(<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | ||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)[i])==3 or len(<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)[i])==4): | |||
if(year_index !=-1): #s'il y a au moins deux nombres à 3 ou 4 chiffres | if(year_index !=-1): #s'il y a au moins deux nombres à 3 ou 4 chiffres | ||
<span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis | |||
</span>)_date=False | |||
date_format_correct=False | date_format_correct=False | ||
year_index=i | year_index=i | ||
Ligne 236 : | Ligne 359 : | ||
if year_index==-1: #si aucune annee n'a ete trouvee | if year_index==-1: #si aucune annee n'a ete trouvee | ||
<span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis | |||
</span>)_date=False | |||
date_format_correct=False | date_format_correct=False | ||
return [ | <span style="color:red">return</span> (correction(s): <span style="color:green"> | ||
</span>) [<span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis | |||
</span>)_date,date_format_correct,date_format,<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>),'pas trouve year'] | |||
if date_format==3: | if date_format==3: | ||
Ligne 249 : | Ligne 377 : | ||
date_format_correct = False | date_format_correct = False | ||
else: | else: | ||
<span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis | |||
</span>)_date=False | |||
date_format_correct=False | date_format_correct=False | ||
return [ | <span style="color:red">return</span> (correction(s): <span style="color:green"> | ||
</span>) [<span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis | |||
</span>)_date,date_format_correct,date_format,<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)] | |||
if (int( | if (<span style="color:red">int</span> (correction(s): <span style="color:green">ont, oint, inti, tint, vint, in | ||
int( | </span>)(<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | ||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)[month_index])>12 or <span style="color:red">int</span> (correction(s): <span style="color:green">ont, oint, inti, tint, vint, in | |||
</span>)(<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)[month_index])<0 or | |||
<span style="color:red">int</span> (correction(s): <span style="color:green">ont, oint, inti, tint, vint, in | |||
</span>)(<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)[day_index])>31 or <span style="color:red">int</span> (correction(s): <span style="color:green">ont, oint, inti, tint, vint, in | |||
</span>)(<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)[day_index])<0): | |||
<span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis | |||
</span>)_date=False | |||
date_format_correct=False | date_format_correct=False | ||
return [ | <span style="color:red">return</span> (correction(s): <span style="color:green"> | ||
</span>) [<span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis | |||
</span>)_date,date_format_correct,date_format,<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)] | |||
if date_format==2: | if date_format==2: | ||
Ligne 264 : | Ligne 414 : | ||
else: | else: | ||
month_index=0 | month_index=0 | ||
if ( int( | if ( <span style="color:red">int</span> (correction(s): <span style="color:green">ont, oint, inti, tint, vint, in | ||
</span>)(<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)[month_index])>12 or <span style="color:red">int</span> (correction(s): <span style="color:green">ont, oint, inti, tint, vint, in | |||
</span>)(<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)[month_index])<0 ): | |||
<span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis | |||
</span>)_date=False | |||
date_format_correct=False | date_format_correct=False | ||
return [ | <span style="color:red">return</span> (correction(s): <span style="color:green"> | ||
</span>) [<span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis | |||
</span>)_date,date_format_correct,date_format,<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)] | |||
if int( | if <span style="color:red">int</span> (correction(s): <span style="color:green">ont, oint, inti, tint, vint, in | ||
</span>)(<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)[year_index])>2050: | |||
<span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis | |||
</span>)_date=False | |||
date_format_correct=False | date_format_correct=False | ||
if date_format==1: | if date_format==1: | ||
date_final=[ | date_final=[ <span style="color:red">number</span> (correction(s): <span style="color:green">nimber | ||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)[year_index] ] | |||
if date_format==2: | if date_format==2: | ||
date_final=[ | date_final=[<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | ||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)[year_index],<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)[month_index]] | |||
if date_format==3: | if date_format==3: | ||
date_final=[ | date_final=[<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | ||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)[year_index],<span style="color:red">number</span> (correction(s): <span style="color:green">nimber | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)[month_index], <span style="color:red">number</span> (correction(s): <span style="color:green">nimber | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)[day_index]] | |||
#rmq: | #<span style="color:red">rmq</span> (correction(s): <span style="color:green"> | ||
return [ | </span>): <span style="color:red">separator</span> (correction(s): <span style="color:green"> | ||
</span>)_index_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>) et <span style="color:red">separator</span> (correction(s): <span style="color:green"> | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>) sont retournes uniquement pour la phase de <span style="color:red">debugging</span> (correction(s): <span style="color:green"> | |||
</span>) | |||
<span style="color:red">return</span> (correction(s): <span style="color:green"> | |||
</span>) [<span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis | |||
</span>)_date,date_format_correct,date_format,date_final,<span style="color:red">separator</span> (correction(s): <span style="color:green"> | |||
</span>)_index_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>),<span style="color:red">separator</span> (correction(s): <span style="color:green"> | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)] | |||
def date_format( | <span style="color:red">def</span> (correction(s): <span style="color:green">zef, der, des, nef, de, dey | ||
</span>) date_format(<span style="color:red">decode</span> (correction(s): <span style="color:green">décode | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)): | |||
date_<span style="color:red">temp</span> (correction(s): <span style="color:green">tem, tempi, temps, tempe, tempo | |||
</span>)="" | |||
for i in range(0, | for i in range(0,<span style="color:red">decode</span> (correction(s): <span style="color:green">décode | ||
if i<( | </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | ||
</span>)[2]) : | |||
if i<(<span style="color:red">decode</span> (correction(s): <span style="color:green">décode | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)[2]-1): | |||
date_<span style="color:red">temp</span> (correction(s): <span style="color:green">tem, tempi, temps, tempe, tempo | |||
</span>)+=<span style="color:red">decode</span> (correction(s): <span style="color:green">décode | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)[3][i]+<span style="color:red">decode</span> (correction(s): <span style="color:green">décode | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)[5][i] | |||
else : | else : | ||
date_<span style="color:red">temp</span> (correction(s): <span style="color:green">tem, tempi, temps, tempe, tempo | |||
</span>)+=<span style="color:red">decode</span> (correction(s): <span style="color:green">décode | |||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)[3][i] | |||
char_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
for c in | </span>)=<span style="color:red">decode</span> (correction(s): <span style="color:green">décode | ||
</span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)[5] | |||
for c in char_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>) : | |||
date_<span style="color:red">temp</span> (correction(s): <span style="color:green">tem, tempi, temps, tempe, tempo | |||
</span>)=date_<span style="color:red">temp</span> (correction(s): <span style="color:green">tem, tempi, temps, tempe, tempo | |||
</span>).replace(c,".") | |||
date_final= | date_final=date_<span style="color:red">temp</span> (correction(s): <span style="color:green">tem, tempi, temps, tempe, tempo | ||
return date_final | </span>).replace(" ","") | ||
<span style="color:red">return</span> (correction(s): <span style="color:green"> | |||
</span>) date_final | |||
## fonction qui reçoit en argument le code wiki complet la date à modifier et la date formatée | ## fonction qui reçoit en argument le code <span style="color:red">wiki</span> (correction(s): <span style="color:green">kiki, tiki | ||
## la fonction ne retourne rien et écrit directement sur la page wiki | </span>) complet la date à modifier et la date formatée | ||
def | ## la fonction ne retourne rien et écrit directement sur la page <span style="color:red">wiki</span> (correction(s): <span style="color:green">kiki, tiki | ||
</span>) | |||
<span style="color:red">def</span> (correction(s): <span style="color:green">zef, der, des, nef, de, dey | |||
</span>) <span style="color:red">wiki</span> (correction(s): <span style="color:green">kiki, tiki | |||
</span>)_write(code,old_date,new_date,name): | |||
new_code = [] | new_code = [] | ||
Ligne 314 : | Ligne 531 : | ||
print(r4.text) | print(r4.text) | ||
print('Modification dans '+name+', '+old_date+' remplacé par '+new_date) | print('Modification dans '+name+', '+old_date+' remplacé par '+new_date) | ||
return new_code | <span style="color:red">return</span> (correction(s): <span style="color:green"> | ||
</span>) new_code | |||
def barre_detect(hypermot): | <span style="color:red">def</span> (correction(s): <span style="color:green">zef, der, des, nef, de, dey | ||
</span>) barre_detect(hypermot): | |||
barre=False | barre=False | ||
syntax_part="" | syntax_part="" | ||
Ligne 326 : | Ligne 545 : | ||
if barre==False : | if barre==False : | ||
syntax_part=hypermot | syntax_part=hypermot | ||
return[barre,syntax_part] | <span style="color:red">return</span> (correction(s): <span style="color:green"> | ||
</span>)[barre,syntax_part] | |||
Ligne 340 : | Ligne 560 : | ||
code+=primitive.string | code+=primitive.string | ||
line_index_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
a=hypertext(code, | </span>)=line_start_detect(code) | ||
a=hypertext(code, line_index_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)[0], line_index_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>)[len(line_index_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit | |||
</span>))-1]) | |||
for i in range(len(a)): | for i in range(len(a)): | ||
barre=barre_detect(a[i]) | barre=barre_detect(a[i]) | ||
b= | b=date_<span style="color:red">decode</span> (correction(s): <span style="color:green">décode | ||
</span>)(barre[1]) | |||
if (b[0]==1 and b[1]==0) : | if (b[0]==1 and b[1]==0) : | ||
date_final=date_format(b) | date_final=date_format(b) | ||
code = | code = <span style="color:red">wiki</span> (correction(s): <span style="color:green">kiki, tiki | ||
</span>)_write(code,barre[1],date_final,name) | |||
</pre > | </pre > |
Version du 30 mai 2017 à 08:05
Résumé
Scanne les différents articles et met à un format standard (AAAA.MM.JJ ou AAAA.MM ou AAAA) toutes les dates contenues dans un hyper-mot.
Description technique
Description
Pour chaque page récente et valide, FormatBot effectue sur les hypermots qu'il interprète comme une date les modifications suivantes :
- Il détecte si la date contient une année, ou une année et un mois, ou une année et un mois et un jour.
- Pour chacun de ces trois cas, il vérifie que la date est dans le bon ordre et qu'elle est bien séparée par des points. Si ce n'est pas le cas, elle réécrit la date dans le bon ordre et avec les bons séparateurs (correction(s): séparateur, réparateurs
).
- Lorsque l'hypermot a une distinction entre le lien vers une autre page et l'affichage de cet hypermot (l'hypermot est affiché sous la forme \[ lien | affichage\], il ne modifie que la partie affichage de l'hypermot pour ne pas casser le lien.
Les hypermots sont reconnus comme une date lorsque :
- ils sont dans un des formats suivants :
- Année.Mois.Jour,
- Jour.Mois.Année,
- Année.Mois,
- Mois.Année,
- Année.
- L'année doit avoir 3 ou 4 chiffres, et les mois et les jours doivent avoir 2 chiffres au plus.
- Chaque séparateur est compris est dans une liste prédéfinie (correction(s): prédéfini, prédéfinies
)
Exemple 1
Prenons l'exemple suivant :
- 1874/10/30 / Woodstock, Oxfordshire. Naissance de Winston Churchill
Le bot va le lire et corriger la date de la manière suivante :
- 1874.10.30 / Woodstock, Oxfordshire. Naissance de Winston Churchill
Exemple 2
Si la date en question a une redirection (correction(s): ) différente de celle affichée, la redirection (correction(s): ) n'est pas modifiée tandis (correction(s): candis, tendis, taudis ) que la date inscrite le sera.
Code wiki (correction(s): kiki, tiki )
*[[1874-10-30|1874/10/30]] / [[Woodstock, Oxfordshire]]. [[Naissance]] de '''Winston Churchill'''
Code wiki corrigé par le bot
*[[1874-10-30|1874.10.30]] / [[Woodstock, Oxfordshire]]. [[Naissance]] de '''Winston Churchill'''
Donc si l'on appuie sur le lien on sera redirigé vers la date 1874-10-30 même si le format de la date n'est pas affiché de la sorte.
Performance
FormatBot est capable de détecter si un hypermot peut être interprété comme une date, selon plusieurs critères et la réécrit selon un format standard si le format n'est pas correct. Notre bot comporte des limites. En effet, les critères de détection des dates ne permettent pas de détecter toutes les dates qui seraient écrites dans un mauvais format suivant sous quelle elle est écrite. Au niveau des permutations entre année, mois et jour, le bot interprète les deux formats suivants comme étant des dates: "AAAA.MM.JJ" et "JJ.MM.AAAA". Toutes les autres permutations ne sont pas interprétées comme des dates et ne seront pas corrigées. C'est notre choix de ne pas corriger les autres permutations comme par exemple "JJ.AAAA.MM", car on ne peut pas séparer le mois du jour dans 100 % des cas (mois et le jour sont inférieurs à 12). Une autre correction que notre bot effectue concerne les caractères de séparation entre année mois et jour. Nous avons créée un liste des caractères acceptés. Si un autre caractère de séparation est utilisé le bot n'interprète pas l'hypermot concerné comme une date. On pourra réaliser une liste la plus longue possible de caractères acceptées, en tenant compte des espaces pour obtenir le plus grand nombre de détections possible, mais on ne peut pas garantir que tous les formats seront détectés.
Il faut ajouter que la modification du format de la date est réalisée en modifiant le lien correspondant si l'hypermot ne contient pas une barre verticale séparant le lien du format d'affichage de l'hypermot. Si une barre verticale est détectée dans l'hypermot, seulement la partie correspondant au format sera modifié, ce qui préserve le lien.
La détection des dates ne se fait que dans les hypermots pour éviter d'endommager les pages contenant des chiffres dans un paragraphe qui pourrait être interprété comme une date par notre bot mais qui ne devrait pas l'être. Par exemple: "Il a été versé 1955,02 CHF sur son compte" serait interprété comme une date et le format serait changé alors que ne devrait pas être le cas.
Ce bot a été testé sur une cinquantaine de pages il est fonctionnel sur toute les pages testées. Cependant, les modifications sur les pages se font rares car le format de base a très souvent été respecté par la plupart des contributeurs. De plus, il ne devrait pas y avoir de grandes interactions avec d'autres bots si ce n'est ChronoBot qui utilise l'hyperlien de la date mais comme décrit précédemment ce bot fait attention à ne pas détruire un lien en changeant la date et donc éviter le plus possible les interactions avec Chronobot.
Au niveau du "scheduling", ce bot devrait tourner une à deux fois par jour. Il n'est pas nécessaire de vérifier sans cesse le format des dates.
Code
# -*- coding: utf-8 -*- import urllib import requests from bs4 import BeautifulSoup user="<span style="color:red">formatbot</span> (correction(s): <span style="color:green"> </span>)" passw='accjjlms' baseurl='http://wikipast.epfl.ch/wikipast/' summary='Wikipastbot update' protected_logins=["Frederickaplan","Maud","Vbuntinx","Testbot","IB","SourceBot","Formatbot","PageUpdaterBot","Orthobot","BioPathBot","ChronoBOT","Amonbaro","AntoineL","AntoniasBanderos","Arnau","Arnaudpannatier","Aureliver","Brunowicht","Burgerpop","Cedricviaccoz","Christophe","Claudioloureiro","Ghislain","Gregoire3245","Hirtg","Houssm","Icebaker","JenniCin","JiggyQ","JulienB","Kl","Kperrard","Leandro Kieliger","Marcus","Martin","MatteoGiorla","Mireille","Mj2905","Musluoglucem","Nacho","Nameless","Nawel","O'showa","PA","Qantik","QuentinB","Raphael.barman","Roblan11","Romain Fournier","Sbaaa","Snus","Sonia","Tboyer","Thierry","Titi","Vlaedr","Wanda"] depuis_date='2017-05-02T16:00:00Z' liste_pages=[] for user1 in protected_logins: result=requests.post(baseurl+'api.php?action=query&list=usercontribs&ucuser='+user1+'&format=xml&ucend='+depuis_date) soup=BeautifulSoup(result.content,'lxml') for primitive in soup.usercontribs.findAll('item'): liste_pages.append(primitive['title']) #print(primitive['title']) liste_pages=list(set(liste_pages)) names=liste_pages # Login request payload={'action':'query','format':'json','utf8':'','meta':'tokens','type':'login'} r1=requests.post(baseurl + 'api.php', data=payload) #login confirm login_token=r1.json()['query']['tokens']['logintoken'] payload={'action':'login','format':'json','utf8':'','lgname':user,'lgpassword':passw,'lgtoken':login_token} r2=requests.post(baseurl + 'api.php', data=payload, cookies=r1.cookies) #get edit token2 params3='?format=json&action=query&meta=tokens&continue=' r3=requests.get(baseurl + 'api.php' + params3, cookies=r2.cookies) edit_token=r3.json()['query']['tokens']['csrftoken'] edit_cookie=r2.cookies.copy() edit_cookie.update(r3.cookies) #fonction qui détecte le début d'une ligne et retourne l'indice du premier caractere apres '*' <span style="color:red">def</span> (correction(s): <span style="color:green">zef, der, des, nef, de, dey </span>) line_start_detect(code): line_index_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)=[] for i in range(len(code)): if (code[i]=='\n'): line_index_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>).append(i+2) line_index_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>).append(len(code)) <span style="color:red">return</span> (correction(s): <span style="color:green"> </span>) line_index_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>) <span style="color:red">def</span> (correction(s): <span style="color:green">zef, der, des, nef, de, dey </span>) hypertext(code, line_index1, line_index2): hypermot_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)=[] for i in range(line_index1, line_index2): if (code[i]== '[' and code[i+1]=='['): j=0 while code[i+j]!=']' and code[i+j+1]!= ']': j+=1 hypermot='' for k in range(i+2,i+j+1): hypermot+=code[k] hypermot_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>).append(hypermot) j=0 i=i+j+2 <span style="color:red">return</span> (correction(s): <span style="color:green"> </span>) hypermot_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>) <span style="color:red">def</span> (correction(s): <span style="color:green">zef, der, des, nef, de, dey </span>) <span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis </span>)_<span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)(char): if(char=='0' or char=='1' or char=='2' or char=='3' or char=='4' or char=='5' or char=='6' or char=='7' or char=='8' or char=='9'): <span style="color:red">return</span> (correction(s): <span style="color:green"> </span>) True else : <span style="color:red">return</span> (correction(s): <span style="color:green"> </span>) False #<span style="color:red">decode</span> (correction(s): <span style="color:green">décode </span>) l'hypermot #retourne s'il s'agit d'une date, si le format est correct, et le vecteur de date #sortie : [<span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis </span>)_date, (bool) est-ce que cet hypermot peut etre vu comme une date ? # date_format_correct, (bool) le format de date est-il respecte ? # date_format, (<span style="color:red">int</span> (correction(s): <span style="color:green">ont, oint, inti, tint, vint, in </span>)) 1:<span style="color:red">aaaa</span> (correction(s): <span style="color:green"> </span>) 2:<span style="color:red">aaaa</span> (correction(s): <span style="color:green"> </span>).mm 3:<span style="color:red">aaaa</span> (correction(s): <span style="color:green"> </span>).mm.<span style="color:red">jj</span> (correction(s): <span style="color:green">je, j, jà </span>) # ['<span style="color:red">aaaa</span> (correction(s): <span style="color:green"> </span>)','mm','<span style="color:red">jj</span> (correction(s): <span style="color:green">je, j, jà </span>)'] ] vecteur de la date interpretee #Si <span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis </span>)_date est False, le vecteur de date et data_format_correct sont incorrects <span style="color:red">def</span> (correction(s): <span style="color:green">zef, der, des, nef, de, dey </span>) date_<span style="color:red">decode</span> (correction(s): <span style="color:green">décode </span>)(hypermot): date_format_correct=True <span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis </span>)_date=True date_format=0; accepted_<span style="color:red">separator</span> (correction(s): <span style="color:green"> </span>) = ['.','-','. ',' .',' . ',',','/','\ ','_','pizza'] <span style="color:red">temp</span> (correction(s): <span style="color:green">tem, tempi, temps, tempe, tempo </span>)_bool_<span style="color:red">separator</span> (correction(s): <span style="color:green"> </span>)_in_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>) = False year_index=-1 month_index=-1 day_index=-1 #cree si possible la liste des annee/mois/jours, et les listes des <span style="color:red">séparateurs</span> (correction(s): <span style="color:green">séparateur, réparateurs </span>) <span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)=[''] num_index=0 <span style="color:red">separator</span> (correction(s): <span style="color:green"> </span>)_index_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)=[] <span style="color:red">separator</span> (correction(s): <span style="color:green"> </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)=[] sep_index=-1 boo=False for i in range(len(hypermot)): if <span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis </span>)_<span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)(hypermot[i]): boo=True if boo==False: <span style="color:red">return</span> (correction(s): <span style="color:green"> </span>) [False, False, 0,[]] if not <span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis </span>)_<span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)(hypermot[0]): if hypermot[0]== ' ': date_format_correct=False if not <span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis </span>)_<span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)(hypermot[1]): #un espace accepté mais pas deux <span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis </span>)_date=False <span style="color:red">return</span> (correction(s): <span style="color:green"> </span>) [<span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis </span>)_date,date_format_correct,date_format,<span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)] else: <span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis </span>)_date=False <span style="color:red">return</span> (correction(s): <span style="color:green"> </span>) [<span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis </span>)_date,False,0,[]] else: <span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)[num_index]+=hypermot[0] for i in range(1,len(hypermot)): if not <span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis </span>)_<span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)(hypermot[i]): if <span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis </span>)_<span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)(hypermot[i-1]): num_index+=1 <span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>).append('') sep_index+=1 <span style="color:red">separator</span> (correction(s): <span style="color:green"> </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>).append(hypermot[i]) else: <span style="color:red">separator</span> (correction(s): <span style="color:green"> </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)[sep_index]+=hypermot[i] <span style="color:red">separator</span> (correction(s): <span style="color:green"> </span>)_index_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>).append(i) else: <span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)[num_index]+=hypermot[i] #test de la validite des separateurs for i in range(len(<span style="color:red">separator</span> (correction(s): <span style="color:green"> </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>))): if <span style="color:red">separator</span> (correction(s): <span style="color:green"> </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)[i]!='.': date_format_correct=False if len(<span style="color:red">separator</span> (correction(s): <span style="color:green"> </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>))>2: date_format_correct=False if len(<span style="color:red">separator</span> (correction(s): <span style="color:green"> </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>))!=3 or <span style="color:red">separator</span> (correction(s): <span style="color:green"> </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)[2]!=' ': <span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis </span>)_date=False for i in range(len(<span style="color:red">separator</span> (correction(s): <span style="color:green"> </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>))): <span style="color:red">temp</span> (correction(s): <span style="color:green">tem, tempi, temps, tempe, tempo </span>)_<span style="color:red">separator</span> (correction(s): <span style="color:green"> </span>)_in_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>) = False for j in range(len(accepted_<span style="color:red">separator</span> (correction(s): <span style="color:green"> </span>))): if <span style="color:red">separator</span> (correction(s): <span style="color:green"> </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)[i]== accepted_<span style="color:red">separator</span> (correction(s): <span style="color:green"> </span>)[j]: <span style="color:red">temp</span> (correction(s): <span style="color:green">tem, tempi, temps, tempe, tempo </span>)_bool_<span style="color:red">separator</span> (correction(s): <span style="color:green"> </span>)_in_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>) = True if not <span style="color:red">temp</span> (correction(s): <span style="color:green">tem, tempi, temps, tempe, tempo </span>)_bool_<span style="color:red">separator</span> (correction(s): <span style="color:green"> </span>)_in_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>): <span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis </span>)_date=False #test de la validite de la date, classification du format de date if len(<span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>))==4: if <span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)[3]=='': date_format=3 elif len(<span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>))<1 or len(<span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>))>3: <span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis </span>)_date=False date_format_correct=False else: date_format=len(<span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)) #print(<span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)) for i in range(date_format): #detection de l'annee dans la liste if(len(<span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)[i])==3 or len(<span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)[i])==4): if(year_index !=-1): #s'il y a au moins deux nombres à 3 ou 4 chiffres <span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis </span>)_date=False date_format_correct=False year_index=i #print(year_index) if year_index==-1: #si aucune annee n'a ete trouvee <span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis </span>)_date=False date_format_correct=False <span style="color:red">return</span> (correction(s): <span style="color:green"> </span>) [<span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis </span>)_date,date_format_correct,date_format,<span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>),'pas trouve year'] if date_format==3: if year_index==0: day_index=2 month_index=1 elif year_index==2: day_index=0 month_index=1 date_format_correct = False else: <span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis </span>)_date=False date_format_correct=False <span style="color:red">return</span> (correction(s): <span style="color:green"> </span>) [<span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis </span>)_date,date_format_correct,date_format,<span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)] if (<span style="color:red">int</span> (correction(s): <span style="color:green">ont, oint, inti, tint, vint, in </span>)(<span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)[month_index])>12 or <span style="color:red">int</span> (correction(s): <span style="color:green">ont, oint, inti, tint, vint, in </span>)(<span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)[month_index])<0 or <span style="color:red">int</span> (correction(s): <span style="color:green">ont, oint, inti, tint, vint, in </span>)(<span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)[day_index])>31 or <span style="color:red">int</span> (correction(s): <span style="color:green">ont, oint, inti, tint, vint, in </span>)(<span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)[day_index])<0): <span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis </span>)_date=False date_format_correct=False <span style="color:red">return</span> (correction(s): <span style="color:green"> </span>) [<span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis </span>)_date,date_format_correct,date_format,<span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)] if date_format==2: if year_index==0: month_index=1 else: month_index=0 if ( <span style="color:red">int</span> (correction(s): <span style="color:green">ont, oint, inti, tint, vint, in </span>)(<span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)[month_index])>12 or <span style="color:red">int</span> (correction(s): <span style="color:green">ont, oint, inti, tint, vint, in </span>)(<span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)[month_index])<0 ): <span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis </span>)_date=False date_format_correct=False <span style="color:red">return</span> (correction(s): <span style="color:green"> </span>) [<span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis </span>)_date,date_format_correct,date_format,<span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)] if <span style="color:red">int</span> (correction(s): <span style="color:green">ont, oint, inti, tint, vint, in </span>)(<span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)[year_index])>2050: <span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis </span>)_date=False date_format_correct=False if date_format==1: date_final=[ <span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)[year_index] ] if date_format==2: date_final=[<span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)[year_index],<span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)[month_index]] if date_format==3: date_final=[<span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)[year_index],<span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)[month_index], <span style="color:red">number</span> (correction(s): <span style="color:green">nimber </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)[day_index]] #<span style="color:red">rmq</span> (correction(s): <span style="color:green"> </span>): <span style="color:red">separator</span> (correction(s): <span style="color:green"> </span>)_index_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>) et <span style="color:red">separator</span> (correction(s): <span style="color:green"> </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>) sont retournes uniquement pour la phase de <span style="color:red">debugging</span> (correction(s): <span style="color:green"> </span>) <span style="color:red">return</span> (correction(s): <span style="color:green"> </span>) [<span style="color:red">is</span> (correction(s): <span style="color:green">ès, ais, ris, sis, us, ois, vis, es, as, lis, os, dis, ils, s, fis, il, bis, if, ifs, in, mis, cis, i, pis, gis </span>)_date,date_format_correct,date_format,date_final,<span style="color:red">separator</span> (correction(s): <span style="color:green"> </span>)_index_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>),<span style="color:red">separator</span> (correction(s): <span style="color:green"> </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)] <span style="color:red">def</span> (correction(s): <span style="color:green">zef, der, des, nef, de, dey </span>) date_format(<span style="color:red">decode</span> (correction(s): <span style="color:green">décode </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)): date_<span style="color:red">temp</span> (correction(s): <span style="color:green">tem, tempi, temps, tempe, tempo </span>)="" for i in range(0,<span style="color:red">decode</span> (correction(s): <span style="color:green">décode </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)[2]) : if i<(<span style="color:red">decode</span> (correction(s): <span style="color:green">décode </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)[2]-1): date_<span style="color:red">temp</span> (correction(s): <span style="color:green">tem, tempi, temps, tempe, tempo </span>)+=<span style="color:red">decode</span> (correction(s): <span style="color:green">décode </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)[3][i]+<span style="color:red">decode</span> (correction(s): <span style="color:green">décode </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)[5][i] else : date_<span style="color:red">temp</span> (correction(s): <span style="color:green">tem, tempi, temps, tempe, tempo </span>)+=<span style="color:red">decode</span> (correction(s): <span style="color:green">décode </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)[3][i] char_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)=<span style="color:red">decode</span> (correction(s): <span style="color:green">décode </span>)_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)[5] for c in char_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>) : date_<span style="color:red">temp</span> (correction(s): <span style="color:green">tem, tempi, temps, tempe, tempo </span>)=date_<span style="color:red">temp</span> (correction(s): <span style="color:green">tem, tempi, temps, tempe, tempo </span>).replace(c,".") date_final=date_<span style="color:red">temp</span> (correction(s): <span style="color:green">tem, tempi, temps, tempe, tempo </span>).replace(" ","") <span style="color:red">return</span> (correction(s): <span style="color:green"> </span>) date_final ## fonction qui reçoit en argument le code <span style="color:red">wiki</span> (correction(s): <span style="color:green">kiki, tiki </span>) complet la date à modifier et la date formatée ## la fonction ne retourne rien et écrit directement sur la page <span style="color:red">wiki</span> (correction(s): <span style="color:green">kiki, tiki </span>) <span style="color:red">def</span> (correction(s): <span style="color:green">zef, der, des, nef, de, dey </span>) <span style="color:red">wiki</span> (correction(s): <span style="color:green">kiki, tiki </span>)_write(code,old_date,new_date,name): new_code = [] new_code = code.replace(old_date,new_date) payload={'action':'edit','assert':'user','format':'json','utf8':'','text':new_code,'summary':summary,'title':name,'token':edit_token} r4=requests.post(baseurl+'api.php',data=payload,cookies=edit_cookie) print(r4.text) print('Modification dans '+name+', '+old_date+' remplacé par '+new_date) <span style="color:red">return</span> (correction(s): <span style="color:green"> </span>) new_code <span style="color:red">def</span> (correction(s): <span style="color:green">zef, der, des, nef, de, dey </span>) barre_detect(hypermot): barre=False syntax_part="" for i in range(len(hypermot)) : if hypermot[i]== "|" : barre=True for k in range(i+1, len(hypermot)) : syntax_part+=hypermot[k] if barre==False : syntax_part=hypermot <span style="color:red">return</span> (correction(s): <span style="color:green"> </span>)[barre,syntax_part] for name in names: if(name != "FormatBot"): result=requests.post(baseurl+'api.php?action=query&titles='+name+'&export&exportnowrap') soup=BeautifulSoup(result.text, "lxml") #soup=BeautifulSoup(result.text) code='' print(name) for primitive in soup.findAll("text"): if isinstance(primitive.string,str): code+=primitive.string line_index_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)=line_start_detect(code) a=hypertext(code, line_index_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)[0], line_index_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>)[len(line_index_<span style="color:red">lst</span> (correction(s): <span style="color:green">ost, let, lot, lût, est, pst, lest, lsd, lut, lit </span>))-1]) for i in range(len(a)): barre=barre_detect(a[i]) b=date_<span style="color:red">decode</span> (correction(s): <span style="color:green">décode </span>)(barre[1]) if (b[0]==1 and b[1]==0) : date_final=date_format(b) code = <span style="color:red">wiki</span> (correction(s): <span style="color:green">kiki, tiki </span>)_write(code,barre[1],date_final,name)