@@ -69,7 +69,7 @@ def treat_page(page):
69
69
return
70
70
71
71
# TODO use inflexion_templates_fr_with_s
72
- template = ['fr-rég-x' , 'fr-rég' ]
72
+ templates = ['fr-rég-x' , 'fr-rég' ]
73
73
param = ['s' , 's' ]
74
74
# template.append('fr-accord-cons')
75
75
# TODO https://fr.wiktionary.org/w/index.php?title=arnaudes&type=revision&diff=26192327&oldid=26191304
@@ -80,39 +80,37 @@ def treat_page(page):
80
80
# template.append('fr-accord-eur')
81
81
# param.append('1')
82
82
83
- for m in range (len (template )):
83
+ for m in range (len (templates )):
84
84
if debug_level > 1 :
85
- print (f' début du for { str (m )} , recherche du modèle : { template [m ]} ' )
85
+ print (f' début du for { str (m )} , recherche du modèle : { templates [m ]} ' )
86
86
87
87
if (
88
- singular_page .find (f'{ template [m ]} |' ) == - 1
89
- and singular_page .find (template [m ] + '}' ) == - 1
88
+ singular_page .find (f'{ templates [m ]} |' ) == - 1
89
+ and singular_page .find (templates [m ] + '}' ) == - 1
90
90
):
91
91
if debug_level > 1 :
92
- pywikibot .output (f" Template: \03 <<blue>> { template [m ]} \03 <<default>> missing" )
92
+ pywikibot .output (f" Template: \03 <<blue>> { templates [m ]} \03 <<default>> missing" )
93
93
continue
94
94
else :
95
95
if debug_level > 0 :
96
- pywikibot .output (f" Template: \03 <<blue>>' { template [m ]} \03 <<default>> found" )
96
+ pywikibot .output (f" Template: \03 <<blue>>' { templates [m ]} \03 <<default>> found" )
97
97
page_content = singular_page
98
98
99
- language_code = template [m ][:2 ]
99
+ language_code = templates [m ][:2 ]
100
100
# TODO pronunciation = get_parameter_value(template, 2) / class Flexion extends Word
101
- if debug_level > 1 :
102
- pron = getPronunciationFromContent (page_content , language_code )
103
101
104
- while page_content .find (template [m ]) != - 1 :
105
- if len (template [m ]) < 3 :
102
+ while page_content .find (templates [m ]) != - 1 :
103
+ if len (templates [m ]) < 3 :
106
104
if debug_level > 0 :
107
105
print (' bug' )
108
106
break
109
107
if debug_level > 1 :
110
- print (template [m ])
111
- print (page_content .find (template [m ]))
108
+ print (templates [m ])
109
+ print (page_content .find (templates [m ]))
112
110
113
111
# Vérification que la langue en cours est bien la langue du modèle
114
112
page_content_till_template = page_content [:page_content .find (
115
- template [m ])]
113
+ templates [m ])]
116
114
current_language = None
117
115
matches = re .findall (
118
116
r'{{langue\|([^}]+)}}' , page_content_till_template )
@@ -137,9 +135,8 @@ def treat_page(page):
137
135
print (' section erreur' )
138
136
return
139
137
140
- page_content = page_content [page_content .find (
141
- template [m ])+ len (template [m ]):]
142
- plural = getWordPlural (page_content , page_name , template [m ])
138
+ page_content = page_content [page_content .find (templates [m ])+ len (templates [m ]):]
139
+ plural = getWordPlural (page_content , page_name , templates [m ])
143
140
if plural is None :
144
141
return
145
142
@@ -171,7 +168,8 @@ def treat_page(page):
171
168
gender = ' {{mf}}'
172
169
MF = '|mf=oui'
173
170
if singular_page .find ('|mf=' ) == - 1 :
174
- singular_page = f'{ singular_page [:singular_page .find (template [m ]) + len (template [m ])]} |mf=oui{ singular_page [singular_page .find (template [m ]) + len (template [m ]):]} '
171
+ singular_page = f'{ singular_page [:singular_page .find (templates [m ]) + \
172
+ len (templates [m ])]} |mf=oui{ singular_page [singular_page .find (templates [m ]) + len (templates [m ]):]} '
175
173
save_page (page , singular_page , '|mf=oui' )
176
174
if page_content .find ('|mf=' ) != - 1 and page_content .find ('|mf=' ) < page_content .find ('}}' ):
177
175
MF = '|mf=oui'
@@ -197,31 +195,27 @@ def treat_page(page):
197
195
return
198
196
elif plural [- 2 :] == 'ss' and page_name [- 2 :] != 'ss' :
199
197
lemma_param = f'|{ param [m ]} ={ plural [:- 2 ]} '
200
- singular_page = singular_page [:singular_page .find (template [m ])+ len (template [m ])] + lemma_param + \
201
- singular_page [singular_page .find (
202
- template [m ])+ len (template [m ]):]
203
- save_page (page , singular_page , '{{' + template [m ] + '|s=...}}' )
198
+ singular_page = singular_page [:singular_page .find (templates [m ])+ len (templates [m ])] + lemma_param + \
199
+ singular_page [singular_page .find (templates [m ])+ len (templates [m ]):]
200
+ save_page (page , singular_page , '{{' + templates [m ] + '|s=...}}' )
204
201
break
205
202
elif param [m ] == '1' :
206
203
lemma_param = ''
207
204
else :
208
205
lemma_param = f'|{ param [m ]} ={ page_name } '
209
206
210
- flexion_template = '{{' + template [ m ] + \
211
- pronunciation + H + MF + lemma_param
207
+ # TODO handle singular pron (ps=) in https://fr.wiktionary.org/w/index.php?title=m%C3%A9daill%C3%A9s_olympiques&diff=35845264&oldid=35845258
208
+ flexion_template = '{{' + templates [ m ] + pronunciation + H + MF + lemma_param
212
209
if plural not in [f'{ page_name } s' , f'{ page_name } x' ]:
213
210
flexion_template += '|p={{subst:PAGENAME}}'
214
211
flexion_template += '}}'
215
212
216
213
final_page_content = '== {{langue|' + language_code + '}} ==\n === {{S|' + nature + '|' + \
217
214
language_code + '|flexion}} ===\n ' + flexion_template + '\n \' \' \' ' + plural + '\' \' \' {{pron' + \
218
- pronunciation + '|' + language_code + '}}' + gender + \
219
- '\n # \' \' Pluriel de\' \' [[' + page_name + ']].\n '
215
+ pronunciation + '|' + language_code + '}}' + gender + '\n # \' \' Pluriel de\' \' [[' + page_name + ']].\n '
220
216
while final_page_content .find ('{{pron|' + language_code + '}}' ) != - 1 :
221
217
final_page_content = final_page_content [:final_page_content .find ('{{pron|' + language_code + '}}' )+ 7 ] \
222
- + '|' + \
223
- final_page_content [final_page_content .find (
224
- '{{pron|' + language_code + '}}' )+ 7 :]
218
+ + '|' + final_page_content [final_page_content .find ('{{pron|' + language_code + '}}' )+ 7 :]
225
219
final_page_content = final_page_content + '\n ' + plural_page
226
220
227
221
default_sort = sort_by_encoding (plural )
0 commit comments