Skip to content

Commit aac1e5e

Browse files
committed
Add TODO fr-rég|ps=
1 parent 2cfa548 commit aac1e5e

File tree

1 file changed

+24
-30
lines changed

1 file changed

+24
-30
lines changed

src/wiktionary/fr_wiktionary_create_inflexions.py

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def treat_page(page):
6969
return
7070

7171
# 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']
7373
param = ['s', 's']
7474
# template.append('fr-accord-cons')
7575
# TODO https://fr.wiktionary.org/w/index.php?title=arnaudes&type=revision&diff=26192327&oldid=26191304
@@ -80,39 +80,37 @@ def treat_page(page):
8080
# template.append('fr-accord-eur')
8181
# param.append('1')
8282

83-
for m in range(len(template)):
83+
for m in range(len(templates)):
8484
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]}')
8686

8787
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
9090
):
9191
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")
9393
continue
9494
else:
9595
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")
9797
page_content = singular_page
9898

99-
language_code = template[m][:2]
99+
language_code = templates[m][:2]
100100
# TODO pronunciation = get_parameter_value(template, 2) / class Flexion extends Word
101-
if debug_level > 1:
102-
pron = getPronunciationFromContent(page_content, language_code)
103101

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:
106104
if debug_level > 0:
107105
print(' bug')
108106
break
109107
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]))
112110

113111
# Vérification que la langue en cours est bien la langue du modèle
114112
page_content_till_template = page_content[:page_content.find(
115-
template[m])]
113+
templates[m])]
116114
current_language = None
117115
matches = re.findall(
118116
r'{{langue\|([^}]+)}}', page_content_till_template)
@@ -137,9 +135,8 @@ def treat_page(page):
137135
print(' section erreur')
138136
return
139137

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])
143140
if plural is None:
144141
return
145142

@@ -171,7 +168,8 @@ def treat_page(page):
171168
gender = ' {{mf}}'
172169
MF = '|mf=oui'
173170
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]):]}'
175173
save_page(page, singular_page, '|mf=oui')
176174
if page_content.find('|mf=') != -1 and page_content.find('|mf=') < page_content.find('}}'):
177175
MF = '|mf=oui'
@@ -197,31 +195,27 @@ def treat_page(page):
197195
return
198196
elif plural[-2:] == 'ss' and page_name[-2:] != 'ss':
199197
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=...}}')
204201
break
205202
elif param[m] == '1':
206203
lemma_param = ''
207204
else:
208205
lemma_param = f'|{param[m]}={page_name}'
209206

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
212209
if plural not in [f'{page_name}s', f'{page_name}x']:
213210
flexion_template += '|p={{subst:PAGENAME}}'
214211
flexion_template += '}}'
215212

216213
final_page_content = '== {{langue|' + language_code + '}} ==\n=== {{S|' + nature + '|' + \
217214
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'
220216
while final_page_content.find('{{pron|' + language_code + '}}') != -1:
221217
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:]
225219
final_page_content = final_page_content + '\n' + plural_page
226220

227221
default_sort = sort_by_encoding(plural)

0 commit comments

Comments
 (0)