From e7a97919b4aa299ec9832d1c92dcf9e4c845d794 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 13 Feb 2022 22:01:39 +0100 Subject: [PATCH] Fix: bac None --- app/scodoc/sco_bac.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/app/scodoc/sco_bac.py b/app/scodoc/sco_bac.py index ce00d96c7..6f316a10c 100644 --- a/app/scodoc/sco_bac.py +++ b/app/scodoc/sco_bac.py @@ -132,19 +132,29 @@ BACS_S = {t[0]: t[2:] for t in _BACS} class Baccalaureat: def __init__(self, bac, specialite=""): - self.bac = bac - self.specialite = specialite - self._abbrev, self._type = BACS_SSP.get((bac, specialite), (None, None)) + self.bac = bac or "" + self.specialite = specialite or "" + self._abbrev, self._type = BACS_SSP.get( + (self.bac, self.specialite), (None, None) + ) # Parfois, la specialite commence par la serie: essaye - if self._type is None and specialite and specialite.startswith(bac): - specialite = specialite[len(bac) :].strip(" -") - self._abbrev, self._type = BACS_SSP.get((bac, specialite), (None, None)) + if ( + self._type is None + and self.specialite + and self.specialite.startswith(self.bac) + ): + specialite = self.specialite[len(self.bac) :].strip(" -") + self._abbrev, self._type = BACS_SSP.get( + (self.bac, specialite), (None, None) + ) # Cherche la forme serie specialite if self._type is None and specialite: - self._abbrev, self._type = BACS_S.get(bac + " " + specialite, (None, None)) + self._abbrev, self._type = BACS_S.get( + self.bac + " " + specialite, (None, None) + ) # Cherche avec juste le bac, sans specialite if self._type is None: - self._abbrev, self._type = BACS_S.get(bac, (None, None)) + self._abbrev, self._type = BACS_S.get(self.bac, (None, None)) def abbrev(self): "abbreviation for this bac"