From 23b3543ba99d6c9a163c8364b20bdcbbb6940c36 Mon Sep 17 00:00:00 2001 From: Jordan ERNST Date: Mon, 4 Feb 2019 16:47:28 +0100 Subject: [PATCH] Declared main() for packaging --- IFPass.py | 125 ++++++++++++++++++++++++++------------------------ installer.cfg | 4 +- 2 files changed, 66 insertions(+), 63 deletions(-) diff --git a/IFPass.py b/IFPass.py index 910fe16..93de9ab 100644 --- a/IFPass.py +++ b/IFPass.py @@ -28,6 +28,7 @@ config = 'IFPass.conf' def initialisation(): + global clientsfile, IFPassdir, clientsfile, clientID, imgdir, dateexp, titre, dateinsc, firstname, surname, clientsbkpfile, pngtemplate, fonttemplate, fullname, picture, pdftemplate, printername, AcrobatReader conf = configparser.ConfigParser() conf.optionxform = str # For case sensitive config file @@ -286,68 +287,70 @@ def membersearch(): print(colored("Aucun membre n'a été trouvé.", 'red', attrs=['bold'])) -while "The program is running": - init() # Initialisation of colorama - IFPassdir, printername, AcrobatReader, clientsfile, clientsbkpfile, imgdir, pdftemplate, pngtemplate, fonttemplate = initialisation() +def main(): + while "The program is running": + init() # Initialisation of colorama + IFPassdir, printername, AcrobatReader, clientsfile, clientsbkpfile, imgdir, pdftemplate, pngtemplate, fonttemplate = initialisation() - os.system('cls') - f = Figlet(font='big') - print(colored(f.renderText('IFPass'), 'cyan', attrs=['bold'])) - print('Version : ', version) - if version in ('dev', 'devnocam'): - print(colored("\nATTENTION : Il s'agit d'une version en cours de développement, potentiellement instable !", 'red')) - print("\nLe programme IFPass à été écrit par Jordan ERNST Q1 2018 pour l'Institut Français en Hongrie.") - print('Pour toute question, problème ou requête contactez-moi à pro.ernst@gmail.com.\n') - 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') - - 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') - - 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: + os.system('cls') + f = Figlet(font='big') + print(colored(f.renderText('IFPass'), 'cyan', attrs=['bold'])) + print('Version : ', version) + if version in ('dev', 'devnocam'): + print(colored("\nATTENTION : Il s'agit d'une version en cours de développement, potentiellement instable !", 'red')) + print("\nLe programme IFPass à été écrit par Jordan ERNST Q1 2018 pour l'Institut Français en Hongrie.") + print('Pour toute question, problème ou requête contactez-moi à pro.ernst@gmail.com.\n') + 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') - if version != 'devnocam': - picture = getpic() - clientID = getclientID() - barcode = barcode_gen(clientID) - fillcard(barcode) - cartefilename = mergepdf() - if version not in ('dev', 'devnocam'): - bkpdb() - printcard(cartefilename) - break - elif choix == '2': - os.system('cls') - membersearch() - os.system("pause") - elif choix == '3': - sys.exit() + titre, firstname, surname, fullname = get_fullname() + dateinsc = date.today() + dateexp = dateinsc + timedelta(days=365) - else: - os.system('cls') - print(colored('Choix incorrect !', 'red', attrs=['bold'])) + 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 ?") + + if correct: + os.system('cls') + if version != 'devnocam': + global picture + picture = getpic() + clientID = getclientID() + barcode = barcode_gen(clientID) + fillcard(barcode) + cartefilename = mergepdf() + if version not in ('dev', 'devnocam'): + bkpdb() + printcard(cartefilename) + break + elif choix == '2': + os.system('cls') + membersearch() + os.system("pause") + + elif choix == '3': + sys.exit() + + else: + os.system('cls') + print(colored('Choix incorrect !', 'red', attrs=['bold'])) diff --git a/installer.cfg b/installer.cfg index f803bd1..633f2ef 100644 --- a/installer.cfg +++ b/installer.cfg @@ -1,10 +1,10 @@ [Application] name=IFPass version=2.2 -target=IFPass.py +entry_point=IFPass:main [Python] -version=3.7.2 +version=3.7.1 [Include] # Packages from PyPI that your application requires, one per line