From 46e18814a4c48518c95de7f6e2d85627fdf6b53d Mon Sep 17 00:00:00 2001 From: Jordan ERNST Date: Thu, 12 Apr 2018 15:11:48 +0200 Subject: [PATCH] IFPass dev uploaded --- IFPass.py | 106 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 67 insertions(+), 39 deletions(-) diff --git a/IFPass.py b/IFPass.py index d39a16f..a0cdb7b 100644 --- a/IFPass.py +++ b/IFPass.py @@ -27,7 +27,7 @@ from termcolor import colored version = '1.0' -computer = '' # 'test', 'mediatheque' or 'accueil' +computer = 'test' # 'test', 'mediatheque' or 'accueil' if computer == 'test': IFPassdir = '\\\\192.168.1.1\SSIC\\04-Projets\IFPass\\' @@ -239,45 +239,73 @@ def printcard(cartefilename): print('test') -while "the informations are incorrect": # Loop Filling informations - os.system('cls') - init() - f = Figlet(font='big') - print(colored(f.renderText('IFPass'), 'cyan', attrs=['bold'])) - print('Version :', version) - print('\nLe programme IFPass à été écrit par Jordan ERNST Q1 2018.') - print('Pour toute question ou problème contactez-moi à pro.ernst@gmail.com.\n') - titre, firstname, surname, fullname = get_fullname() - dateinsc = date.today() - dateexp = dateinsc + timedelta(days=365) +while True: + print('1 - Nouveau membre', '2 - Rechercher un membre', '3 - Quitter', sep='\n') + choix = input('Choix : ') + if choix == '1': + while "the informations are incorrect": # Loop Filling informations + os.system('cls') + init() + f = Figlet(font='big') + print(colored(f.renderText('IFPass'), 'cyan', attrs=['bold'])) + print('Version :', version) + print('\nLe programme IFPass à été écrit par Jordan ERNST Q1 2018.') + print('Pour toute question ou problème contactez-moi à pro.ernst@gmail.com.\n') + titre, firstname, surname, fullname = get_fullname() + dateinsc = date.today() + dateexp = dateinsc + timedelta(days=365) - dateinsc = dateinsc.strftime('%d/%m/%Y') - dateexp = dateexp.strftime('%d/%m/%Y') - changeexp = yes_or_no('Voulez-vous choisir la date d\'expiration ?') - if changeexp: - while True: - dateexp = input('Quelle date d\'expiration voulez-vous mettre (Format : JJ/MM/AAAA)? : ') - match = re.fullmatch(r'^(0[1-9]|1[0-9]|2[0-9]|3[0-1])/(0[1-9]|1[0-2])/([0-9]){4}$', dateexp) - if match: - break - else: - print('Mauvais format ! JJ/MM/AAAA, exemple : 01/08/2042') + dateinsc = dateinsc.strftime('%d/%m/%Y') + dateexp = dateexp.strftime('%d/%m/%Y') + changeexp = yes_or_no('Voulez-vous choisir la date d\'expiration ?') + if changeexp: + while True: + dateexp = input('Quelle date d\'expiration voulez-vous mettre (Format : JJ/MM/AAAA)? : ') + match = re.fullmatch(r'^(0[1-9]|1[0-9]|2[0-9]|3[0-1])/(0[1-9]|1[0-2])/([0-9]){4}$', dateexp) + if match: + break + else: + print('Mauvais format ! JJ/MM/AAAA, exemple : 01/08/2042') - os.system('cls') - print("Titre : ", colored(titre, 'green')) - print("Prénom : ", colored(firstname, 'green')) - print("Nom : ", colored(surname, 'green')) - print("Date d'inscription :", colored(dateinsc, 'green')) - print("Date d'expiration : ", colored(dateexp, 'green')) - correct = yes_or_no("Ces informations sont elles correctes ?") + os.system('cls') + print("Titre : ", colored(titre, 'green')) + print("Prénom : ", colored(firstname, 'green')) + print("Nom : ", colored(surname, 'green')) + print("Date d'inscription :", colored(dateinsc, 'green')) + print("Date d'expiration : ", colored(dateexp, 'green')) + correct = yes_or_no("Ces informations sont elles correctes ?") - if correct: + if correct: + os.system('cls') + picture = getpic() + clientID = getclientID() + barcode = barcode_gen(clientID) + fillcard(barcode) + cartefilename = mergepdf() + bkpdb() + if computer == 'mediatheque' or computer == 'accueil': + printcard(cartefilename) + + elif choix == '2': os.system('cls') - picture = getpic() - clientID = getclientID() - barcode = barcode_gen(clientID) - fillcard(barcode) - cartefilename = mergepdf() - bkpdb() - if computer == 'mediatheque' or computer == 'accueil': - printcard(cartefilename) + research = input('Entrez le nom, prénom, ou numéro de carte (ou flashez) : ').lower() + try: + with open(clientsfile, 'r', newline='', encoding='utf-8') as csvfile: + results = [] + for line in csvfile.readlines(): + resfirstname = line.split(';')[1].lower() + ressurname = line.split(';')[2].lower() + resnumber = line.split(';')[3] + if research in (ressurname or resfirstname): + results.append([resfirstname, ressurname, resnumber]) + print(results) + + except FileNotFoundError: + print('Le fichier client est inexistant.') + + elif choix == '3': + sys.exit() + + else: + os.system('cls') + print('Choix incorrect !')