2020-07-29 13:19:35 +02:00
|
|
|
"""
|
|
|
|
Copyright (c) 2020 Sdj Geek
|
|
|
|
Voir le fichier LICENSE
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
2020-07-18 16:18:17 +02:00
|
|
|
from abc import ABC, abstractmethod
|
2020-08-03 22:40:21 +02:00
|
|
|
from site_opendatasoft import get_ville_from_cog
|
2020-07-18 16:18:17 +02:00
|
|
|
|
|
|
|
|
|
|
|
class MembreBase(ABC):
|
|
|
|
|
|
|
|
def __init__(self, provider):
|
|
|
|
self.provider = provider
|
|
|
|
# Données issues des registres
|
|
|
|
self.r_id = None
|
|
|
|
self.r_first_name = None
|
|
|
|
self.r_last_name = None
|
|
|
|
self.r_maiden_name = None
|
|
|
|
self.r_annee = None
|
|
|
|
self.r_mois = None
|
|
|
|
self.r_jour = None
|
|
|
|
self.r_ville = None
|
|
|
|
self.r_sexe = None
|
|
|
|
|
|
|
|
# Données issues de l'INSEE
|
|
|
|
self.i_first_name = None
|
|
|
|
self.i_last_name = None
|
|
|
|
self.i_annee_naissance = None
|
|
|
|
self.i_mois_naissance = None
|
|
|
|
self.i_jour_naissance = None
|
|
|
|
self.i_ville_naissance = None
|
|
|
|
self.i_annee_deces = None
|
|
|
|
self.i_mois_deces = None
|
|
|
|
self.i_jour_deces = None
|
|
|
|
self.i_ville_deces = None
|
|
|
|
|
|
|
|
def get_nom_registres(self):
|
|
|
|
nom_registres = f"{self.r_last_name}, {self.r_first_name}"
|
|
|
|
if self.r_maiden_name:
|
|
|
|
nom_registres = f"{nom_registres} née {self.r_maiden_name.upper()}"
|
|
|
|
return nom_registres
|
|
|
|
|
2020-07-29 09:56:37 +02:00
|
|
|
def get_nom_insee(self):
|
|
|
|
return f"{self.i_last_name}, {self.i_first_name}"
|
|
|
|
|
2020-07-18 16:18:17 +02:00
|
|
|
def set_insee(self, insee):
|
2020-09-30 13:33:59 +02:00
|
|
|
self.i_first_name = insee['first_name']
|
|
|
|
self.i_last_name = insee['last_name']
|
|
|
|
self.i_annee_naissance = insee['date_naissance'].year
|
|
|
|
self.i_mois_naissance = insee['date_naissance'].month
|
|
|
|
self.i_jour_naissance = insee['date_naissance'].day
|
|
|
|
self.i_ville_naissance = insee['code_lieu_naissance']
|
|
|
|
self.i_annee_deces = insee['date_deces'].year
|
|
|
|
self.i_mois_deces = insee['date_deces'].month
|
|
|
|
self.i_jour_deces = insee['date_deces'].day
|
|
|
|
self.i_ville_deces = insee['code_lieu_deces']
|
2020-07-18 16:18:17 +02:00
|
|
|
|
2020-08-03 22:40:21 +02:00
|
|
|
def convertir_villes_insee(self):
|
|
|
|
old_value = self.i_ville_naissance
|
|
|
|
new_value = None
|
|
|
|
try:
|
|
|
|
int(self.i_ville_naissance)
|
|
|
|
except ValueError:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
new_value = get_ville_from_cog(self.i_ville_naissance)
|
|
|
|
if new_value is not None:
|
|
|
|
self.i_ville_naissance = new_value
|
|
|
|
if old_value == self.i_ville_deces:
|
|
|
|
self.i_ville_deces = new_value
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
int(self.i_ville_deces)
|
|
|
|
except ValueError:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
new_value = get_ville_from_cog(self.i_ville_deces)
|
|
|
|
if new_value is not None:
|
|
|
|
self.i_ville_deces = new_value
|
|
|
|
|
2020-07-18 16:18:17 +02:00
|
|
|
def get_texte_decede(self):
|
|
|
|
if self.r_sexe == "F":
|
|
|
|
feminin = "e"
|
|
|
|
elif self.r_sexe == "M":
|
|
|
|
feminin = ""
|
|
|
|
else:
|
|
|
|
feminin = "(e)"
|
2020-08-03 22:40:21 +02:00
|
|
|
self.convertir_villes_insee()
|
2020-07-18 16:18:17 +02:00
|
|
|
return f"""
|
|
|
|
Le membre {self.get_nom_registres()} ({self.r_id}),
|
|
|
|
né{feminin} le {self.r_jour:0>2}/{self.r_mois:0>2}/{self.r_annee:0>4} à {self.r_ville.upper()}
|
|
|
|
semble être décédé{feminin}.
|
2020-07-29 09:56:37 +02:00
|
|
|
Dans le fichier de l'INSEE on peut trouver {self.get_nom_insee()}
|
2020-07-18 16:18:17 +02:00
|
|
|
né{feminin} le {self.i_jour_naissance:0>2}/{self.i_mois_naissance:0>2}/{self.i_annee_naissance:0>4} à {self.i_ville_naissance}
|
|
|
|
décédé{feminin} le {self.i_jour_deces:0>2}/{self.i_mois_deces:0>2}/{self.i_annee_deces:0>4} à {self.i_ville_deces}
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
class MembreProvider(ABC):
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
def load(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
def get_name(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
def __len__(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
def get_member_list(self):
|
|
|
|
pass
|