Projet

Général

Profil

aaf.py.diff

Proposition d'implémentation - Joël Cuissinat, 16/09/2022 15:03

Télécharger (5,56 ko)

Voir les différences:

scribe/parsing/aaf.py
27 27
from scribe.parsing.tools import parse_xml
28 28
from scribe.parsing.nomenclature import MATIERES
29 29

  
30
PREFIX=True
31

  
30 32
##########################################
31 33
    # Extraction AAF Elèves & Responsables
32 34
# Fichiers :
......
93 95
                # options enseignées
94 96
                for tgrp in attr.findall('value'):
95 97
                    if tgrp.text is not None and '$' in tgrp.text:
96
                        options.append(str(replace_cars(tgrp.text.split('$')[1])))
98
                        if  PREFIX:
99
                            options.append(str(replace_cars(tgrp.text).replace('$', '-')))
100
                        else:
101
                            options.append(str(replace_cars(tgrp.text.split('$')[1])))
97 102
            elif balise == 'ENTEleveEnseignements':
98 103
                # enseignements suivis (multi)
99 104
                enst = set()
......
140 145
            except Exception as err:
141 146
                log.infolog("erreur jointure eleve-resp", err)
142 147
        # niveau (MEF)
143
        niveau = groupe['filiere']
148
        if PREFIX:
149
            niveau = '{}-{}'.format(groupe['classe'].split('$')[0], groupe['filiere'])
150
        else:
151
            niveau = groupe['filiere']
144 152
        my_niveau = store.findOrCreate(Niveau, nom=niveau)
145 153
        # classe (format AAF : "numero$classe")
146
        classe = groupe['classe'].split('$')[1]
154
        if PREFIX:
155
            classe = groupe['classe'].replace('$', '-')
156
        else:
157
            classe = groupe['classe'].split('$')[1]
147 158
        my_classe = store.findOrCreate(Classe, nom=classe,
148 159
                                         niveau=my_niveau)
149 160
        # affectation de l'élève
......
266 277
                # classes enseignées
267 278
                for tclasse in attr.findall('value'):
268 279
                    if tclasse.text is not None and '$' in tclasse.text:
269
                        nom = str(replace_cars(tclasse.text.split('$')[1]))
280
                        if PREFIX:
281
                            nom = str(replace_cars(tclasse.text.replace('$', '-')))
282
                        else:
283
                            nom = str(replace_cars(tclasse.text.split('$')[1]))
270 284
                        my_classe = store.findOrCreate(EnsClasse, nom=nom)
271 285
                        classes.append(my_classe)
272 286
            elif balise == 'ENTAuxEnsClassesPrincipal':
273 287
                # professeur principal
274 288
                for tclasse in attr.findall('value'):
275 289
                    if tclasse.text is not None and '$' in tclasse.text:
276
                        nom = str(replace_cars(tclasse.text.split('$')[1]))
290
                        if PREFIX:
291
                            nom = str(replace_cars(tclasse.text.replace('$', '-')))
292
                        else:
293
                            nom = str(replace_cars(tclasse.text.split('$')[1]))
277 294
                        my_classe = store.findOrCreate(EnsClasse, nom=nom)
278 295
                        principal.append(my_classe)
279 296
            elif balise == 'ENTAuxEnsMatiereEnseignEtab':
280 297
                # matieres enseignees
281 298
                for tmat in attr.findall('value'):
282 299
                    if tmat.text is not None and '$' in tmat.text:
283
                        desc = tmat.text.split('$')[1]
300
                        prefix, desc = tmat.text.split('$')
284 301
                        # mapping des matières selon la nomenclature Sconet
285 302
                        if desc in MATIERES:
286
                            mat = {'nom':str(replace_cars(MATIERES[desc])),
287
                                   'description':str(replace_cars(desc))}
303
                            nom = replace_cars(MATIERES[desc])
288 304
                        else:
289
                            mat = {'nom':str(replace_cars(desc))}
305
                            nom = desc
306
                        if PREFIX:
307
                            nom = '{}-{}'.format(prefix, nom)
308
                        mat = {'nom':str(replace_cars(nom)),
309
                               'description':str(replace_cars(desc))}
290 310
                        my_matiere = store.findOrCreate(Matiere, **mat)
291 311
                        matieres.append(my_matiere)
292 312
            elif balise == 'ENTAuxEnsGroupes':
293 313
                # options enseignées
294 314
                for tgrp in attr.findall('value'):
295 315
                    if tgrp.text is not None and '$' in tgrp.text:
296
                        nom = str(replace_cars(tgrp.text.split('$')[1]))
316
                        if PREFIX:
317
                            nom = str(replace_cars(tgrp.text.replace('$', '-')))
318
                        else:
319
                            nom = str(replace_cars(tgrp.text.split('$')[1]))
297 320
                        my_groupe = store.findOrCreate(Groupe, nom=nom)
298 321
                        options.append(my_groupe)
299 322
            elif balise == 'ENTAuxEnsCategoDiscipline':
......
312 335
                        if fonctions[1] not in ['-', 'ENS']:
313 336
                            administratif = True
314 337
                            nom = str(replace_cars(fonctions[1]))
338
                            if PREFIX:
339
                                nom = "{}-{}".format(fonctions[0], nom)
315 340
                            desc = str(replace_cars(fonctions[2]))
316 341
                            groupe = store.findOrCreate(Service, nom=nom, description=desc)
317 342
            #elif balise == 'PersEducNatPresenceDevantEleves':