diff options
| author | Debulois Quentin <quentin.debulois@gmail.com> | 2020-09-20 20:57:56 +0200 |
|---|---|---|
| committer | Debulois Quentin <quentin.debulois@gmail.com> | 2020-09-20 20:57:56 +0200 |
| commit | 5248604f682789c736beada767405b4b14a44d86 (patch) | |
| tree | 8172cd8c93ef0edb3c0dd711932e90280c128274 /Redim/config.py | |
| parent | 79e091c7c3796e6a4fd35ffb5b54b9e626954caa (diff) | |
Ajout des commentaires + pylint 10/10, hell yeah B)
Diffstat (limited to 'Redim/config.py')
| -rw-r--r-- | Redim/config.py | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/Redim/config.py b/Redim/config.py index c6a6070..b0ea2ee 100644 --- a/Redim/config.py +++ b/Redim/config.py @@ -1,3 +1,7 @@ +"""Contient la gestion de l'enregistrement des choix de l'utilisateur +ainsi que la gestion de la supression des fichiers anciennement décompressés +par pyinstaller""" + from sys import platform from os import mkdir, listdir, environ, getenv from os.path import isdir, join, getmtime, isfile @@ -7,8 +11,9 @@ import json class Config(): + """Gestion de l'enregistrement des choix de l'utilisateur""" def __init__(self): - self._base_configuration = { + self.base_configuration = { "dimensions": [[500, 350], [900, 900]], "background": [255, 255, 255], "format_final": ".webp", @@ -34,21 +39,33 @@ class Config(): self.nettoyage_pyinstaller() def sauvegarde(self, configuration): + """Création du dossier de sauvegarde pour le fichier de configuration + et enregistrement des préférence de l'utilisateur + """ if not isdir(self.json_path): mkdir(self.json_path) - with open(join(self.json_path, "config"), "w") as f: - json.dump(configuration, f) + with open(join(self.json_path, "config"), "w") as file_config: + json.dump(configuration, file_config) print("\n[-] Modification enregistree.") def lecture(self): + """Return le contenu du fichier de configuration, si aucun fichier + n'éxiste, création d'un avec les valeurs par défaut + """ if not isfile(join(self.json_path, "config")): - self.sauvegarde(self._base_configuration) - return self._base_configuration - with open(join(self.json_path, "config"), "r") as f: - configuration = json.load(f) + self.sauvegarde(self.base_configuration) + return self.base_configuration + with open(join(self.json_path, "config"), "r") as file_config: + configuration = json.load(file_config) return configuration - def nettoyage_pyinstaller(self): + @staticmethod + def nettoyage_pyinstaller(): + """Supression des fichiers anciennement décompressés par pyinstaller""" for i in listdir(environ["TMP"]): - if i.startswith("_MEI") and isdir(i) and (int(getmtime(join(environ["TMP"], i))) < (time() - 86400)): + if i.startswith("_MEI")\ + and isdir(i)\ + and ( + int(getmtime(join(environ["TMP"], i))) + < (time() - 86400)): rmtree(join(environ["TMP"], i)) |
