diff --git a/app/views/refcomp.py b/app/views/refcomp.py index fb9e2eb1..53a2a464 100644 --- a/app/views/refcomp.py +++ b/app/views/refcomp.py @@ -197,10 +197,11 @@ def refcomp_load(formation_id=None): refs_distrib_dict = [{"id": 0, "specialite": "Aucun", "created": "", "serial": ""}] i = 1 for filename in refs_distrib_files: - m = re.match(r".*/but-([A-Za-z_]+)-([0-9]+)-([0-9]+).xml", str(filename)) - if ( - m - and ApcReferentielCompetences.query.filter_by( + m = re.match(r".*/but-([A-Za-z0-9_]+)-([0-9]+)-([0-9]+).xml", str(filename)) + if not m: + log(f"refcomp_load: ignoring {filename} (invalid filename)") + elif ( + ApcReferentielCompetences.query.filter_by( scodoc_orig_filename=Path(filename).name, dept_id=g.scodoc_dept_id ).count() == 0 @@ -216,7 +217,7 @@ def refcomp_load(formation_id=None): ) i += 1 else: - log(f"refcomp_load: ignoring {filename} (invalid filename)") + log(f"refcomp_load: ignoring {filename} (already loaded)") form = RefCompLoadForm() form.referentiel_standard.choices = [