diff --git a/src/CNIRevelator.py b/src/CNIRevelator.py index 3d49ce2..20660c5 100644 --- a/src/CNIRevelator.py +++ b/src/CNIRevelator.py @@ -24,19 +24,15 @@ ******************************************************************************** """ # Import critical files -import sys import os -import subprocess import threading -import psutil -import traceback import lang # lang.py import logger # logger.py import globs # globs.py import critical # critical.py -# Import all other files +# Import all other files and crash if necessary try: import launcher # launcher.py" @@ -48,9 +44,6 @@ try: except: critical.LASTCHANCECRASH() - -from main import * # main.py - # Global handler logfile = logger.logCur @@ -72,8 +65,10 @@ def main(): mainw.logOnTerm('\n\n{} \n'.format(lang.all[globs.CNIRlang]["Please type a MRZ or open a scan"])) + # changelog if globs.CNIRNewVersion: - showinfo("Changelog : update summary", ('{} : CNIRevelator {}\n\n{}'.format(lang.all[globs.CNIRlang]["Program version"], globs.verstring_full, globs.changelog)), parent=mainw) + mainw.after_idle(mainw.showChangeLog) + logfile.printdbg('main() : **** Launching App_main() ****') try: mainw.mainloop() @@ -87,59 +82,44 @@ def main(): ## BOOTSTRAP OF CNIREVELATOR try: - # LANGUAGE - if os.path.isfile(globs.CNIRLangFile): - with open(globs.CNIRLangFile, 'r') as (configFile): - try: - # Reading it - globs.CNIRlang = configFile.read() - except Exception as e: - ihm.crashCNIR() - raise IOError(str(e)) - else: - # Recreating the url file - try: - os.mkdir(globs.CNIRFolder + '\\config') - except: - pass - with open(globs.CNIRLangFile, 'w') as (configFile): + try: + # LANGUAGE + lang.readLang() + except: + ihm.crashCNIR() + updater.exitProcess(1) + + from main import * # main.py + # GO + try: + launcherThread = threading.Thread(target=updater.umain, daemon=False) + launcher.lmain(launcherThread) + except Exception: + ihm.crashCNIR() + updater.exitProcess(1) + + if updater.UPDATE_IS_MADE: + # Launch app ! + args = updater.UPATH + '\\CNIRevelator.exe' + " DELETE " + globs.CNIRFolder + cd = updater.UPATH + for i in range(0,3): try: - # Writing it - configFile.write(globs.CNIRlang) - except Exception as e: - ihm.crashCNIR() - raise IOError(str(e)) + updater.spawnProcess(args, cd) + except: + time.sleep(3) + continue + break + updater.exitProcess(0) + + # Here we go ! + try: + main() + except Exception as e: + ihm.crashCNIR() + updater.exitProcess(1) + except: - ihm.crashCNIR() - updater.exitProcess(1) - -# GO -try: - launcherThread = threading.Thread(target=updater.umain, daemon=False) - launcher.lmain(launcherThread) -except Exception: - ihm.crashCNIR() - updater.exitProcess(1) - -if updater.UPDATE_IS_MADE: - # Launch app ! - args = updater.UPATH + '\\CNIRevelator.exe' + " DELETE " + globs.CNIRFolder - cd = updater.UPATH - for i in range(0,3): - try: - updater.spawnProcess(args, cd) - except: - time.sleep(3) - continue - break - updater.exitProcess(0) - -# Here we go ! -try: - main() -except Exception as e: - ihm.crashCNIR() - updater.exitProcess(1) + critical.LASTCHANCECRASH() updater.exitProcess(0) \ No newline at end of file diff --git a/src/critical.py b/src/critical.py index 9ff07b9..8d337d0 100644 --- a/src/critical.py +++ b/src/critical.py @@ -24,16 +24,27 @@ """ from tkinter.messagebox import * from tkinter import * +import webbrowser +import traceback +import psutil +import os import lang # lang.py import logger # logger.py +import globs # globs.py def LASTCHANCECRASH(): + """ + very last solution + """ root = Tk() root.withdraw() logfile = logger.logCur logfile.printerr("FATAL ERROR : see traceback below.\n{}".format(traceback.format_exc())) showerror(lang.all[globs.CNIRlang]["CNIRevelator Fatal Eror"], lang.all[globs.CNIRlang]["CNIRevelator crashed because a fatal error occured. View log for more infos and please open an issue on Github"]) + res = askquestion(lang.all[globs.CNIRlang]["CNIRevelator Fatal Eror"], lang.all[globs.CNIRlang]["Would you like to open the log file ?"]) + if res == "yes": + webbrowser.open_new(globs.CNIRErrLog) res = askquestion(lang.all[globs.CNIRlang]["CNIRevelator Fatal Eror"], lang.all[globs.CNIRlang]["Would you like to open an issue on Github to report this bug ?"]) if res == "yes": webbrowser.open_new("https://github.com/neox95/CNIRevelator/issues") diff --git a/src/globs.py b/src/globs.py index 2f4b850..77ba0c8 100644 --- a/src/globs.py +++ b/src/globs.py @@ -29,16 +29,29 @@ verType = "final release" version = [3, 1, 0] verstring_full = "{}.{}.{} {}".format(version[0], version[1], version[2], verType) verstring = "{}.{}".format(version[0], version[1]) -debug = True -changelog = "Version 3.1.0 \nMise-à-jour majeure avec les progressions suivantes :\n- Modifications cosmétiques de l'interface utilisateur\n- Stabilisation des changements effectués sur la version mineure 3.0 : interface utilisateur, OCR, VISA A et B, logging\n- Rationalisation du système de langues" +CNIRTesserHash = '5b58db27f7bc08c58a2cb33d01533b034b067cf8' +CNIRFolder = os.getcwd() +CNIRLColor = "#006699" +CNIRName = "CNIRevelator {}".format(verstring) +CNIRCryptoKey = '82Xh!efX3#@P~2eG' +CNIRNewVersion = False + +CNIRConfig = CNIRFolder + '\\config\\conf.ig' +CNIRTesser = CNIRFolder + '\\Tesseract-OCR4\\' +CNIRErrLog = CNIRFolder + '\\logs\\error.log' +CNIRMainLog = CNIRFolder + '\\logs\\main.log' +CNIRUrlConfig = CNIRFolder + '\\config\\urlconf.ig' +CNIRVerStock = CNIRFolder + '\\downloads\\versions.lst' +CNIREnv = CNIRFolder + '\\Data\\' + CNIRTesserHash = '5b58db27f7bc08c58a2cb33d01533b034b067cf8' CNIRFolder = os.path.dirname(os.path.realpath(__file__)) CNIRLColor = "#006699" CNIRName = "CNIRevelator {}".format(verstring) CNIRCryptoKey = '82Xh!efX3#@P~2eG' -CNIRNewVersion = False + CNIRLangFile = CNIRFolder + '\\config\\lang.ig' CNIRlang = "fr" @@ -50,4 +63,9 @@ CNIRUrlConfig = CNIRFolder + '\\config\\urlconf.ig' CNIRVerStock = CNIRFolder + '\\downloads\\versions.lst' CNIREnv = CNIRFolder + '\\Data\\' -CNIROpenFile = False \ No newline at end of file +CNIRBetaURL = "https://raw.githubusercontent.com/neox95/CNIRevelator/v3.1/VERSIONS.LST" +CNIRDefaultURL = "https://raw.githubusercontent.com/neox95/CNIRevelator/master/VERSIONS.LST" + +CNIRNewVersion = False +CNIROpenFile = False +debug = True \ No newline at end of file diff --git a/src/ihm.py b/src/ihm.py index 1c7d153..7c1a05b 100644 --- a/src/ihm.py +++ b/src/ihm.py @@ -1,4 +1,4 @@ -""" +""" ******************************************************************************** * CNIRevelator * * * @@ -35,7 +35,7 @@ import traceback import logger # logger.py import globs # globs.py import lang # lang.py - +import updater # updater.py controlKeys = ["Escape", "Right", "Left", "Up", "Down", "Home", "End", "BackSpace", "Delete", "Inser", "Shift_L", "Shift_R", "Control_R", "Control_L"] @@ -117,21 +117,22 @@ class LoginDialog(Toplevel): self.login = '' super().__init__(parent) self.title(lang.all[globs.CNIRlang]["Connection"]) - Label(self, text='IPN : ').pack() - self.entry_login = Entry(self) + self["background"] = "white" + Label(self, text='IPN : ', bg="white").pack(fill=Y) + self.entry_login = ttk.Entry(self) self.entry_login.insert(0, '') self.entry_login.pack() - Label(self, text='{} : '.format(lang.all[globs.CNIRlang]["Password"])).pack() - self.entry_pass = Entry(self, show='*') + Label(self, text='{} : '.format(lang.all[globs.CNIRlang]["Password"]), bg="white").pack(fill=Y) + self.entry_pass = ttk.Entry(self, show='*') self.entry_pass.insert(0, '') - self.entry_pass.pack() - Button(self, text=lang.all[globs.CNIRlang]["Connection"], command=(self.connecti)).pack() + self.entry_pass.pack(fill=Y) + ttk.Button(self, text=lang.all[globs.CNIRlang]["Connection"], command=(self.connecti)).pack(fill=Y, pady=10) + self.update() self.resizable(width=False, height=False) ws = self.winfo_screenwidth() hs = self.winfo_screenheight() - w = hs / 10 - h = ws / 18 - self.update() + w = self.winfo_reqwidth() + 5 + h = self.winfo_reqheight() if getattr(sys, 'frozen', False): self.iconbitmap(sys._MEIPASS + '\\id-card.ico\\id-card.ico') else: @@ -146,6 +147,124 @@ class LoginDialog(Toplevel): self.key = self.entry_pass.get().strip() self.destroy() +class ChangelogDialog(Toplevel): + + def __init__(self, parent, text): + super().__init__(parent) + + self.title(lang.all[globs.CNIRlang]["Show Changelog"]) + self["background"] = "white" + + self.grid_columnconfigure(0, weight=1) + self.grid_rowconfigure(0, weight=1) + + self.text = Text(self, wrap='word', width=55, height=15, borderwidth=0, font="TkDefaultFont", bg="white") + self.text.grid(column=0, row=0, sticky='EWNS', padx=5, pady=5) + + ttk.Button(self, text="OK", command=(self.oki)).grid(column=0, row=1, pady=5) + + self.scrollb = ttk.Scrollbar(self, command=(self.text.yview)) + self.scrollb.grid(column=1, row=0, sticky='EWNS', padx=5, pady=5) + self.text['yscrollcommand'] = self.scrollb.set + + self.text.insert('end', text) + self.text['state'] = 'disabled' + + self.update() + self.resizable(width=False, height=False) + ws = self.winfo_screenwidth() + hs = self.winfo_screenheight() + w = self.winfo_reqwidth() + 5 + h = self.winfo_reqheight() + if getattr(sys, 'frozen', False): + self.iconbitmap(sys._MEIPASS + '\\id-card.ico\\id-card.ico') + else: + self.iconbitmap('id-card.ico') + x = ws / 2 - w / 2 + y = hs / 2 - h / 2 + self.geometry('%dx%d+%d+%d' % (w, h, x, y)) + self.bind("", self.oki) + + def oki(self, event=None): + self.destroy() + +class langDialog(Toplevel): + + def __init__(self, parent): + super().__init__(parent) + + self.title(lang.all[globs.CNIRlang]["Language"]) + + Label(self, text=lang.all[globs.CNIRlang]["Please choose your language : "]).pack(fill=Y) + + vals = [i for i in lang.all] + for i in range(len(lang.all)): + ttk.Radiobutton(self, text=vals[i], command=self.createRegister(i), value=vals[i]).pack(fill=Y) + + ttk.Button(self, text="OK", command=(self.oki)).pack(fill=Y, pady=5) + + self.update() + self.resizable(width=False, height=False) + ws = self.winfo_screenwidth() + hs = self.winfo_screenheight() + w = self.winfo_reqwidth() + 5 + h = self.winfo_reqheight() + if getattr(sys, 'frozen', False): + self.iconbitmap(sys._MEIPASS + '\\id-card.ico\\id-card.ico') + else: + self.iconbitmap('id-card.ico') + x = ws / 2 - w / 2 + y = hs / 2 - h / 2 + self.geometry('%dx%d+%d+%d' % (w, h, x, y)) + self.bind("", self.oki) + + def oki(self, event=None): + self.destroy() + + def createRegister(self, i): + def register(): + lang.updateLang([j for j in lang.all][i]) + return register + +class updateSetDialog(Toplevel): + + def __init__(self, parent): + super().__init__(parent) + + self.title(lang.all[globs.CNIRlang]["Update options"]) + + Label(self, text=lang.all[globs.CNIRlang]["Please choose your update channel : "]).pack(fill=Y) + + self.vals = ["Stable", "Beta"] + vals = self.vals + for i in range(len(vals)): + ttk.Radiobutton(self, text=vals[i], command=self.createRegister(i), value=vals[i]).pack(fill=Y) + + ttk.Button(self, text="OK", command=(self.oki)).pack(fill=Y, pady=5) + + self.update() + self.resizable(width=False, height=False) + ws = self.winfo_screenwidth() + hs = self.winfo_screenheight() + w = self.winfo_reqwidth() + 5 + h = self.winfo_reqheight() + if getattr(sys, 'frozen', False): + self.iconbitmap(sys._MEIPASS + '\\id-card.ico\\id-card.ico') + else: + self.iconbitmap('id-card.ico') + x = ws / 2 - w / 2 + y = hs / 2 - h / 2 + self.geometry('%dx%d+%d+%d' % (w, h, x, y)) + self.bind("", self.oki) + + def oki(self, event=None): + self.destroy() + + def createRegister(self, i): + def register(): + updater.updateChannel(self.vals[i]) + return register + class LauncherWindow(Tk): def __init__(self): @@ -233,6 +352,23 @@ class ResizeableCanvas(Canvas): # rescale all the objects tagged with the "all" tag self.scale("all",0,0,wscale,hscale) +class StatusBar(Frame): + + def __init__(self, master): + Frame.__init__(self, master) + self.label = Label(self, bd=1, relief=SUNKEN, anchor=W) + self.label.pack(fill=X) + + def set(self, text): + self.label.config(text="Document : " + text.lower()) + self.label.update_idletasks() + + def clear(self): + self.label.config(text="") + self.label.update_idletasks() + +## Crash + def crashCNIR(): """ last solution @@ -244,6 +380,9 @@ def crashCNIR(): root.withdraw() logfile.printerr("FATAL ERROR : see traceback below.\n{}".format(traceback.format_exc())) showerror(lang.all[globs.CNIRlang]["CNIRevelator Fatal Eror"], lang.all[globs.CNIRlang]["CNIRevelator crashed because a fatal error occured. View log for more infos and please open an issue on Github"]) + res = askquestion(lang.all[globs.CNIRlang]["CNIRevelator Fatal Eror"], lang.all[globs.CNIRlang]["Would you like to open the log file ?"]) + if res == "yes": + webbrowser.open_new(globs.CNIRErrLog) res = askquestion(lang.all[globs.CNIRlang]["CNIRevelator Fatal Eror"], lang.all[globs.CNIRlang]["Would you like to open an issue on Github to report this bug ?"]) if res == "yes": webbrowser.open_new("https://github.com/neox95/CNIRevelator/issues") diff --git a/src/lang.py b/src/lang.py index 100706c..d671572 100644 --- a/src/lang.py +++ b/src/lang.py @@ -22,6 +22,7 @@ * along with CNIRevelator. If not, see . * ******************************************************************************** """ +import os import globs # globs.py @@ -49,6 +50,8 @@ french = \ "fatal error occured. View log for " "more infos and please open " "an issue on Github" : "CNIRevelator s'est arrêté car une erreur fatale s'est produite. Consultez le journal pour plus d'informations et ouvrez s'il vous plaît un ticket sur Github.", +"Would you like to open the " +"log file ?" : "Souhaitez-vous ouvrir le fichier de log ?", "Would you like to open an issue " "on Github to report this bug ?" : "Souhaitez-vous ouvrir un ticket sur Github pour signaler ce bogue?", "Starting..." : "Lancement...", @@ -64,7 +67,7 @@ french = \ "Issuing country" : "Pays émetteur", "Nationality" : "Nationalité", "Registration" : "Immatriculation", -"Document number" : "Numéro de document", +"Document number" : "N° de document", "Unknown" : "Inconnu(e)", "Display and processing of " "documents" : "Affichage et traitement de documents", @@ -75,6 +78,7 @@ french = \ "Open scan..." : "Ouvrir scan...", "Quit" : "Quitter", "File" : "Fichier", +"Settings" : "Paramètres", "Keyboard commands" : "Commandes au clavier", "Report a bug" : "Signaler un problème", "About CNIRevelator" : "A propos de CNIRevelator", @@ -132,9 +136,22 @@ french = \ "Copier :\t\t\t\tCtrl-C \n" "Coller :\t\t\t\tCtrl-V \n" "Forcer une nouvelle détection du document :\tEchap\n", + +"CHANGELOG" : "Version 3.1.0 \nMise-à-jour majeure avec les progressions suivantes :\n- Modifications cosmétiques de l'interface utilisateur\n- Stabilisation des changements effectués sur la version mineure 3.0 : interface utilisateur, OCR, VISA A et B, logging\n- Rationalisation du système de langues\n- Ajout des canaux de mise-à-jour\n\n" + \ +"Version 3.0.8 finale\nCorrectif : bug du système de mise-à-jour'\n\n" + \ +"Version 3.0.6 \nMise-à-jour mineure avec les corrections suivantes :\n- Changement de l'apparence du launcher de l'application\n- Améliorations de l'interface, notamment de la stabilité\n- Ajout de la signature numérique de l'exécutable\n\n" + \ +"Version 3.0.7 finale\nMise-à-jour majeure avec les corrections suivantes :\n- Refonte de l'interface utilisateur\n- Fonction OCR intégrée à l'application avec support des TIFF et JPEG\n- Corrections d'erreurs sur le traitement des VISA de type A et B, ainsi que les titres de séjour\n\n" + \ +"Version 3.0.6 \nMise-à-jour mineure avec les corrections suivantes :\n- Changement de l'apparence du launcher de l'application\n- Améliorations de l'interface, notamment de la stabilité\n- Ajout de la signature numérique de l'exécutable\n\n" + \ +"Version 3.0.5 \nMise-à-jour mineure avec les corrections suivantes :\n- Changement de l'icône de l'exécutable afin de refléter le changement de version majeur accompli en 3.0\n\n" + \ +"Version 3.0.4 \nMise-à-jour mineure avec les corrections suivantes :\n- Correction d'un bug affectant le système de mise-à-jour\n\n" + \ +"Version 3.0.3 \nMise-à-jour mineure avec les corrections suivantes :\n- Correction d'un bug affectant le changelog\n- Correction d'une erreur avec la touche Suppr Arrière et Suppr causant une perte de données\n\n" + \ +"Version 3.0.2 \nMise-à-jour mineure avec les corrections suivantes :\n- Changement d'icône de l'exécutable\n- Correction d'un bug affectant le logging\n- Correction d'un bug affectant la détection de documents\n- Et autres modifications mineures\n\n" + \ +"Version 3.0.1 \nMise-à-jour majeure avec les corrections suivantes :\n- Renouvellement de la signature numérique de l'exécutable\n- Amélioration de présentation du log en cas d'erreur\n- Refonte totale du code source et désobfuscation\n- Téléchargements en HTTPS fiables avec somme de contrôle\n- Nouveaux terminaux d'entrées : un rapide (731) et un complet\n- Détection des documents améliorée, possibilité de choix plus fin\nEt les regressions suivantes :\n- Suppression temporaire de la fonction de lecture OCR. Retour planifié pour une prochaine version", + "Document Review: {}\n\n" : "Examen du document : {}\n\n", -"Check sum position {}: Lu {} VS " -"Calculated {} and {}\n" : "Check sum position {}: Lu {} VS Calculated {} and {}\n", +"Calculated {} [facultative]\n" : "Checksum position {}: Lu {} VS Calculé {} [facultatif]\n", +"Checksum position {}: Lu {} VS " +"Calculated {}\n" : "Checksum position {}: Lu {} VS Calculé {}\n", "COMPLIANT" : "CONFORME", "IMPROPER" : "NON CONFORME", "Installing the updates" : "Installation des mises-à-jour", @@ -151,9 +168,547 @@ french = \ "Shortcut creation" : "Création de raccourci", "Would you like to create/update " "the shortcut for CNIRevelator " -"on your desktop ?" : "Souhaitez vous créer/mettre à jour le raccourci pour CNIRevelator sur votre bureau ?", +"on your desktop ?" : "Souhaitez vous créer/mettre à jour le raccourci pour CNIRevelator sur votre bureau ?", "The file you provided is " -"not found : {}" : "Fichier transmis non trouvé : {}" +"not found : {}" : "Fichier transmis non trouvé : {}", +"Update options" : "Options de mise-à-jour", +"Language" : "Langue", +"Show Changelog" : "Résumé de mise-à-jour", +"Please choose your language : " : "Merci de choisir votre langue : ", +"Please choose your update " +"channel : " : "Merci de choisir votre canal de mise-à-jour : ", +"Passeport" : "Passeport", +"Carte-passeport" : "Carte-passeport", +"Titre d'identité/de voyage" : "Titre d'identité/de voyage", +"Certificat de membre d'équipage" : "Certificat de membre d'équipage", +"Visa de type A" : "Visa de type A", +"Visa de type B" : "Visa de type B", +"Carte de séjour" : "Carte de séjour", +"Pièce d'identité/de voyage" : "Pièce d'identité/de voyage", +"Pièce d'identité FR" : "Pièce d'identité FR", +"Permis de conduire" : "Permis de conduire", + +"LANDCODE2" : { + 'AW': 'Aruba', + 'AF': 'Afghanistan', + 'AO': 'Angola', + 'AI': 'Anguilla', + 'AL': 'Albanie', + 'AD': 'Andorre', + 'AE': 'Emirats arabes unis', + 'AR': 'Argentine', + 'AM': 'Arménie', + 'AS': 'Samoa américaines', + 'AQ': 'Antarctique', + 'TF': 'Terres australes et antarctiques françaises', + 'AG': 'Antigua-et-Barbuda', + 'AU': 'Australie', + 'AT': 'Autriche', + 'AZ': 'Azerbaidjan', + 'BI': 'Burundi', + 'BE': 'Belgique', + 'BJ': 'Benin', + 'BQ': 'Pays-Bas caribéens', + 'BF': 'Burkina Faso', + 'BD': 'Bangladesh', + 'BG': 'Bulgarie', + 'BH': 'Bahrein', + 'BS': 'Bahamas', + 'BA': 'Bosnie-Herzegovine', + 'BL': 'Saint-Barthélemy', + 'BY': 'Bielorussie', + 'BZ': 'Belize', + 'BM': 'Bermudes', + 'BO': 'Bolivie', + 'BR': 'Brésil', + 'BB': 'Barbade', + 'BN': 'Brunei', + 'BT': 'Bhoutan', + 'BW': 'Botswana', + 'CF': 'République Centrafricaine', + 'CA': 'Canada', + 'CC': 'Îles Cocos', + 'CH': 'Suisse', + 'CL': 'Chili', + 'CN': 'Chine', + 'CI': "Côte d'Ivoire", + 'CM': 'Cameroun', + 'CD': 'Congo (République démocratique)', + 'CG': 'Congo (République)', + 'CK': 'Îles Cook', + 'CO': 'Colombie', + 'KM': 'Comores', + 'CV': 'Cap-Vert', + 'CR': 'Costa Rica', + 'CU': 'Cuba', + 'CW': 'Curaçao', + 'CX': 'Île Christmas', + 'KY': 'Caimans', + 'CY': 'Chypre', + 'CZ': 'Tchéquie', + 'DE': 'Allemagne', + 'DJ': 'Djibouti', + 'DM': 'Dominique', + 'DK': 'Danemark', + 'DO': 'République dominicaine', + 'DZ': 'Algérie', + 'EC': 'Equateur', + 'EG': 'Egypte', + 'ER': 'Erythrée', + 'EH': 'Sahara occidental', + 'ES': 'Espagne', + 'EE': 'Estonie', + 'ET': 'Ethiopie', + 'FI': 'Finlande', + 'FJ': 'Fidji', + 'FK': 'Îles Malouines', + 'FR': 'France', + 'FO': 'Féroé', + 'FM': 'Micronésie', + 'GA': 'Gabon', + 'GB': 'Royaume-Uni', + 'GE': 'Géorgie', + 'GG': 'Guernesey', + 'GH': 'Ghana', + 'GI': 'Gibraltar', + 'GN': 'Guinée', + 'GP': 'Guadeloupe', + 'GM': 'Gambie', + 'GW': 'Guinée-Bissau', + 'GQ': 'Guinée équatoriale', + 'GR': 'Grèce', + 'GD': 'Grenade', + 'GL': 'Groenland', + 'GT': 'Guatemala', + 'GF': 'Guyane', + 'GU': 'Guam', + 'GY': 'Guyana', + 'HK': 'Hong Kong', + 'HN': 'Honduras', + 'HR': 'Croatie', + 'HT': 'Haïti', + 'HU': 'Hongrie', + 'ID': 'Indonésie', + 'IM': 'Île de Man', + 'IN': 'Inde', + 'IO': "Territoire britannique de l'océan Indien", + 'IE': 'Irlande', + 'IR': 'Irak', + 'IQ': 'Iran', + 'IS': 'Islande', + 'IL': 'Israël', + 'IT': 'Italie', + 'JM': 'Jamaïque', + 'JE': 'Jersey', + 'JO': 'Jordanie', + 'JP': 'Japon', + 'KZ': 'Kazakhstan', + 'KE': 'Kenya', + 'KG': 'Kirghizistan', + 'KH': 'Cambodge', + 'KI': 'Kiribati', + 'KN': 'Saint-Christophe-et-Niévès', + 'KR': 'Corée du Sud', + 'KW': 'Koweït', + 'LA': 'Laos', + 'LB': 'Liban', + 'LR': 'Liberia', + 'LY': 'Libye', + 'LC': 'Sainte-Lucie', + 'LI': 'Liechtenstein', + 'LK': 'Sri Lanka', + 'LS': 'Lesotho', + 'LT': 'Lituanie', + 'LU': 'Luxembourg', + 'LV': 'Lettonie', + 'MO': 'Macao', + 'MF': 'Sint-Maarten', + 'MA': 'Maroc', + 'MC': 'Monaco', + 'MD': 'Moldavie', + 'MG': 'Madagascar', + 'MV': 'Maldives', + 'MX': 'Mexique', + 'MH': 'Marshall', + 'MK': 'Macedoine', + 'ML': 'Mali', + 'MT': 'Malte', + 'MM': 'Birmanie', + 'ME': 'Monténégro', + 'MN': 'Mongolie', + 'MP': 'Îles Mariannes du Nord', + 'MZ': 'Mozambique', + 'MR': 'Mauritanie', + 'MS': 'Montserrat', + 'MQ': 'Martinique', + 'MU': 'Maurice', + 'MW': 'Malawi', + 'MY': 'Malaisie', + 'YT': 'Mayotte', + 'NA': 'Namibie', + 'NC': 'Nouvelle-Calédonie', + 'NE': 'Niger', + 'NF': 'Île Norfolk', + 'NG': 'Nigeria', + 'NI': 'Nicaragua', + 'NU': 'Niue', + 'NL': 'Pays-Bas', + 'NO': 'Norvège', + 'NP': 'Nepal', + 'NR': 'Nauru', + 'NZ': 'Nouvelle-Zélande', + 'OM': 'Oman', + 'PK': 'Pakistan', + 'PA': 'Panama', + 'PN': 'Îles Pitcairn', + 'PE': 'Pérou', + 'PH': 'Philippines', + 'PW': 'Palaos', + 'PG': 'Papouasie-Nouvelle-Guinée', + 'PL': 'Pologne', + 'PR': 'Porto Rico', + 'KP': 'Corée du Nord', + 'PT': 'Portugal', + 'PY': 'Paraguay', + 'PS': 'Palestine', + 'PF': 'Polynésie française', + 'QA': 'Qatar', + 'RE': 'Réunion', + 'RO': 'Roumanie', + 'RU': 'Russie', + 'RW': 'Rwanda', + 'SA': 'Arabie saoudite', + 'SD': 'Soudan', + 'SN': 'Sénégal', + 'SG': 'Singapour', + 'GS': 'Georgie du Sud-et-les iles Sandwich du Sud', + 'SH': 'Sainte-Hélène, Ascension et Tristan da Cunha', + 'SJ': 'Svalbard et île Jan Mayen', + 'SB': 'Salomon', + 'SL': 'Sierra Leone', + 'SV': 'Salvador', + 'SM': 'Saint-Marin', + 'SO': 'Somalie', + 'PM': 'Saint-Pierre-et-Miquelon', + 'RS': 'Serbie', + 'SS': 'Soudan du Sud', + 'ST': 'Sao Tomé-et-Principe', + 'SR': 'Suriname', + 'SK': 'Slovaquie', + 'SI': 'Slovénie', + 'SE': 'Suède', + 'SZ': 'eSwatani', + 'SX': 'Saint-Martin ', + 'SC': 'Seychelles', + 'SY': 'Syrie', + 'TC': 'Îles Turques-et-Caïques', + 'TD': 'Tchad', + 'TG': 'Togo', + 'TH': 'Thaïlande', + 'TJ': 'Tadjikistan', + 'TK': 'Tokelau', + 'TM': 'Turkmenistan', + 'TL': 'Timor oriental', + 'TO': 'Tonga', + 'TT': 'Trinité-et-Tobago', + 'TN': 'Tunisie', + 'TR': 'Turquie', + 'TV': 'Tuvalu', + 'TW': 'Taiwan', + 'TZ': 'Tanzanie', + 'UG': 'Ouganda', + 'UA': 'Ukraine', + 'UY': 'Uruguay', + 'US': 'Etats-Unis', + 'UZ': 'Ouzbékistan', + 'VA': 'Saint-Siège (État de la Cité du Vatican)', + 'VC': 'Saint-Vincent-et-les-Grenadines', + 'VE': 'Venezuela', + 'VG': 'Îles Vierges britanniques', + 'VI': 'Îles Vierges des États-Unis', + 'VN': 'Viêt Nam', + 'VU': 'Vanuatu', + 'WF': 'Wallis-et-Futuna', + 'WS': 'Samoa', + 'XK': 'Kosovo', + 'YE': 'Yémen', + 'ZA': 'Afrique du Sud', + 'ZM': 'Zambie', + 'ZW': 'Zimbabwe' + }, + +"LANDCODE3" : { + 'ABW': 'Aruba', + 'AFG': 'Afghanistan', + 'AGO': 'Angola', + 'AIA': 'Anguilla', + 'ALB': 'Albanie', + 'AND': 'Andorre', + 'ARE': 'Emirats arabes unis', + 'ARG': 'Argentine', + 'ARM': 'Arménie', + 'ASM': 'Samoa américaines', + 'ATA': 'Antarctique', + 'ATF': 'Terres australes et antarctiques françaises', + 'ATG': 'Antigua-et-Barbuda', + 'AUS': 'Australie', + 'AUT': 'Autriche', + 'AZE': 'Azerbaidjan', + 'BDI': 'Burundi', + 'BEL': 'Belgique', + 'BEN': 'Benin', + 'BES': 'Pays-Bas caribéens', + 'BFA': 'Burkina Faso', + 'BGD': 'Bangladesh', + 'BGR': 'Bulgarie', + 'BHR': 'Bahrein', + 'BHS': 'Bahamas', + 'BIH': 'Bosnie-Herzegovine', + 'BLM': 'Saint-Barthélemy', + 'BLR': 'Bielorussie', + 'BLZ': 'Belize', + 'BMU': 'Bermudes', + 'BOL': 'Bolivie', + 'BRA': 'Brésil', + 'BRB': 'Barbade', + 'BRN': 'Brunei', + 'BTN': 'Bhoutan', + 'BWA': 'Botswana', + 'CAF': 'République Centrafricaine', + 'CAN': 'Canada', + 'CCK': 'Îles Cocos', + 'CHE': 'Suisse', + 'CHL': 'Chili', + 'CHN': 'Chine', + 'CIV': "Côte d'Ivoire", + 'CMR': 'Cameroun', + 'COD': 'Congo (République démocratique)', + 'COG': 'Congo (République)', + 'COK': 'Îles Cook', + 'COL': 'Colombie', + 'COM': 'Comores', + 'CPV': 'Cap-Vert', + 'CRI': 'Costa Rica', + 'CUB': 'Cuba', + 'CUW': 'Curaçao', + 'CXR': 'Île Christmas', + 'CYM': 'Caimans', + 'CYP': 'Chypre', + 'CZE': 'Tchéquie', + 'DEU': 'Allemagne', + 'DJI': 'Djibouti', + 'DMA': 'Dominique', + 'DNK': 'Danemark', + 'DOM': 'République dominicaine', + 'DZA': 'Algérie', + 'ECU': 'Equateur', + 'EGY': 'Egypte', + 'ERI': 'Erythrée', + 'ESH': 'Sahara occidental', + 'ESP': 'Espagne', + 'EST': 'Estonie', + 'ETH': 'Ethiopie', + 'FIN': 'Finlande', + 'FJI': 'Fidji', + 'FLK': 'Îles Malouines', + 'FRA': 'France', + 'FRO': 'Féroé', + 'FSM': 'Micronésie', + 'GAB': 'Gabon', + 'GBR': 'Royaume-Uni', + 'GEO': 'Géorgie', + 'GGY': 'Guernesey', + 'GHA': 'Ghana', + 'GIB': 'Gibraltar', + 'GIN': 'Guinée', + 'GLP': 'Guadeloupe', + 'GMB': 'Gambie', + 'GNB': 'Guinée-Bissau', + 'GNQ': 'Guinée équatoriale', + 'GRC': 'Grèce', + 'GRD': 'Grenade', + 'GRL': 'Groenland', + 'GTM': 'Guatemala', + 'GUF': 'Guyane', + 'GUM': 'Guam', + 'GUY': 'Guyana', + 'HKG': 'Hong Kong', + 'HND': 'Honduras', + 'HRV': 'Croatie', + 'HTI': 'Haïti', + 'HUN': 'Hongrie', + 'IDN': 'Indonésie', + 'IMN': 'Île de Man', + 'IND': 'Inde', + 'IOT': "Territoire britannique de l'océan Indien", + 'IRL': 'Irlande', + 'IRN': 'Irak', + 'IRQ': 'Iran', + 'ISL': 'Islande', + 'ISR': 'Israël', + 'ITA': 'Italie', + 'JAM': 'Jamaïque', + 'JEY': 'Jersey', + 'JOR': 'Jordanie', + 'JPN': 'Japon', + 'KAZ': 'Kazakhstan', + 'KEN': 'Kenya', + 'KGZ': 'Kirghizistan', + 'KHM': 'Cambodge', + 'KIR': 'Kiribati', + 'KNA': 'Saint-Christophe-et-Niévès', + 'KOR': 'Corée du Sud', + 'KWT': 'Koweït', + 'LAO': 'Laos', + 'LBN': 'Liban', + 'LBR': 'Liberia', + 'LBY': 'Libye', + 'LCA': 'Sainte-Lucie', + 'LIE': 'Liechtenstein', + 'LKA': 'Sri Lanka', + 'LSO': 'Lesotho', + 'LTU': 'Lituanie', + 'LUX': 'Luxembourg', + 'LVA': 'Lettonie', + 'MAC': 'Macao', + 'MAF': 'Sint-Maarten', + 'MAR': 'Maroc', + 'MCO': 'Monaco', + 'MDA': 'Moldavie', + 'MDG': 'Madagascar', + 'MDV': 'Maldives', + 'MEX': 'Mexique', + 'MHL': 'Marshall', + 'MKD': 'Macedoine', + 'MLI': 'Mali', + 'MLT': 'Malte', + 'MMR': 'Birmanie', + 'MNE': 'Monténégro', + 'MNG': 'Mongolie', + 'MNP': 'Îles Mariannes du Nord', + 'MOZ': 'Mozambique', + 'MRT': 'Mauritanie', + 'MSR': 'Montserrat', + 'MTQ': 'Martinique', + 'MUS': 'Maurice', + 'MWI': 'Malawi', + 'MYS': 'Malaisie', + 'MYT': 'Mayotte', + 'NAM': 'Namibie', + 'NCL': 'Nouvelle-Calédonie', + 'NER': 'Niger', + 'NFK': 'Île Norfolk', + 'NGA': 'Nigeria', + 'NIC': 'Nicaragua', + 'NIU': 'Niue', + 'NLD': 'Pays-Bas', + 'NOR': 'Norvège', + 'NPL': 'Nepal', + 'NRU': 'Nauru', + 'NZL': 'Nouvelle-Zélande', + 'OMN': 'Oman', + 'PAK': 'Pakistan', + 'PAN': 'Panama', + 'PCN': 'Îles Pitcairn', + 'PER': 'Pérou', + 'PHL': 'Philippines', + 'PLW': 'Palaos', + 'PNG': 'Papouasie-Nouvelle-Guinée', + 'POL': 'Pologne', + 'PRI': 'Porto Rico', + 'PRK': 'Corée du Nord', + 'PRT': 'Portugal', + 'PRY': 'Paraguay', + 'PSE': 'Palestine', + 'PYF': 'Polynésie française', + 'QAT': 'Qatar', + 'REU': 'Réunion', + 'ROU': 'Roumanie', + 'RUS': 'Russie', + 'RWA': 'Rwanda', + 'SAU': 'Arabie saoudite', + 'SDN': 'Soudan', + 'SEN': 'Sénégal', + 'SGP': 'Singapour', + 'SGS': 'Georgie du Sud-et-les iles Sandwich du Sud', + 'SHN': 'Sainte-Hélène, Ascension et Tristan da Cunha', + 'SJM': 'Svalbard et île Jan Mayen', + 'SLB': 'Salomon', + 'SLE': 'Sierra Leone', + 'SLV': 'Salvador', + 'SMR': 'Saint-Marin', + 'SOM': 'Somalie', + 'SPM': 'Saint-Pierre-et-Miquelon', + 'SRB': 'Serbie', + 'SSD': 'Soudan du Sud', + 'STP': 'Sao Tomé-et-Principe', + 'SUR': 'Suriname', + 'SVK': 'Slovaquie', + 'SVN': 'Slovénie', + 'SWE': 'Suède', + 'SWZ': 'eSwatani', + 'SXM': 'Saint-Martin ', + 'SYC': 'Seychelles', + 'SYR': 'Syrie', + 'TCA': 'Îles Turques-et-Caïques', + 'TCD': 'Tchad', + 'TGO': 'Togo', + 'THA': 'Thaïlande', + 'TJK': 'Tadjikistan', + 'TKL': 'Tokelau', + 'TKM': 'Turkmenistan', + 'TLS': 'Timor oriental', + 'TON': 'Tonga', + 'TTO': 'Trinité-et-Tobago', + 'TUN': 'Tunisie', + 'TUR': 'Turquie', + 'TUV': 'Tuvalu', + 'TWN': 'Taiwan', + 'TZA': 'Tanzanie', + 'UGA': 'Ouganda', + 'UKR': 'Ukraine', + 'URY': 'Uruguay', + 'USA': 'Etats-Unis', + 'UZB': 'Ouzbékistan', + 'VAT': 'Saint-Siège (État de la Cité du Vatican)', + 'VCT': 'Saint-Vincent-et-les-Grenadines', + 'VEN': 'Venezuela', + 'VGB': 'Îles Vierges britanniques', + 'VIR': 'Îles Vierges des États-Unis', + 'VNM': 'Viêt Nam', + 'VUT': 'Vanuatu', + 'WLF': 'Wallis-et-Futuna', + 'WSM': 'Samoa', + 'XKX': 'Kosovo', + 'YEM': 'Yémen', + 'ZAF': 'Afrique du Sud', + 'ZMB': 'Zambie', + 'ZWE': 'Zimbabwe', + 'NTZ': 'Zone neutre', + 'UNO': 'Fonctionnaire des Nations Unies', + 'UNA': "Fonctionnaire d'une organisation affiliée aux Nations Unies", + 'UNK': 'Représentant des Nations Unies au Kosovo', + 'XXA': 'Apatride Convention 1954', + 'XXB': 'Réfugié Convention 1954', + 'XXC': 'Réfugié autre', + 'XXX': 'Résident Légal de Nationalité Inconnue', + 'D': 'Allemagne', + 'EUE': 'Union Européenne', + 'GBD': "Citoyen Britannique d'Outre-mer (BOTC)", + 'GBN': 'British National (Overseas)', + 'GBO': 'British Overseas Citizen', + 'GBP': 'British Protected Person', + 'GBS': 'British Subject', + 'XBA': 'Banque Africaine de Développement', + 'XIM': "Banque Africaine d'Export–Import", + 'XCC': 'Caribbean Community or one of its emissaries', + 'XCO': 'Common Market for Eastern and Southern Africa', + 'XEC': 'Economic Community of West African States', + 'XPO': 'International Criminal Police Organization', + 'XOM': 'Sovereign Military Order of Malta', + 'RKS': 'Kosovo', + 'WSA': 'World Service Authority World Passport' + } } ## ENGLISH LANGUAGE @@ -183,6 +738,8 @@ english = \ "an issue on Github" : "CNIRevelator crashed because a fatal error occured. View log for more infos and please open an issue on Github", "Would you like to open an issue " "on Github to report this bug ?" : "Would you like to open an issue on Github to report this bug ?", +"Would you like to open the " +"log file ?" : "Would you like to open the log file ?", "Starting..." : "Starting...", "Informations about the current " "document" : "Informations about the current document", @@ -190,7 +747,7 @@ english = \ "Status" : "Status", "Name" : "Name", "Birth date" : "Birth date", -"Issue date" : "Date de délivrance", +"Issue date" : "Issue date", "Expiration date" : "Issue date", "Sex" : "Sex", "Issuing country" : "Issuing country", @@ -207,6 +764,7 @@ english = \ "Open scan..." : "Open scan...", "Quit" : "Quit", "File" : "File", +"Settings" : "Settings", "Keyboard commands" : "Keyboard commands", "Report a bug" : "Report a bug", "About CNIRevelator" : "About CNIRevelator", @@ -267,9 +825,22 @@ english = \ "Paste:\t\t\t\tCtrl-V\n" "Force a new document detection:\tEchap\n", +"CHANGELOG" : "Version 3.1.0 \nMajor update with the following progressions: \n- Cosmetic modifications of the user interface \n- Stabilization of the changes made on the minor version 3.0 : user interface, OCR, VISA A and B, logging\n- Rationalization of the language system\n- Added update channels\n\n" + \ +"Version 3.0.8 final\nCorrection: bug in the update system'\n\n" + \ +"Version 3.0.6 \nMinor update with the following fixes:\n- Change in the appearance of the application launcher\n- Improvements to the interface, including stability\n- Added digital signature of the executable\n" + \ +"Version 3.0.7 final\nMajor update with the following corrections: \n- Redesign of the user interface\n- OCR function integrated into the application with TIFF and JPEG support\n- Corrections of errors on the processing of VISA type A and B, as well as residence permits\n\n" + \ +"Version 3.0.6 \nMinor update with the following fixes:\n- Change in the appearance of the application launcher\n- Improvements to the interface, including stability\n- Added digital signature of the executable\n" + \ +"Version 3.0.5 \n Minor update with the following corrections: \n- Change of executable icon to reflect the major version change accomplished in 3.0\n\n" + \ +"Version 3.0.4 \nMinor update with the following fixes:\n- Fixed a bug affecting the update system" + \ +"Version 3.0.3 \nMinor update with the following corrections: \n- Fixed a bug affecting the changelog\n- Fixed an error with the Delete Back key and Deleted causing a data loss" + \ +"Version 3.0.2 \nMinor update with the following corrections: \n- Change of executable icon\n- Fix of a bug affecting logging\n- Fix of a bug affecting document detection- And other minor modifications\n\n" + \ +"Version 3.0.1 \nMajor update with the following corrections: \n- Renewal of the executable's digital signature- Improvement of the log presentation in case of error\n- Total overhaul of the source code and disobfuscation\n- Reliable HTTPS downloads with checksum\n- New input terminals : a fast (731) and a complete one\n- Improved document detection, possibility of finer choice and the following regressions:\n- Temporary deletion of the OCR reading function. Planned return for a next version", + "Document Review: {}\n\n" : "Document Review: {}\n\n", -"Check sum position {}: Lu {} VS " -"Calculated {} and {}\n" : "Check sum position {}: Lu {} VS Calculated {} and {}\n", +"Checksum position {}: Lu {} VS " +"Calculated {} [facultative]\n" : "Checksum position {}: Read {} VS Calculated {} [facultative]\n", +"Checksum position {}: Lu {} VS " +"Calculated {}\n" : "Checksum position {}: Read {} VS Calculated {}\n", "COMPLIANT" : "COMPLIANT", "IMPROPER" : "IMPROPER", "Installing the updates" : "Installing the updates", @@ -286,9 +857,547 @@ english = \ "Shortcut creation" : "Shortcut creation", "Would you like to create/update " "the shortcut for CNIRevelator on " -"your desktop ?" : "Would you like to create/update the shortcut for CNIRevelator on your desktop ?", +"your desktop ?" : "Would you like to create/update the shortcut for CNIRevelator on your desktop ?", "The file you provided is not " -"found : {}" : "The file you provided is not found : {}" +"found : {}" : "The file you provided is not found : {}", +"Update options" : "Update options", +"Language" : "Language", +"Show Changelog" : "Show the changelog", +"Please choose your language : " : "Please choose your language : ", +"Please choose your update " +"channel : " : "Please choose your update channel : ", +"Passeport" : "Passport", +"Carte-passeport" : "Passport card", +"Titre d'identité/de voyage" : "Identity/travel document", +"Certificat de membre d'équipage" : "Crew member certificate", +"Visa de type A" : "Type A visa", +"Visa de type B" : "Type B visa", +"Carte de séjour" : "Residence permit", +"Pièce d'identité/de voyage" : "Identity/travel document", +"Pièce d'identité FR" : "French Identity card", +"Permis de conduire" : "Driver License", + +"LANDCODE2" : { + "AW": "Aruba", + "AF": "Afghanistan", + "AO": "Angola", + "AI": "Anguilla", + "AL": "Albania", + "AD": "Andorra", + "AE": "United Arab Emirates", + "AR": "Argentina", + "AM": "Armenia", + "AS": "American Samoa", + "QA": "Antarctic", + "TF": 'French Southern and Antarctic Territories', + "AG": 'Antigua and Barbuda', + "TO": "Australia", + "AT": "Austria", + "AZ": "Azerbaidjan", + "BI": "Burundi", + "BE": "Belgium", + "BJ": "Benin", + "BQ": "Caribbean Netherlands", + "BF": "Burkina Faso", + "BD": "Bangladesh", + "BG": "Bulgaria", + "BH": "Bahrain", + "BS": "Bahamas", + "BA": "Bosnia and Herzegovina", + "BL": "Saint-Barthélemy", + "BY": "Belarus", + "BZ": "Belize", + "BM": "Bermuda", + "BO": "Bolivia", + "BR": 'Brazil', + "BB": "Barbados", + "BN": "Brunei", + "BT": "Bhutan", + "BW": "Botswana", + "CF": "Central African Republic", + "CA": "Canada", + "CC": "Cocos Islands", + "CH": "Switzerland", + "CL": "Chile", + "CN": "China", + "CI": "Côte d'Ivoire", + "CM": "Cameroon", + "CD": 'Congo (Democratic Republic)', + "CG": "Congo (Republic)", + "CK": "Cook Islands", + "CO": "Colombia", + "KM": "Comoros", + "CV": "Cape Verde", + "CR": "Costa Rica", + "CU": "Cuba", + "CW": "Curaçao", + "CX": "Christmas Island", + "KY": "Caimans", + "CY": "Cyprus", + "CZ": "Czech Republic", + "DE": "Germany", + "DJ": "Djibouti", + "DM": "Dominique", + "DK": "Denmark", + "DO": 'Dominican Republic', + "DZ": "Algeria", + "EC": "Ecuador", + "EG": "Egypt", + "ER": "Eritrea", + "EH": "Western Sahara", + "ES": "Spain", + "EE": "Estonia", + "AND": "Ethiopia", + "FI": "Finland", + "FJ": "Fiji", + "FK": "Falkland Islands", + "FR": "France", + "FO": "Faroese", + "FM": "Micronesia", + "GA": "Gabon", + "GB": "United Kingdom", + "GE": "Georgia", + "GG": "Guernsey", + "GH": "Ghana", + "GI": "Gibraltar", + "GN": "Guinea", + "GP": "Guadeloupe", + "GM": "Gambia", + "GW": "Guinea-Bissau", + "GQ": "Equatorial Guinea", + "GR": "Greece", + "GD": "Granada", + "GL": "Greenland", + "GT": "Guatemala", + "GF": "Guyana", + "GU": "Guam", + "GY": "Guyana", + "HK": "Hong Kong", + "HN": "Honduras", + "HR": "Croatia", + "HT": "Haiti", + "HU": "Hungary", + "ID": "Indonesia", + "IM": "Isle of Man", + "IN": "India", + "IO": 'British Indian Ocean Territory', + "IE": "Ireland", + "IR": "Iraq", + "IQ": "Iran", + "IS": "Iceland", + "IL": "Israel", + "IT": "Italy", + "JM": "Jamaica", + "I": "Jersey", + "JO": "Jordan", + "JP": "Japan", + "KZ": "Kazakhstan", + "KE": "Kenya", + "KG": "Kyrgyzstan", + "KH": "Cambodia", + "KI": "Kiribati", + "KN": "Saint Kitts and Nevis", + "KR": "South Korea", + "KW": "Kuwait", + "LA": "Laos", + "LB": "Lebanon", + "LR": "Liberia", + "LY": "Libya", + "LC": "Saint Lucia", + "LI": "Liechtenstein", + "LK": "Sri Lanka", + "LS": "Lesotho", + "LT": "Lithuania", + "LU": "Luxembourg", + "LV": "Latvia", + "MO": "Macao", + "MF": "Sint-Maarten", + "MA": "Morocco", + "MC": "Monaco", + "MD": 'Moldavia', + "MG": "Madagascar", + "MV": "Maldives", + "MX": "Mexico", + "MH": "Marshall", + "MK": "Macedonia", + "ML": "Mali", + "MT": "Malta", + "MM": "Burma", + "ME": "Montenegro", + "MN": "Mongolia", + "MP": "Northern Mariana Islands", + "MZ": "Mozambique", + "MR": "Mauritania", + "MS": "Montserrat", + "MQ": "Martinique", + "MU": "Mauritius", + "MW": "Malawi", + "MY": "Malaysia", + "YT": "Mayotte", + "NA": "Namibia", + "NC": "New Caledonia", + "NE": "Niger", + "NF": "Norfolk Island", + "NG": "Nigeria", + "NI": "Nicaragua", + "NU": "Niue", + "NL": 'Netherlands', + "NO": "Norway", + "NP": "Nepal", + "NR": "Nauru", + "NZ": "New Zealand", + "OM": "Oman", + "PK": "Pakistan", + "PA": "Panama", + "NP": "Pitcairn Islands", + "PE": "Peru", + "PH": "Philippines", + "PW": "Palau", + "PG": "Papua New Guinea", + "PL": "Poland", + "PR": "Puerto Rico", + "KP": "North Korea", + "PT": "Portugal", + "PY": "Paraguay", + "PS": "Palestine", + "FP": "French Polynesia", + "QA": "Qatar", + "RE": "Reunion", + "RO": "Romania", + "RU": "Russia", + "RW": "Rwanda", + "SA": "Saudi Arabia", + "SD": "Sudan", + "SN": "Senegal", + "SG": "Singapore", + "GS": "South Georgia and the South Sandwich Islands", + 'SH': 'St Helena, Ascension and Tristan da Cunha', + "SJ": "Svalbard and Jan Mayen Island", + "SB": "Solomon", + "SL": "Sierra Leone", + "SV": "El Salvador", + "SM": "San Marino", + "SO": "Somalia", + "PM": "Saint-Pierre-et-Miquelon", + "RS": "Serbia", + "SS": "South Sudan", + "ST": "Sao Tome and Principe", + "SR": "Suriname", + "SK": "Slovakia", + "SI": "Slovenia", + "SE": "Sweden", + "SZ": "eSwatani", + "SX": "Saint-Martin", + "SC": "Seychelles", + "SY": "Syria", + "TC": "Turks and Caicos Islands", + "TD": "Chad", + "TG": "Togo", + "TH": "Thailand", + "TJ": "Tajikistan", + "TK": "Tokelau", + "TM": "Turkmenistan", + "TL": "East Timor", + "TO": "Tonga", + "TT": "Trinidad and Tobago", + "TN": "Tunisia", + "TR": "Turkey", + "TV": "Tuvalu", + "TW": "Taiwan", + "TZ": "Tanzania", + "UG": "Uganda", + "UA": "Ukraine", + "UY": "Uruguay", + "US": "United States", + "UZ": "Uzbekistan", + 'VA': 'Holy See (Vatican City State)', + 'VC': 'Saint Vincent and the Grenadines', + "EV": "Venezuela", + "VG": "British Virgin Islands", + 'VI': 'Virgin Islands of the United States', + "VN": "Vietnam", + "VU": "Vanuatu", + "WF": "Wallis and Futuna", + 'WS': 'Samoa', + "XK": "Kosovo", + "YE": "Yemen", + "ZA": "South Africa", + "ZM": "Zambia", + "ZW": "Zimbabwe" + }, + +"LANDCODE3" : { + "ABW": "Aruba", + "AFG": "Afghanistan", + "OGM": "Angola", + "AIA": "Anguilla", + 'ALB': 'Albania', + "AND": "Andorra", + "AER": "United Arab Emirates", + "ARG": "Argentina", + "ARM": "Armenia", + "ASM": "American Samoa", + "ATA": "Antarctica", + 'ATF': 'French Southern and Antarctic Lands', + "ATG": "Antigua and Barbuda", + "AUS": "Australia", + "AUT": "Austria", + "AZE": "Azerbaidjan", + "BDI": "Burundi", + "BEL": "Belgium", + "BEN": "Benin", + 'BES': 'Caribbean Netherlands', + "BFA": "Burkina Faso", + "BGD": "Bangladesh", + "BGR": "Bulgaria", + "BHR": "Bahrain", + "BHS": "Bahamas", + "BIH": "Bosnia and Herzegovina", + "BLM": "Saint-Barthélemy", + "BLR": "Belarus", + "BLZ": "Belize", + "BMU": "Bermuda", + "BOL": "Bolivia", + "BRA": "Brazil", + 'BRB': 'Barbados', + "BRN": "Brunei", + "BTN": "Bhutan", + "BWA": "Botswana", + 'CAF': 'Central African Republic', + 'CAN': 'Canada', + "CCK": "Cocos Islands", + "CHE": "Switzerland", + "CHL": "Chile", + "CHN": "China", + 'CIV': "Côte d'Ivoire", + "CMR": "Cameroon", + 'COD': 'Congo (Democratic Republic)', + "COG": "Congo (Republic)", + "COK": "Cook Islands", + "COL": "Colombia", + "COM": "Comoros", + 'CPV': 'Cape Verde', + "CRI": "Costa Rica", + "CUB": "Cuba", + "CUW": "Curaçao", + "CXR": "Christmas Island", + "CYM": "Caimans", + "CYP": "Cyprus", + "CZE": "Czech Republic", + "DEU": "Germany", + "DJI": "Djibouti", + "DMA": "Dominique", + "DNK": "Denmark", + "DOM": "Dominican Republic", + "DZA": "Algeria", + 'ECU': 'Ecuador', + "EGY": "Egypt", + "ERI": "Eritrea", + 'ESH': 'Western Sahara', + "ESP": "Spain", + "EST": "Estonia", + "ETH": "Ethiopia", + "FIN": "Finland", + "FJI": "Fiji", + "FLK": "Falkland Islands", + "FRA": "France", + "FRO": "Faroese", + "WSF": "Micronesia", + "ATM": "Gabon", + "GBR": "United Kingdom", + "GEO": "Georgia", + "GGY": "Guernsey", + "GHA": "Ghana", + "GIB": "Gibraltar", + "GIN": "Guinea", + "GLP": "Guadeloupe", + "GMB": "Gambia", + "GNB": "Guinea-Bissau", + "GNQ": "Equatorial Guinea", + "GRC": "Greece", + "DSO": "Granada", + "GRL": "Greenland", + "GTM": "Guatemala", + 'GUF': 'Guyana', + "GUM": "Guam", + "GUY": "Guyana", + "HKG": "Hong Kong", + "HND": "Honduras", + "HRV": "Croatia", + "HTI": "Haiti", + "HUN": "Hungary", + "IDN": "Indonesia", + "IMN": "Isle of Man", + "IND": "India", + 'IOT': 'British Indian Ocean Territory', + "IRL": "Ireland", + "IRN": "Iraq", + "IRQ": "Iran", + "ISL": "Iceland", + "SRI": "Israel", + "ITA": "Italy", + "JAM": "Jamaica", + "JEY": "Jersey", + "JOR": "Jordan", + 'JPN': 'Japan', + "KAZ": "Kazakhstan", + "KEN": "Kenya", + "KGZ": "Kyrgyzstan", + "KHM": "Cambodia", + "KIR": "Kiribati", + "KNA": "Saint Kitts and Nevis", + "KOR": "South Korea", + "KWT": "Kuwait", + "LAO": "Laos", + "LBN": "Lebanon", + "LBR": "Liberia", + "LBY": "Libya", + "LCA": "Saint Lucia", + "LEL": "Liechtenstein", + "LKA": "Sri Lanka", + "LSO": "Lesotho", + "LTU": "Lithuania", + "LUX": "Luxembourg", + "LVA": "Latvia", + "MAC": "Macao", + "MAF": "Sint-Maarten", + "MAR": "Morocco", + "MCO": "Monaco", + "MDA": "Moldavia", + "MDG": "Madagascar", + "MDV": "Maldives", + "MEX": "Mexico", + "MHL": "Marshall", + "MKD": "Macedonia", + "MLI": "Mali", + "MLT": "Malta", + "MMR": "Burma", + "MNE": "Montenegro", + "MNG": "Mongolia", + 'MNP': 'Northern Mariana Islands', + "MOZ": "Mozambique", + "MRT": "Mauritania", + "MSR": "Montserrat", + "MTQ": "Martinique", + "MUS": "Mauritius", + "MWI": "Malawi", + "MYS": "Malaysia", + "MYT": "Mayotte", + "NAM": "Namibia", + "NCL": "New Caledonia", + "NER": "Niger", + "NFK": "Norfolk Island", + "NGA": "Nigeria", + "NIC": "Nicaragua", + "NIU": "Niue", + 'NLD': 'Netherlands', + "NOR": "Norway", + "NPL": "Nepal", + "NRU": "Nauru", + "NZL": "New Zealand", + "OMN": "Oman", + "PAK": "Pakistan", + "PAN": "Panama", + "PCN": "Pitcairn Islands", + "PER": "Peru", + "PHL": "Philippines", + "PLW": "Palau", + "PNG": "Papua New Guinea", + "POL": "Poland", + "PRI": "Puerto Rico", + "PRK": "North Korea", + "PRT": "Portugal", + "PRY": "Paraguay", + "PES": "Palestine", + "PYF": "French Polynesia", + "QAT": "Qatar", + "REU": "Reunion", + "ROU": "Romania", + "RUS": "Russia", + "RWA": "Rwanda", + "UAA": "Saudi Arabia", + "SDN": "Sudan", + "SEN": "Senegal", + "SGP": "Singapore", + 'SGS': 'South Georgia and the South Sandwich Islands', + "SHN": "St Helena, Ascension and Tristan da Cunha", + "SJM": "Svalbard and Jan Mayen Island", + "SLB": "Solomon", + "SLE": "Sierra Leone", + "SLV": "El Salvador", + "SMR": "San Marino", + "SOM": "Somalia", + "SPM": "Saint-Pierre-et-Miquelon", + "SRB": "Serbia", + "SSD": "South Sudan", + "PTS": "Sao Tome and Principe", + "SUR": "Suriname", + "SVK": "Slovakia", + "SVN": "Slovenia", + "SWE": "Sweden", + "SWZ": "eSwatani", + "SXM": "Saint-Martin", + "SYC": "Seychelles", + "SYR": "Syria", + "TCA": "Turks and Caicos Islands", + "TCD": "Chad", + "TGO": "Togo", + "THA": "Thailand", + "TJK": "Tajikistan", + "TKL": "Tokelau", + "TKM": "Turkmenistan", + "TLS": "East Timor", + "TON": "Tonga", + 'TTO': 'Trinidad and Tobago', + "TUN": "Tunisia", + "TUR": "Turkey", + "TUV": "Tuvalu", + "TWN": "Taiwan", + "TZA": "Tanzania", + "UGA": "Uganda", + "UKR": "Ukraine", + "URY": "Uruguay", + "USA": "United States", + "UZB": "Uzbekistan", + 'VAT': 'Holy See (Vatican City State)', + 'VCT': 'Saint Vincent and the Grenadines', + "VEN": "Venezuela", + 'VGB': 'British Virgin Islands', + 'VIR': 'Virgin Islands of the United States', + "VNM": "Vietnam", + "STV": "Vanuatu", + "WLF": "Wallis and Futuna", + "WSM": "Samoa", + "XKX": "Kosovo", + "YEM": "Yemen", + "ZAF": "South Africa", + "ZMB": "Zambia", + "ZWE": "Zimbabwe", + 'NTZ': 'Neutral Zone', + 'UNO': 'United Nations official', + 'UNA': "Staff member of a United Nations-affiliated organization", + 'UNK': 'United Nations Representative in Kosovo', + 'XXA': 'Stateless Person 1954 Convention', + "XXB": "Refugee Convention 1954", + "XXC": "Other refugee", + 'XXX': 'Legal Resident of Unknown Nationality', + 'D' : 'Germany', + "EUE": "European Union", + "GBD": "British Overseas Citizen (BOTC)", + "GBN": "British National (Overseas)", + "GBO": "British Overseas Citizen", + 'GBP': 'British Protected Person', + "GBS": "British Subject", + 'XBA': 'African Development Bank', + 'XIM': "African Export Import Bank", + 'XCC':' Caribbean Community or one of its emissaries', + 'XCO': 'Common Market for Eastern and Southern Africa', + 'XEC': 'Economic Community of West African States', + 'XPO': 'International Criminal Police Organization', + 'XOM': 'Sovereign Military Order of Malta', + "RKS": "Kosovo", + "WSA": "World Service Authority World Passport" + } } ## MAIN DICT @@ -296,4 +1405,58 @@ all = \ { "fr" : french, "en" : english -} \ No newline at end of file +} + + +## Functions + +def readLang(): + + if os.path.isfile(globs.CNIRLangFile): + with open(globs.CNIRLangFile, 'r') as (configFile): + try: + # Reading it + globs.CNIRlang = configFile.read() + except Exception as e: + ihm.crashCNIR() + raise IOError(str(e)) + else: + # Recreating the url file + try: + os.mkdir(globs.CNIRFolder + '\\config') + except: + pass + + with open(globs.CNIRLangFile, 'w') as (configFile): + try: + # Writing it + configFile.write(globs.CNIRlang) + except Exception as e: + ihm.crashCNIR() + raise IOError(str(e)) + +def updateLang(choice): + + if os.path.isfile(globs.CNIRLangFile): + with open(globs.CNIRLangFile, 'w') as (configFile): + try: + # Writing it + globs.CNIRlang = choice + configFile.write(choice) + except Exception as e: + ihm.crashCNIR() + raise IOError(str(e)) + else: + # Recreating the url file + try: + os.mkdir(globs.CNIRFolder + '\\config') + except: + pass + + with open(globs.CNIRLangFile, 'w') as (configFile): + try: + # Writing it + configFile.write(globs.CNIRlang) + except Exception as e: + ihm.crashCNIR() + raise IOError(str(e)) \ No newline at end of file diff --git a/src/main.py b/src/main.py index 18ec34d..648f2ea 100644 --- a/src/main.py +++ b/src/main.py @@ -31,6 +31,7 @@ from tkinter import filedialog from tkinter import ttk import threading from datetime import datetime +from importlib import reload import re import cv2 import PIL.Image, PIL.ImageTk @@ -50,11 +51,16 @@ logfile = logger.logCur class mainWindow(Tk): + ## App Pattern + def __init__(self): Tk.__init__(self) self.initialize() def initialize(self): + """ + Initializes the main window + """ self.mrzChar = "" self.mrzDecided = False self.Tags = [] @@ -71,12 +77,13 @@ class mainWindow(Tk): logfile.printdbg('Launching main window with resolution' + str(ws) + 'x' + str(hs)) # Configuring the size of each part of the window - self.grid_columnconfigure(0, weight=1, minsize=(ws / 2 * 0.3333333333333333)) - self.grid_columnconfigure(1, weight=1, minsize=(ws / 2 * 0.3333333333333333)) + self.grid_columnconfigure(0, minsize=(ws / 2 * 0.3333333333333333)) + self.grid_columnconfigure(1, minsize=(ws / 2 * 0.3333333333333333)) self.grid_columnconfigure(2, weight=1, minsize=(ws / 2 * 0.3333333333333333)) - self.grid_rowconfigure(0, weight=1, minsize=(hs / 2 * 0.5)) - self.grid_rowconfigure(1, weight=1, minsize=(hs / 2 * 0.10)) - self.grid_rowconfigure(2, weight=1, minsize=(hs / 2 * 0.35)) + self.grid_rowconfigure(0, minsize=(hs / 2 * 0.5)) + self.grid_rowconfigure(1, minsize=(hs / 2 * 0.10)) + self.grid_rowconfigure(2, minsize=(hs / 2 * 0.35)) + self.grid_rowconfigure(3, minsize=10) # Prepare the data sections self.lecteur_ci = ttk.Labelframe(self, text=lang.all[globs.CNIRlang]["Informations about the current document"]) @@ -91,9 +98,14 @@ class mainWindow(Tk): self.lecteur_ci.grid_rowconfigure(3, weight=1) self.lecteur_ci.grid_rowconfigure(4, weight=1) self.lecteur_ci.grid_rowconfigure(5, weight=1) + + # And what about the status bar ? + self.statusbar = ihm.StatusBar(self) + self.statusbar.grid(row=3, columnspan=3, sticky="NSEW") # Fill the data sections ttk.Label((self.lecteur_ci), text='{} : '.format(lang.all[globs.CNIRlang]["Status"])).grid(column=0, row=0, padx=5, pady=5) + self.statusbar.set(lang.all[globs.CNIRlang]["IDLE"]) self.STATUStxt = ttk.Label((self.lecteur_ci), text=lang.all[globs.CNIRlang]["IDLE"], font=("TkDefaultFont", 13, "bold"), foreground="orange", anchor=CENTER) self.STATUStxt.grid(column=1, row=0, padx=5, pady=5) ttk.Label((self.lecteur_ci), text='{} : '.format(lang.all[globs.CNIRlang]["Name"])).grid(column=0, row=1, padx=5, pady=5) @@ -319,14 +331,21 @@ class mainWindow(Tk): menu1.add_separator() menu1.add_command(label=lang.all[globs.CNIRlang]["Quit"], command=(self.destroy)) menubar.add_cascade(label=lang.all[globs.CNIRlang]["File"], menu=menu1) + menu2 = Menu(menubar, tearoff=0) + menu2.add_command(label=lang.all[globs.CNIRlang]["Update options"], command=(self.updateSet)) + menu2.add_command(label=lang.all[globs.CNIRlang]["Show Changelog"], command=(self.showChangeLog)) + menu2.add_separator() + menu2.add_command(label=lang.all[globs.CNIRlang]["Language"], command=(self.languageSet)) + menubar.add_cascade(label=lang.all[globs.CNIRlang]["Settings"], menu=menu2) menu3 = Menu(menubar, tearoff=0) menu3.add_command(label=lang.all[globs.CNIRlang]["Keyboard commands"], command=(self.helpbox)) menu3.add_command(label=lang.all[globs.CNIRlang]["Report a bug"], command=(self.openIssuePage)) menu3.add_separator() menu3.add_command(label=lang.all[globs.CNIRlang]["About CNIRevelator"], command=(self.infobox)) menubar.add_cascade(label=lang.all[globs.CNIRlang]["Help"], menu=menu3) + menubar.add_command(label="<|>", command=(self.panelResize)) self.config(menu=menubar) - + # The title self.wm_title(globs.CNIRName) @@ -337,19 +356,21 @@ class mainWindow(Tk): self.iconbitmap('id-card.ico') # Make this window resizable and set her size - self.resizable(width=True, height=True) + self.resizable(0, 0) self.update() - w = int(self.winfo_reqwidth()) - h = int(self.winfo_reqheight()) - ws = self.winfo_screenwidth() - hs = self.winfo_screenheight() - x = (ws - w)/2 - y = (hs - h)/2 - self.geometry('%dx%d+%d+%d' % (w, h, x, y)) + self.w = int(self.winfo_reqwidth()) + self.h = int(self.winfo_reqheight()) + self.ws = self.winfo_screenwidth() + self.hs = self.winfo_screenheight() + self.x = (self.ws - self.w)/2 + self.y = (self.hs - self.h)/2 + self.geometry('%dx%d+%d+%d' % (self.w, self.h, self.x, self.y)) self.update() self.deiconify() self.attributes("-topmost", 1) - self.minsize(self.winfo_width(), self.winfo_height()) + self.maxsize(self.w, self.h) + self.minsize(int(2.15 * (self.ws / 2 * 0.3333333333333333)), self.h) + self.currentw = self.w # Set image self.imageViewer.image = None @@ -370,13 +391,13 @@ class mainWindow(Tk): if globs.CNIROpenFile: self.after_idle(lambda : self.openScanFile(sys.argv[1])) - def statusUpdate(self, image=None, setplace=False): - if image: - self.imageViewer.image = image - self.imageViewer.ZONE.itemconfigure(self.STATUSimg, image=(self.imageViewer.image)) - self.imageViewer.ZONE.configure(scrollregion=self.imageViewer.ZONE.bbox("all")) - + + ## OCR related functions + def rectangleSelectScan(self, event): + """ + Realises the selection of the MRZ to make OCR possible + """ if self.imageViewer.image: canvas = event.widget #print("Get coordinates : [{}, {}], for [{}, {}]".format(canvas.canvasx(event.x), canvas.canvasy(event.y), event.x, event.y)) @@ -390,6 +411,9 @@ class mainWindow(Tk): self.imageViewer.ZONE.delete(self.select) def goOCRDetection(self): + """ + Realises the OCR detection and get the text in self.mrzChar (and prints it) + """ if self.imageViewer.image: cv_img = cv2.imreadmulti(self.imageViewer.imagePath)[1][self.imageViewer.pagenumber] cv_img = cv2.cvtColor(cv_img, cv2.COLOR_BGR2RGB) @@ -466,8 +490,12 @@ class mainWindow(Tk): logfile.printerr("Tesseract error : {}".format(e)) showerror(lang.all[globs.CNIRlang]["OCR module error"], (lang.all[globs.CNIRlang]["The Tesseract module encountered a problem: {}"].format(e)), parent=self) - + ## Regex and document detection + control related functions + def stringValidation(self, keysym): + """ + Analysis of the already typed document + """ # analysis # If we must decide the type of the document if not self.mrzDecided: @@ -484,10 +512,12 @@ class mainWindow(Tk): self.wait_window(invite) self.logOnTerm(lang.all[globs.CNIRlang]["Document detected: {}\n"].format(candidates[invite.choice][2])) + self.statusbar.set(candidates[invite.choice][2]) self.mrzDecided = candidates[invite.choice] elif len(candidates) == 1: self.logOnTerm(lang.all[globs.CNIRlang]["Document detected: {}\n"].format(candidates[0][2])) + self.statusbar.set(candidates[0][2]) self.mrzDecided = candidates[0] else: # corrects some problems @@ -574,11 +604,13 @@ class mainWindow(Tk): self.wait_window(invite) - self.logOnTerm(lang.all[globs.CNIRlang]["Document detected again: {} \ n"].format(candidates[invite.choice][2])) + self.logOnTerm(lang.all[globs.CNIRlang]["Document detected again: {}\n"].format(candidates[invite.choice][2])) + self.statusbar.set(candidates[invite.choice][2]) self.mrzDecided = candidates[invite.choice] elif len(candidates) == 1: - self.logOnTerm(lang.all[globs.CNIRlang]["Document detected again: {} \ n"].format(candidates[0][2])) + self.logOnTerm(lang.all[globs.CNIRlang]["Document detected again: {}\n"].format(candidates[0][2])) + self.statusbar.set(candidates[0][2]) self.mrzDecided = candidates[0] return "break" @@ -630,30 +662,128 @@ class mainWindow(Tk): char = self.speed731text.get() self.speedResultPrint(str(mrz.computeControlSum(char))) return "break" + + def computeSigma(self): + """ + Launch the checksum computation, infos validation and print/display the results + """ + # the regex + regex = re.compile("[^A-Z0-9<]") + code = re.sub(regex, '', self.mrzChar) + self.compliance = True + allSums = mrz.computeAllControlSum(self.mrzDecided, code)["ctrlSumList"] + #print("Code : _{}_ | Sums : {}".format(code, allSums)) + + self.termtext.tag_remove("conforme", "1.0", "end") + self.termtext.tag_remove("nonconforme", "1.0", "end") + + self.clearTerm() + self.logOnTerm(lang.all[globs.CNIRlang]["Document Review: {}\n\n"].format(self.mrzDecided[2])) + + for sum in allSums: + x = sum[1] // len(self.mrzDecided[0][0]) +1 + y = sum[1] % len(self.mrzDecided[0][0]) + #print("index : {}.{}".format(x,y)) + #print("{} == {}".format(code[sum[1]], sum[2])) + + if sum[3]: + self.logOnTerm(lang.all[globs.CNIRlang]["Checksum position {}: Lu {} VS Calculated {} [facultative]\n"].format(sum[1], code[sum[1]], sum[2])) + else: + self.logOnTerm(lang.all[globs.CNIRlang]["Checksum position {}: Lu {} VS Calculated {}\n"].format(sum[1], code[sum[1]], sum[2])) + + # if sum is facultative or if sum is ok + try: + if sum[3] or int(code[sum[1]]) == int(sum[2]): + self.termtext.tag_add("conforme", "{}.{}".format(x,y), "{}.{}".format(x,y+1)) + self.termtext.tag_configure("conforme", background="green", foreground="white") + else: + self.termtext.tag_add("nonconforme", "{}.{}".format(x,y), "{}.{}".format(x,y+1)) + self.termtext.tag_configure("nonconforme", background="red", relief='raised', foreground="white") + self.compliance = False + except ValueError: + self.termtext.tag_add("nonconforme", "{}.{}".format(x,y), "{}.{}".format(x,y+1)) + self.termtext.tag_configure("nonconforme", background="red", relief='raised', foreground="white") + self.compliance = False + + # get the infos + docInfos = mrz.getDocInfos(self.mrzDecided, code) + #print(docInfos) + # display the infos + for key in [ e for e in docInfos ]: + #print(docInfos[key]) + if key in ["CODE", "CTRL", "CTRLF"]: + continue + if not docInfos[key] == False: + self.infoList[key]['text'] = docInfos[key] + self.infoList[key]['background'] = self['background'] + self.infoList[key]['foreground'] = "black" + else: + self.infoList[key]['background'] = "red" + self.infoList[key]['foreground'] = "white" + self.infoList[key]['text'] = "NC" + self.compliance = False + + if self.compliance == True: + self.STATUStxt["text"] = lang.all[globs.CNIRlang]["COMPLIANT"] + self.STATUStxt["foreground"] = "green" + self.statusbar.set(lang.all[globs.CNIRlang]["COMPLIANT"]) + else: + self.STATUStxt["text"] = lang.all[globs.CNIRlang]["IMPROPER"] + self.STATUStxt["foreground"] = "red" + self.statusbar.set(lang.all[globs.CNIRlang]["IMPROPER"]) + + ## Print functions + def logOnTerm(self, text): + """ + Writes on the monitor + """ self.monlog['state'] = 'normal' self.monlog.insert('end', text) self.monlog['state'] = 'disabled' self.monlog.yview(END) def clearTerm(self): + """ + Clears the monitor + """ self.monlog['state'] = 'normal' self.monlog.delete('1.0', 'end') self.monlog['state'] = 'disabled' self.monlog.yview(END) def speedResultPrint(self, text): + """ + Prints a result in the quick entry terminal + """ self.speedResult['state'] = 'normal' self.speedResult.delete("1.0", 'end') self.speedResult.insert('end', text) self.speedResult['state'] = 'disabled' + ## Document display related functions + + def DisplayUpdate(self, image=None, setplace=False): + """ + Reload the displayer to display the image or not + """ + if image: + self.imageViewer.image = image + self.imageViewer.ZONE.itemconfigure(self.STATUSimg, image=(self.imageViewer.image)) + self.imageViewer.ZONE.configure(scrollregion=self.imageViewer.ZONE.bbox("all")) + def goPageChoice(self, event): + """ + Change the current viewed page of the multipage tiff if needed + """ self.imageViewer.pagenumber = int(self.toolbar.pageChooser.get()) - 1 self.resizeScan() def openingScan(self): + """ + Open the scan, ask its path and displays it + """ path = '' path = filedialog.askopenfilename(parent=self, title=lang.all[globs.CNIRlang]["Open a scan of document..."], filetypes=(('TIF files', '*.tif'), ('TIF files', '*.tiff'), @@ -662,7 +792,9 @@ class mainWindow(Tk): self.openScanFile(path) def openScanFile(self, path): - + """ + Open an image file at path to display it on the displayer + """ # Check if the file is valid if ( path[-3:] != 'jpg' and path[-3:] != 'tif' @@ -702,7 +834,7 @@ class mainWindow(Tk): # Use PIL (Pillow) to convert the NumPy ndarray to a PhotoImage photo = PIL.ImageTk.PhotoImage(image = PIL.Image.fromarray(cv_img)) - self.statusUpdate(photo) + self.DisplayUpdate(photo) def zoomInScan50(self, quantity = 50): if self.imageViewer.image: @@ -763,6 +895,9 @@ class mainWindow(Tk): self.resizeScan() def negativeScan(self): + """ + Invert the bits to make a negative of the scan (and highlight the contrasts) + """ if self.imageViewer.image: # Load an image using OpenCV cv_img = cv2.imreadmulti(self.imageViewer.imagePath)[1][self.imageViewer.pagenumber] @@ -777,6 +912,9 @@ class mainWindow(Tk): self.resizeScan(cv_img) def resizeScan(self, cv_img = None): + """ + Reloads the image according to settings + """ if self.imageViewer.image: try: if not hasattr(cv_img, 'shape'): @@ -806,7 +944,7 @@ class mainWindow(Tk): cv_img = cv2.resize(cv_img, dim, interpolation = cv2.INTER_AREA) # Use PIL (Pillow) to convert the NumPy ndarray to a PhotoImage photo = PIL.ImageTk.PhotoImage(image = PIL.Image.fromarray(cv_img)) - self.statusUpdate( photo) + self.DisplayUpdate( photo) except Exception as e: logfile.printerr("Error with opencv : {}".format(e)) ihm.crashCNIR() @@ -824,19 +962,26 @@ class mainWindow(Tk): height, width, channels_no = cv_img.shape # Use PIL (Pillow) to convert the NumPy ndarray to a PhotoImage photo = PIL.ImageTk.PhotoImage(image = PIL.Image.fromarray(cv_img)) - self.statusUpdate(photo) + self.DisplayUpdate(photo) except Exception as e: logfile.printerr("Critical error with opencv : ".format(e)) ihm.crashCNIR() showerror(lang.all[globs.CNIRlang]["OpenCV error (image processing)"], lang.all[globs.CNIRlang]["A critical error has occurred in the OpenCV image processing manager used by CNIRevelator, the application will reset itself"]) self.initialize() + ## IHM and user interface related functions + def newEntry(self): + """ + Reinits the IHM and invite + """ self.initialize() self.logOnTerm('\n\n{}\n'.format(lang.all[globs.CNIRlang]["Please type a MRZ or open a scan"])) def infobox(self): - + """ + Shows the About dialog + """ Tk().withdraw() showinfo( lang.all[globs.CNIRlang]["About CNIRevelator"], @@ -846,6 +991,9 @@ class mainWindow(Tk): parent=self) def helpbox(self): + """ + Shows the keyboard help summary + """ Tk().withdraw() showinfo( lang.all[globs.CNIRlang]["Keyboard commands"], @@ -856,79 +1004,55 @@ class mainWindow(Tk): parent=self) def openIssuePage(self): + """ + Opens the Github Issue Repository page + """ webbrowser.open_new("https://github.com/neox95/CNIRevelator/issues") - def computeSigma(self): + def showChangeLog(self): + changelogWin = ihm.ChangelogDialog(self, ('{} : CNIRevelator {}\n\n{}'.format(lang.all[globs.CNIRlang]["Program version"], globs.verstring_full, lang.all[globs.CNIRlang]["CHANGELOG"]))) + changelogWin.transient(self) + changelogWin.grab_set() + changelogWin.focus_force() + self.wait_window(changelogWin) + + def updateSet(self): """ - Launch the checksum computation, infos validation and display the results + Update Settings """ - # the regex - regex = re.compile("[^A-Z0-9<]") - code = re.sub(regex, '', self.mrzChar) - self.compliance = True - - allSums = mrz.computeAllControlSum(self.mrzDecided, code)["ctrlSumList"] - #print("Code : _{}_ | Sums : {}".format(code, allSums)) - - self.termtext.tag_remove("conforme", "1.0", "end") - self.termtext.tag_remove("nonconforme", "1.0", "end") - - self.clearTerm() - self.logOnTerm(lang.all[globs.CNIRlang]["Document Review: {}\n\n"].format(self.mrzDecided[2])) - - for sum in allSums: - x = sum[1] // len(self.mrzDecided[0][0]) +1 - y = sum[1] % len(self.mrzDecided[0][0]) - #print("index : {}.{}".format(x,y)) - #print("{} == {}".format(code[sum[1]], sum[2])) - - self.logOnTerm(lang.all[globs.CNIRlang]["Check sum position {}: Lu {} VS Calculated {} and {}\n"].format(sum[1], code[sum[1]], sum[2], sum[3])) - - # if sum is facultative or if sum is ok - try: - if sum[3] or int(code[sum[1]]) == int(sum[2]): - self.termtext.tag_add("conforme", "{}.{}".format(x,y), "{}.{}".format(x,y+1)) - self.termtext.tag_configure("conforme", background="green", foreground="white") - else: - self.termtext.tag_add("nonconforme", "{}.{}".format(x,y), "{}.{}".format(x,y+1)) - self.termtext.tag_configure("nonconforme", background="red", relief='raised', foreground="white") - self.compliance = False - except ValueError: - self.termtext.tag_add("nonconforme", "{}.{}".format(x,y), "{}.{}".format(x,y+1)) - self.termtext.tag_configure("nonconforme", background="red", relief='raised', foreground="white") - self.compliance = False - - # get the infos - docInfos = mrz.getDocInfos(self.mrzDecided, code) - #print(docInfos) - # display the infos - for key in [ e for e in docInfos ]: - #print(docInfos[key]) - if key in ["CODE", "CTRL", "CTRLF"]: - continue - if not docInfos[key] == False: - self.infoList[key]['text'] = docInfos[key] - self.infoList[key]['background'] = self['background'] - self.infoList[key]['foreground'] = "black" - else: - self.infoList[key]['background'] = "red" - self.infoList[key]['foreground'] = "white" - self.infoList[key]['text'] = "NC" - self.compliance = False - - if self.compliance == True: - self.STATUStxt["text"] = lang.all[globs.CNIRlang]["COMPLIANT"] - self.STATUStxt["foreground"] = "green" + changeupdateWin = ihm.updateSetDialog(self) + changeupdateWin.transient(self) + changeupdateWin.grab_set() + changeupdateWin.focus_force() + self.wait_window(changeupdateWin) + + def languageSet(self): + """ + Lang Settings + """ + changelangWin = ihm.langDialog(self) + changelangWin.transient(self) + changelangWin.grab_set() + changelangWin.focus_force() + self.wait_window(changelangWin) + + global mrz + mrz = reload(mrz) + + self.initialize() + + def panelResize(self): + """ + Shows or hides the panel + """ + if self.currentw > int(2.15 * (self.ws / 2 * 0.3333333333333333)): + self.currentw = int(2.15 * (self.ws / 2 * 0.3333333333333333)) + self.geometry('%dx%d+%d+%d' % (self.currentw, self.h, self.x, self.y)) + self.update() else: - self.STATUStxt["text"] = lang.all[globs.CNIRlang]["IMPROPER"] - self.STATUStxt["foreground"] = "red" - - return - - - - - + self.currentw = self.w + self.geometry('%dx%d+%d+%d' % (self.currentw, self.h, self.x, self.y)) + self.update() diff --git a/src/mrz.py b/src/mrz.py index 1ce646d..672eba7 100644 --- a/src/mrz.py +++ b/src/mrz.py @@ -28,6 +28,7 @@ import re import datetime import logger # logger.py +import globs # globs.py import lang # lang.py ## SEX CODES @@ -35,527 +36,9 @@ sexcode = {'M':'Homme', 'F':'Femme', 'X':'Non spécifié'} ## COUNTRY CODES -landcode2 = { - 'AW': 'Aruba', - 'AF': 'Afghanistan', - 'AO': 'Angola', - 'AI': 'Anguilla', - 'AL': 'Albanie', - 'AD': 'Andorre', - 'AE': 'Emirats arabes unis', - 'AR': 'Argentine', - 'AM': 'Arménie', - 'AS': 'Samoa américaines', - 'AQ': 'Antarctique', - 'TF': 'Terres australes et antarctiques françaises', - 'AG': 'Antigua-et-Barbuda', - 'AU': 'Australie', - 'AT': 'Autriche', - 'AZ': 'Azerbaidjan', - 'BI': 'Burundi', - 'BE': 'Belgique', - 'BJ': 'Benin', - 'BQ': 'Pays-Bas caribéens', - 'BF': 'Burkina Faso', - 'BD': 'Bangladesh', - 'BG': 'Bulgarie', - 'BH': 'Bahrein', - 'BS': 'Bahamas', - 'BA': 'Bosnie-Herzegovine', - 'BL': 'Saint-Barthélemy', - 'BY': 'Bielorussie', - 'BZ': 'Belize', - 'BM': 'Bermudes', - 'BO': 'Bolivie', - 'BR': 'Brésil', - 'BB': 'Barbade', - 'BN': 'Brunei', - 'BT': 'Bhoutan', - 'BW': 'Botswana', - 'CF': 'République Centrafricaine', - 'CA': 'Canada', - 'CC': 'Îles Cocos', - 'CH': 'Suisse', - 'CL': 'Chili', - 'CN': 'Chine', - 'CI': "Côte d'Ivoire", - 'CM': 'Cameroun', - 'CD': 'Congo (République démocratique)', - 'CG': 'Congo (République)', - 'CK': 'Îles Cook', - 'CO': 'Colombie', - 'KM': 'Comores', - 'CV': 'Cap-Vert', - 'CR': 'Costa Rica', - 'CU': 'Cuba', - 'CW': 'Curaçao', - 'CX': 'Île Christmas', - 'KY': 'Caimans', - 'CY': 'Chypre', - 'CZ': 'Tchéquie', - 'DE': 'Allemagne', - 'DJ': 'Djibouti', - 'DM': 'Dominique', - 'DK': 'Danemark', - 'DO': 'République dominicaine', - 'DZ': 'Algérie', - 'EC': 'Equateur', - 'EG': 'Egypte', - 'ER': 'Erythrée', - 'EH': 'Sahara occidental', - 'ES': 'Espagne', - 'EE': 'Estonie', - 'ET': 'Ethiopie', - 'FI': 'Finlande', - 'FJ': 'Fidji', - 'FK': 'Îles Malouines', - 'FR': 'France', - 'FO': 'Féroé', - 'FM': 'Micronésie', - 'GA': 'Gabon', - 'GB': 'Royaume-Uni', - 'GE': 'Géorgie', - 'GG': 'Guernesey', - 'GH': 'Ghana', - 'GI': 'Gibraltar', - 'GN': 'Guinée', - 'GP': 'Guadeloupe', - 'GM': 'Gambie', - 'GW': 'Guinée-Bissau', - 'GQ': 'Guinée équatoriale', - 'GR': 'Grèce', - 'GD': 'Grenade', - 'GL': 'Groenland', - 'GT': 'Guatemala', - 'GF': 'Guyane', - 'GU': 'Guam', - 'GY': 'Guyana', - 'HK': 'Hong Kong', - 'HN': 'Honduras', - 'HR': 'Croatie', - 'HT': 'Haïti', - 'HU': 'Hongrie', - 'ID': 'Indonésie', - 'IM': 'Île de Man', - 'IN': 'Inde', - 'IO': "Territoire britannique de l'océan Indien", - 'IE': 'Irlande', - 'IR': 'Irak', - 'IQ': 'Iran', - 'IS': 'Islande', - 'IL': 'Israël', - 'IT': 'Italie', - 'JM': 'Jamaïque', - 'JE': 'Jersey', - 'JO': 'Jordanie', - 'JP': 'Japon', - 'KZ': 'Kazakhstan', - 'KE': 'Kenya', - 'KG': 'Kirghizistan', - 'KH': 'Cambodge', - 'KI': 'Kiribati', - 'KN': 'Saint-Christophe-et-Niévès', - 'KR': 'Corée du Sud', - 'KW': 'Koweït', - 'LA': 'Laos', - 'LB': 'Liban', - 'LR': 'Liberia', - 'LY': 'Libye', - 'LC': 'Sainte-Lucie', - 'LI': 'Liechtenstein', - 'LK': 'Sri Lanka', - 'LS': 'Lesotho', - 'LT': 'Lituanie', - 'LU': 'Luxembourg', - 'LV': 'Lettonie', - 'MO': 'Macao', - 'MF': 'Sint-Maarten', - 'MA': 'Maroc', - 'MC': 'Monaco', - 'MD': 'Moldavie', - 'MG': 'Madagascar', - 'MV': 'Maldives', - 'MX': 'Mexique', - 'MH': 'Marshall', - 'MK': 'Macedoine', - 'ML': 'Mali', - 'MT': 'Malte', - 'MM': 'Birmanie', - 'ME': 'Monténégro', - 'MN': 'Mongolie', - 'MP': 'Îles Mariannes du Nord', - 'MZ': 'Mozambique', - 'MR': 'Mauritanie', - 'MS': 'Montserrat', - 'MQ': 'Martinique', - 'MU': 'Maurice', - 'MW': 'Malawi', - 'MY': 'Malaisie', - 'YT': 'Mayotte', - 'NA': 'Namibie', - 'NC': 'Nouvelle-Calédonie', - 'NE': 'Niger', - 'NF': 'Île Norfolk', - 'NG': 'Nigeria', - 'NI': 'Nicaragua', - 'NU': 'Niue', - 'NL': 'Pays-Bas', - 'NO': 'Norvège', - 'NP': 'Nepal', - 'NR': 'Nauru', - 'NZ': 'Nouvelle-Zélande', - 'OM': 'Oman', - 'PK': 'Pakistan', - 'PA': 'Panama', - 'PN': 'Îles Pitcairn', - 'PE': 'Pérou', - 'PH': 'Philippines', - 'PW': 'Palaos', - 'PG': 'Papouasie-Nouvelle-Guinée', - 'PL': 'Pologne', - 'PR': 'Porto Rico', - 'KP': 'Corée du Nord', - 'PT': 'Portugal', - 'PY': 'Paraguay', - 'PS': 'Palestine', - 'PF': 'Polynésie française', - 'QA': 'Qatar', - 'RE': 'Réunion', - 'RO': 'Roumanie', - 'RU': 'Russie', - 'RW': 'Rwanda', - 'SA': 'Arabie saoudite', - 'SD': 'Soudan', - 'SN': 'Sénégal', - 'SG': 'Singapour', - 'GS': 'Georgie du Sud-et-les iles Sandwich du Sud', - 'SH': 'Sainte-Hélène, Ascension et Tristan da Cunha', - 'SJ': 'Svalbard et île Jan Mayen', - 'SB': 'Salomon', - 'SL': 'Sierra Leone', - 'SV': 'Salvador', - 'SM': 'Saint-Marin', - 'SO': 'Somalie', - 'PM': 'Saint-Pierre-et-Miquelon', - 'RS': 'Serbie', - 'SS': 'Soudan du Sud', - 'ST': 'Sao Tomé-et-Principe', - 'SR': 'Suriname', - 'SK': 'Slovaquie', - 'SI': 'Slovénie', - 'SE': 'Suède', - 'SZ': 'eSwatani', - 'SX': 'Saint-Martin ', - 'SC': 'Seychelles', - 'SY': 'Syrie', - 'TC': 'Îles Turques-et-Caïques', - 'TD': 'Tchad', - 'TG': 'Togo', - 'TH': 'Thaïlande', - 'TJ': 'Tadjikistan', - 'TK': 'Tokelau', - 'TM': 'Turkmenistan', - 'TL': 'Timor oriental', - 'TO': 'Tonga', - 'TT': 'Trinité-et-Tobago', - 'TN': 'Tunisie', - 'TR': 'Turquie', - 'TV': 'Tuvalu', - 'TW': 'Taiwan', - 'TZ': 'Tanzanie', - 'UG': 'Ouganda', - 'UA': 'Ukraine', - 'UY': 'Uruguay', - 'US': 'Etats-Unis', - 'UZ': 'Ouzbékistan', - 'VA': 'Saint-Siège (État de la Cité du Vatican)', - 'VC': 'Saint-Vincent-et-les-Grenadines', - 'VE': 'Venezuela', - 'VG': 'Îles Vierges britanniques', - 'VI': 'Îles Vierges des États-Unis', - 'VN': 'Viêt Nam', - 'VU': 'Vanuatu', - 'WF': 'Wallis-et-Futuna', - 'WS': 'Samoa', - 'XK': 'Kosovo', - 'YE': 'Yémen', - 'ZA': 'Afrique du Sud', - 'ZM': 'Zambie', - 'ZW': 'Zimbabwe' - } +landcode2 = lang.all[globs.CNIRlang]["LANDCODE2"] -landcode3 = { - 'ABW': 'Aruba', - 'AFG': 'Afghanistan', - 'AGO': 'Angola', - 'AIA': 'Anguilla', - 'ALB': 'Albanie', - 'AND': 'Andorre', - 'ARE': 'Emirats arabes unis', - 'ARG': 'Argentine', - 'ARM': 'Arménie', - 'ASM': 'Samoa américaines', - 'ATA': 'Antarctique', - 'ATF': 'Terres australes et antarctiques françaises', - 'ATG': 'Antigua-et-Barbuda', - 'AUS': 'Australie', - 'AUT': 'Autriche', - 'AZE': 'Azerbaidjan', - 'BDI': 'Burundi', - 'BEL': 'Belgique', - 'BEN': 'Benin', - 'BES': 'Pays-Bas caribéens', - 'BFA': 'Burkina Faso', - 'BGD': 'Bangladesh', - 'BGR': 'Bulgarie', - 'BHR': 'Bahrein', - 'BHS': 'Bahamas', - 'BIH': 'Bosnie-Herzegovine', - 'BLM': 'Saint-Barthélemy', - 'BLR': 'Bielorussie', - 'BLZ': 'Belize', - 'BMU': 'Bermudes', - 'BOL': 'Bolivie', - 'BRA': 'Brésil', - 'BRB': 'Barbade', - 'BRN': 'Brunei', - 'BTN': 'Bhoutan', - 'BWA': 'Botswana', - 'CAF': 'République Centrafricaine', - 'CAN': 'Canada', - 'CCK': 'Îles Cocos', - 'CHE': 'Suisse', - 'CHL': 'Chili', - 'CHN': 'Chine', - 'CIV': "Côte d'Ivoire", - 'CMR': 'Cameroun', - 'COD': 'Congo (République démocratique)', - 'COG': 'Congo (République)', - 'COK': 'Îles Cook', - 'COL': 'Colombie', - 'COM': 'Comores', - 'CPV': 'Cap-Vert', - 'CRI': 'Costa Rica', - 'CUB': 'Cuba', - 'CUW': 'Curaçao', - 'CXR': 'Île Christmas', - 'CYM': 'Caimans', - 'CYP': 'Chypre', - 'CZE': 'Tchéquie', - 'DEU': 'Allemagne', - 'DJI': 'Djibouti', - 'DMA': 'Dominique', - 'DNK': 'Danemark', - 'DOM': 'République dominicaine', - 'DZA': 'Algérie', - 'ECU': 'Equateur', - 'EGY': 'Egypte', - 'ERI': 'Erythrée', - 'ESH': 'Sahara occidental', - 'ESP': 'Espagne', - 'EST': 'Estonie', - 'ETH': 'Ethiopie', - 'FIN': 'Finlande', - 'FJI': 'Fidji', - 'FLK': 'Îles Malouines', - 'FRA': 'France', - 'FRO': 'Féroé', - 'FSM': 'Micronésie', - 'GAB': 'Gabon', - 'GBR': 'Royaume-Uni', - 'GEO': 'Géorgie', - 'GGY': 'Guernesey', - 'GHA': 'Ghana', - 'GIB': 'Gibraltar', - 'GIN': 'Guinée', - 'GLP': 'Guadeloupe', - 'GMB': 'Gambie', - 'GNB': 'Guinée-Bissau', - 'GNQ': 'Guinée équatoriale', - 'GRC': 'Grèce', - 'GRD': 'Grenade', - 'GRL': 'Groenland', - 'GTM': 'Guatemala', - 'GUF': 'Guyane', - 'GUM': 'Guam', - 'GUY': 'Guyana', - 'HKG': 'Hong Kong', - 'HND': 'Honduras', - 'HRV': 'Croatie', - 'HTI': 'Haïti', - 'HUN': 'Hongrie', - 'IDN': 'Indonésie', - 'IMN': 'Île de Man', - 'IND': 'Inde', - 'IOT': "Territoire britannique de l'océan Indien", - 'IRL': 'Irlande', - 'IRN': 'Irak', - 'IRQ': 'Iran', - 'ISL': 'Islande', - 'ISR': 'Israël', - 'ITA': 'Italie', - 'JAM': 'Jamaïque', - 'JEY': 'Jersey', - 'JOR': 'Jordanie', - 'JPN': 'Japon', - 'KAZ': 'Kazakhstan', - 'KEN': 'Kenya', - 'KGZ': 'Kirghizistan', - 'KHM': 'Cambodge', - 'KIR': 'Kiribati', - 'KNA': 'Saint-Christophe-et-Niévès', - 'KOR': 'Corée du Sud', - 'KWT': 'Koweït', - 'LAO': 'Laos', - 'LBN': 'Liban', - 'LBR': 'Liberia', - 'LBY': 'Libye', - 'LCA': 'Sainte-Lucie', - 'LIE': 'Liechtenstein', - 'LKA': 'Sri Lanka', - 'LSO': 'Lesotho', - 'LTU': 'Lituanie', - 'LUX': 'Luxembourg', - 'LVA': 'Lettonie', - 'MAC': 'Macao', - 'MAF': 'Sint-Maarten', - 'MAR': 'Maroc', - 'MCO': 'Monaco', - 'MDA': 'Moldavie', - 'MDG': 'Madagascar', - 'MDV': 'Maldives', - 'MEX': 'Mexique', - 'MHL': 'Marshall', - 'MKD': 'Macedoine', - 'MLI': 'Mali', - 'MLT': 'Malte', - 'MMR': 'Birmanie', - 'MNE': 'Monténégro', - 'MNG': 'Mongolie', - 'MNP': 'Îles Mariannes du Nord', - 'MOZ': 'Mozambique', - 'MRT': 'Mauritanie', - 'MSR': 'Montserrat', - 'MTQ': 'Martinique', - 'MUS': 'Maurice', - 'MWI': 'Malawi', - 'MYS': 'Malaisie', - 'MYT': 'Mayotte', - 'NAM': 'Namibie', - 'NCL': 'Nouvelle-Calédonie', - 'NER': 'Niger', - 'NFK': 'Île Norfolk', - 'NGA': 'Nigeria', - 'NIC': 'Nicaragua', - 'NIU': 'Niue', - 'NLD': 'Pays-Bas', - 'NOR': 'Norvège', - 'NPL': 'Nepal', - 'NRU': 'Nauru', - 'NZL': 'Nouvelle-Zélande', - 'OMN': 'Oman', - 'PAK': 'Pakistan', - 'PAN': 'Panama', - 'PCN': 'Îles Pitcairn', - 'PER': 'Pérou', - 'PHL': 'Philippines', - 'PLW': 'Palaos', - 'PNG': 'Papouasie-Nouvelle-Guinée', - 'POL': 'Pologne', - 'PRI': 'Porto Rico', - 'PRK': 'Corée du Nord', - 'PRT': 'Portugal', - 'PRY': 'Paraguay', - 'PSE': 'Palestine', - 'PYF': 'Polynésie française', - 'QAT': 'Qatar', - 'REU': 'Réunion', - 'ROU': 'Roumanie', - 'RUS': 'Russie', - 'RWA': 'Rwanda', - 'SAU': 'Arabie saoudite', - 'SDN': 'Soudan', - 'SEN': 'Sénégal', - 'SGP': 'Singapour', - 'SGS': 'Georgie du Sud-et-les iles Sandwich du Sud', - 'SHN': 'Sainte-Hélène, Ascension et Tristan da Cunha', - 'SJM': 'Svalbard et île Jan Mayen', - 'SLB': 'Salomon', - 'SLE': 'Sierra Leone', - 'SLV': 'Salvador', - 'SMR': 'Saint-Marin', - 'SOM': 'Somalie', - 'SPM': 'Saint-Pierre-et-Miquelon', - 'SRB': 'Serbie', - 'SSD': 'Soudan du Sud', - 'STP': 'Sao Tomé-et-Principe', - 'SUR': 'Suriname', - 'SVK': 'Slovaquie', - 'SVN': 'Slovénie', - 'SWE': 'Suède', - 'SWZ': 'eSwatani', - 'SXM': 'Saint-Martin ', - 'SYC': 'Seychelles', - 'SYR': 'Syrie', - 'TCA': 'Îles Turques-et-Caïques', - 'TCD': 'Tchad', - 'TGO': 'Togo', - 'THA': 'Thaïlande', - 'TJK': 'Tadjikistan', - 'TKL': 'Tokelau', - 'TKM': 'Turkmenistan', - 'TLS': 'Timor oriental', - 'TON': 'Tonga', - 'TTO': 'Trinité-et-Tobago', - 'TUN': 'Tunisie', - 'TUR': 'Turquie', - 'TUV': 'Tuvalu', - 'TWN': 'Taiwan', - 'TZA': 'Tanzanie', - 'UGA': 'Ouganda', - 'UKR': 'Ukraine', - 'URY': 'Uruguay', - 'USA': 'Etats-Unis', - 'UZB': 'Ouzbékistan', - 'VAT': 'Saint-Siège (État de la Cité du Vatican)', - 'VCT': 'Saint-Vincent-et-les-Grenadines', - 'VEN': 'Venezuela', - 'VGB': 'Îles Vierges britanniques', - 'VIR': 'Îles Vierges des États-Unis', - 'VNM': 'Viêt Nam', - 'VUT': 'Vanuatu', - 'WLF': 'Wallis-et-Futuna', - 'WSM': 'Samoa', - 'XKX': 'Kosovo', - 'YEM': 'Yémen', - 'ZAF': 'Afrique du Sud', - 'ZMB': 'Zambie', - 'ZWE': 'Zimbabwe', - 'NTZ': 'Zone neutre', - 'UNO': 'Fonctionnaire des Nations Unies', - 'UNA': "Fonctionnaire d'une organisation affiliée aux Nations Unies", - 'UNK': 'Représentant des Nations Unies au Kosovo', - 'XXA': 'Apatride Convention 1954', - 'XXB': 'Réfugié Convention 1954', - 'XXC': 'Réfugié autre', - 'XXX': 'Résident Légal de Nationalité Inconnue', - 'D': 'Allemagne', - 'EUE': 'Union Européenne', - 'GBD': "Citoyen Britannique d'Outre-mer (BOTC)", - 'GBN': 'British National (Overseas)', - 'GBO': 'British Overseas Citizen', - 'GBP': 'British Protected Person', - 'GBS': 'British Subject', - 'XBA': 'Banque Africaine de Développement', - 'XIM': "Banque Africaine d'Export–Import", - 'XCC': 'Caribbean Community or one of its emissaries', - 'XCO': 'Common Market for Eastern and Southern Africa', - 'XEC': 'Economic Community of West African States', - 'XPO': 'International Criminal Police Organization', - 'XOM': 'Sovereign Military Order of Malta', - 'RKS': 'Kosovo', - 'WSA': 'World Service Authority World Passport' -} +landcode3 = lang.all[globs.CNIRlang]["LANDCODE3"] ## DOCUMENTS TYPES @@ -577,7 +60,7 @@ P = [ "D": ["1", "CTRLF", "[0-9]", "C"], "E": ["1", "CTRL", "[0-9]", "4578ABCD"] }, - "Passeport" + lang.all[globs.CNIRlang]["Passeport"] ] IP = [ @@ -597,7 +80,7 @@ IP = [ "C": ["11", "FACULT", ".+"], "D": ["1", "CTRL", "[0-9]", "345679AC"] }, - "Carte-passeport" + lang.all[globs.CNIRlang]["Carte-passeport"] ] I_ = [ @@ -617,7 +100,7 @@ I_ = [ "C": ["11", "FACULT", ".+"], "D": ["1", "CTRL", "[0-9]", "345679AC"] }, - "Titre d'identité/de voyage" + lang.all[globs.CNIRlang]["Titre d'identité/de voyage"] ] AC = [ @@ -638,7 +121,7 @@ AC = [ "C": ["11", "FACULT", ".+"], "D": ["1", "CTRL", "[0-9]","345679AC"] }, - "Certificat de membre d'équipage" + lang.all[globs.CNIRlang]["Certificat de membre d'équipage"] ] VA = [ @@ -657,7 +140,7 @@ VA = [ "B": ["1", "CTRL", "[0-9]", "A"], "C": ["16", "FACULT", ".+"] }, - "Visa de type A" + lang.all[globs.CNIRlang]["Visa de type A"] ] VB = [ @@ -676,7 +159,7 @@ VB = [ "B": ["1", "CTRL", "[0-9]", "A"], "C": ["8", "FACULT", ".+"] }, - "Visa de type B" + lang.all[globs.CNIRlang]["Visa de type B"] ] TSF = [ @@ -695,7 +178,7 @@ TSF = [ "B": ["1", "CTRL", "[0-9]", "A"], "C": ["8", "FACULT", ".+"] }, - "Carte de séjour" + lang.all[globs.CNIRlang]["Carte de séjour"] ] I__ = [ @@ -715,7 +198,7 @@ I__ = [ "C": ["7", "FACULT", ".+"], "D": ["1", "CTRL", "[0-9]", "4578ABC"] }, - "Pièce d'identité/de voyage" + lang.all[globs.CNIRlang]["Pièce d'identité/de voyage"] ] IDFR = [ @@ -735,7 +218,7 @@ IDFR = [ "C": ["1", "SEX", "[A-Z]"], "D": ["1", "CTRL", "[0-9]", "123456789ABCE"] }, - "Pièce d'identité FR" + lang.all[globs.CNIRlang]["Pièce d'identité FR"] ] DL = [ @@ -749,7 +232,7 @@ DL = [ "6": ["8", "NOM", "([A-Z]|<)+"], "7": ["1", "CTRL", "[0-9]", "123456"] }, - "Permis de conduire" + lang.all[globs.CNIRlang]["Permis de conduire"] ] TYPES = [IDFR, I__, VB, VA, AC, I_, IP, P, DL, TSF] @@ -1011,6 +494,14 @@ def getDocInfos(doc, code): res["INDIC"] += value except KeyError: res["INDIC"] = value + + # Sex + elif field[0] == 'SEX': + if not value in "MF": + res[field[0]] = False + else: + res[field[0]] = value + # All other cases else: if value != "": diff --git a/src/updater.py b/src/updater.py index 8f8e15f..e8a6a75 100644 --- a/src/updater.py +++ b/src/updater.py @@ -80,6 +80,14 @@ def exitProcess(arg): if process.pid == os.getpid(): process.terminate() sys.exit(arg) + +def updateChannel(choice): + if choice == "Beta": + with open(globs.CNIRUrlConfig, 'w') as (configFile): + configFile.write("{}\n0\n0".format(globs.CNIRBetaURL)) + else: + with open(globs.CNIRUrlConfig, 'w') as (configFile): + configFile.write("{}\n0\n0".format(globs.CNIRDefaultURL)) def getLatestVersion(credentials): """ @@ -114,7 +122,7 @@ def getLatestVersion(credentials): except: pass with open(globs.CNIRUrlConfig, 'w') as (configFile): - configFile.write("https://raw.githubusercontent.com/neox95/CNIRevelator/master/VERSIONS.LST\n0\n0") + configFile.write("{}\n0\n0".format(globs.CNIRDefaultURL)) # Getting the list of versions of the software logfile.printdbg('Retrieving the software versions')