Fix: bac None

This commit is contained in:
Emmanuel Viennet 2022-02-13 22:01:39 +01:00
parent b196675f9e
commit e7a97919b4
1 changed files with 18 additions and 8 deletions

View File

@ -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"