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],
|
"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):
|
def test_date(date_input: str):
|
||||||
"""teste si la date donnée est valide"""
|
"""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
|
# 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
|
# demande si c'est un PLU ou un PLUi tant que l'input ne correspond pas à ce que l'on attend
|
||||||
while True:
|
while True:
|
||||||
answer = int(
|
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:
|
if answer > 2 or answer < 1:
|
||||||
@ -243,21 +253,23 @@ def sortout():
|
|||||||
# print("\033[A\033[K", end="") #supprime la dernière ligne
|
# print("\033[A\033[K", end="") #supprime la dernière ligne
|
||||||
else:
|
else:
|
||||||
is_plu = answer == 1
|
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
|
# On demande le numero INSEE ou SIREN tant que l'input est invalide
|
||||||
while True:
|
while True:
|
||||||
print("numero INSEE (Format 5 chiffres): "
|
print("numero INSEE (Format 5 chiffres): "
|
||||||
if is_plu else "numero siren (Format 9 chiffres): ", end="")
|
if is_plu else "numero siren (Format 9 chiffres): ", end="")
|
||||||
prefixe = input()
|
prefixe = input()
|
||||||
if test_siren_insee(is_plu, prefixe):
|
if test_siren_insee(is_plu, prefixe) and confirm_choice(prefixe):
|
||||||
break
|
break
|
||||||
|
|
||||||
# On demande la date d'approbation tant que l'input est invalide
|
# On demande la date d'approbation tant que l'input est invalide
|
||||||
while True:
|
while True:
|
||||||
print("Date d'approbation (Format AAAAMMJJ): ", end="")
|
print("Date d'approbation (Format AAAAMMJJ): ", end="")
|
||||||
suffixe = input()
|
suffixe = input()
|
||||||
if test_date(suffixe):
|
if test_date(suffixe) and confirm_choice(suffixe):
|
||||||
break
|
break
|
||||||
|
|
||||||
main_path = create_folders(is_plu, prefixe, suffixe)
|
main_path = create_folders(is_plu, prefixe, suffixe)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user