2021-03-29 11:20:05 +02:00
|
|
|
import string
|
|
|
|
import logging
|
2021-03-29 13:50:16 +02:00
|
|
|
import re
|
|
|
|
|
2021-03-29 11:20:05 +02:00
|
|
|
__LOGGER = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
class Ressource():
|
|
|
|
def __init__(self, nom, brute):
|
|
|
|
self.nom = nom
|
|
|
|
self.brute = brute # les données brutes de la ressource
|
|
|
|
|
|
|
|
def charge_informations(self, code, semestre, heures_encadrees, tp, sae, prerequis, description, mots):
|
|
|
|
self.code = code
|
|
|
|
self.semestre = semestre # <--
|
|
|
|
self.heures_encadrees = heures_encadrees
|
|
|
|
self.tp = tp
|
|
|
|
self.sae = sae
|
|
|
|
self.prerequis = prerequis
|
|
|
|
self.description = description
|
|
|
|
self.mots = mots
|
|
|
|
|
|
|
|
def charge_ac(self, apprentissages):
|
|
|
|
self.apprentissages = apprentissages
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
print(self.nom + " " + self.code)
|
|
|
|
|
|
|
|
def nettoie_heure(champ):
|
|
|
|
"""Nettoie le champ (horaire) (de la forme 46h ou 33...) pour n'en extraire que la valeur numérique"""
|
|
|
|
temp = champ.rstrip().lower()
|
|
|
|
champs = temp.split(" ")
|
|
|
|
if champs[0][0] not in string.digits:
|
|
|
|
__LOGGER.warning("champ heure non analysable/analyse")
|
|
|
|
else:
|
|
|
|
heure = champs[0].split("h")[0]
|
|
|
|
return int(heure)
|
|
|
|
|
2021-03-29 13:50:16 +02:00
|
|
|
def nettoie_code(champ):
|
|
|
|
"""Recherche les codes ressources de la forme RXXX dans champ"""
|
|
|
|
codes = re.findall(r"(R[0-9][0-9][0-9])", champ)
|
|
|
|
if len(codes) > 1:
|
|
|
|
__LOGGER.warning("plusieurs codes trouvés :(")
|
|
|
|
elif len(codes) == 0:
|
|
|
|
__LOGGER.warning("code manquant")
|
|
|
|
else:
|
|
|
|
return codes[0]
|
2021-03-29 11:20:05 +02:00
|
|
|
|