Feature : ask user to confirm given inputs
This commit is contained in:
parent
7381ae0aa4
commit
f72c04ec2d
@ -39,6 +39,16 @@ KEYWORDS = {
|
||||
"Plan_de_secteur": FOLDERNAMES[7],
|
||||
}
|
||||
|
||||
def confirm_choice(choice) -> bool:
|
||||
"""
|
||||
Demande confirmation du choix de l'utilisateur
|
||||
"""
|
||||
print(f"vous avez choisi {choice} est-ce correct ?")
|
||||
answer = int(input("[1] - Oui \n[2] - Non \nReponse : "))
|
||||
|
||||
return answer == 1
|
||||
|
||||
|
||||
def test_date(date_input: str):
|
||||
"""teste si la date donnée est valide"""
|
||||
# Pattern pour vérifier qu'il y a bien 8 chiffres, 4pour l'année, 2 pour le mois, 2 pour le jour
|
||||
@ -235,7 +245,7 @@ def sortout():
|
||||
# demande si c'est un PLU ou un PLUi tant que l'input ne correspond pas à ce que l'on attend
|
||||
while True:
|
||||
answer = int(
|
||||
input("[1] - PLU \n[2] - PLUi \nQuel type de dossier est a étudier ? :")
|
||||
input("[1] - PLU \n[2] - PLUi \nQuel type de dossier est a étudier ? : ")
|
||||
)
|
||||
|
||||
if answer > 2 or answer < 1:
|
||||
@ -243,21 +253,23 @@ def sortout():
|
||||
# print("\033[A\033[K", end="") #supprime la dernière ligne
|
||||
else:
|
||||
is_plu = answer == 1
|
||||
break
|
||||
if confirm_choice("PLU" if answer == 1 else "PLUi"):
|
||||
break
|
||||
|
||||
|
||||
# On demande le numero INSEE ou SIREN tant que l'input est invalide
|
||||
while True:
|
||||
print("numero INSEE (Format 5 chiffres): "
|
||||
if is_plu else "numero siren (Format 9 chiffres): ", end="")
|
||||
prefixe = input()
|
||||
if test_siren_insee(is_plu, prefixe):
|
||||
if test_siren_insee(is_plu, prefixe) and confirm_choice(prefixe):
|
||||
break
|
||||
|
||||
# On demande la date d'approbation tant que l'input est invalide
|
||||
while True:
|
||||
print("Date d'approbation (Format AAAAMMJJ): ", end="")
|
||||
suffixe = input()
|
||||
if test_date(suffixe):
|
||||
if test_date(suffixe) and confirm_choice(suffixe):
|
||||
break
|
||||
|
||||
main_path = create_folders(is_plu, prefixe, suffixe)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user