search function added

This commit is contained in:
Jordan ERNST 2018-04-24 17:25:16 +02:00
parent 5297fd2c5a
commit f9b62fc805
2 changed files with 18 additions and 10 deletions

View File

@ -234,13 +234,14 @@ def printcard(cartefilename):
subprocess.Popen('"' + AcrobatReader + '"' + ' /h /n /t ' + cartefilename + ' '+ printername, shell=False)
while True:
while "The program is running":
print('1 - Nouveau membre', '2 - Rechercher un membre', '3 - Quitter', sep='\n')
choix = input('Choix : ')
IFPassdir, printername, AcrobatReader, clientsfile, clientsbkpfile, imgdir, pdftemplate, pngtemplate, fonttemplate = initialisation()
init() # Initialisation of colorama
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)
@ -274,7 +275,6 @@ while True:
if correct:
os.system('cls')
IFPassdir, printername, AcrobatReader, clientsfile, clientsbkpfile, imgdir, pdftemplate, pngtemplate, fonttemplate = initialisation()
if version != 'devnocam':
picture = getpic()
clientID = getclientID()
@ -291,12 +291,20 @@ while True:
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()
resfirstname = line.split(';')[1]
resfirstnamemin = resfirstname.lower()
ressurname = line.split(';')[2]
ressurnamemin = ressurname.lower()
resnumber = line.split(';')[3]
if research in (ressurname or resfirstname):
results.append([resfirstname, ressurname, resnumber])
print(results)
if any(research in data for data in [resfirstnamemin, ressurnamemin, resnumber]):
results.append((resfirstname, ressurname, resnumber))
if results:
print('Prénom', 'Nom', '"Numéro de carte"')
for result in results:
print(result[0], result[1], result[2])
else:
print(colored("Aucun membre n'a été trouvé.", 'red', attrs=['bold']))
except FileNotFoundError:
print('Le fichier client est inexistant.')
@ -306,4 +314,4 @@ while True:
else:
os.system('cls')
print('Choix incorrect !')
print(colored('Choix incorrect !', 'red', attrs=['bold']))