diff --git a/assets/version.json b/assets/version.json index 8ddb5ee..5701725 100644 --- a/assets/version.json +++ b/assets/version.json @@ -1 +1 @@ -{"version": "Stable V-0.0.3"} \ No newline at end of file +{"version": "Stable V-0.0.4"} \ No newline at end of file diff --git a/help.py b/help.py index 81dba78..96d86ec 100644 --- a/help.py +++ b/help.py @@ -3,8 +3,12 @@ def help_funtion(): print("") print("Avec la commande 'help' vous avez acées a toutes les informations pour utiliser le logiciel ! ") print("") - print("creat => Crée une fiche de jouer") - print("sr => Recherche la fiche d'un joueur") - print("edit => Edition d'un fichier d'un joueur") - print("exit => Ferme le programe") + print("Recherche and Fiche Players") + print("creat [player]: Crée une fiche de jouer") + print("sr [player]: Recherche la fiche d'un joueur") + print("edit [player]: Edition d'un fichier d'un joueur") + print("") + print("Général Programe") + print("exit: Ferme le programe") + print("version: numéros de version du logiciel") print("") \ No newline at end of file diff --git a/main.py b/main.py index 52b19ff..1f275b8 100644 --- a/main.py +++ b/main.py @@ -10,9 +10,14 @@ import version today = date.today() +class bcolors: + OK = '\033[92m' #GREEN + WARNING = '\033[93m' #YELLOW + FAIL = '\033[91m' #RED + RESET = '\033[0m' #RESET COLOR try: - with open('./assets/config.json') as mon_fichier: + with open('assets/config.json') as mon_fichier: data = json.load(mon_fichier) except (FileNotFoundError): print("Absence de fichier de configration sur le logiciel") @@ -34,32 +39,46 @@ try: while i : + a = input("Que voulez-vous faire {0} ? : ".format(data['name'])) + a = a.split() - if (a == "creat"): - req = input("Qu'elle est son nom ? ") - prenom = input("Qu'elle est son prenom ? ") - age = input("Qu'elle est son age ? ") - ville = input("Qu'elle sa ville ? (Si pas disponible (n)) ") - function = input("Qu'elle est sa fonction ? (doc, citoyen, cherif, autre) ") - sr.creatplayer(req, age, prenom, ville, function) + if (a[0] == "creat"): + try: + req = a[1] + prenom = input("Qu'elle est son prenom ? ") + age = input("Qu'elle est son age ? ") + ville = input("Qu'elle sa ville ? (Si pas disponible (n)) ") + function = input("Qu'elle est sa fonction ? (doc, citoyen, cherif, autre) ") + sr.creatplayer(req, age, prenom, ville, function) + except: + print("Manque information player") - if (a == "sr"): - req = input("Qu'elle personne ? ") - sr.player(req) + if (a[0] == "sr"): + try: + req = a[1] + sr.player(req) + except: + print("Manque information player") - if (a == "edit"): - req = input("Qu'elle personne ? ") - information = input("votre nouvelle information ? ") - sr.editplayer(req, information) + if (a[0] == "edit"): + try: + req = a[1] + information = input("votre nouvelle information ? ") + sr.editplayer(req, information) + except: + print("Manque information player") - if (a == 'help'): + if (a[0] == 'help'): help.help_funtion() + + if (a[0] == 'version'): + version.numero_version() - if (a == "exit"): + if (a[0] == "exit"): quit() -except (KeyboardInterrupt): +except (KeyboardInterrupt): print(" Fermeture du logiciel") \ No newline at end of file diff --git a/version.py b/version.py index 4cda868..22424ba 100644 --- a/version.py +++ b/version.py @@ -2,21 +2,37 @@ from urllib import request, parse import json import os +import webbrowser + +class bcolors: + OK = '\033[92m' #GREEN + WARNING = '\033[93m' #YELLOW + FAIL = '\033[91m' #RED + RESET = '\033[0m' #RESET COLOR url = "https://api.github.com/repos/alexcaussades/Follow-RP/releases" with open('./assets/version.json') as mon_fichier: data = json.load(mon_fichier) - -def versions_serach(): res = request.urlopen(url).read() page = res.decode("utf8") y = json.loads(page) +def versions_serach(): + if(y[0]['name'] != data["version"]): print("____________________________________") - print("Une nouvelle version est disponible sur https://github.com/alexcaussades/Follow-RP/releases") - print("") - print("Description de la mise à jour") - print("\n" + y[0]['body']) - print("____________________________________") \ No newline at end of file + print(bcolors.FAIL + "Une nouvelle version est disponible 🔽:"+ bcolors.RESET ) + print("⏩ Taper la commande : version") + +def numero_version(): + print("Vous êtes sur la version : {0}".format(data["version"])) + if(y[0]['name'] != data["version"]): + a = input("mettre à jour ? (y/n)") + + if(a == "y"): + repro = request.urlopen(y[0]["url"]).read() + info = repro.decode("utf8") + res = json.loads(info) + webbrowser.open(y[0]["html_url"]) +