summaryrefslogtreecommitdiff
path: root/Redim/config.py
diff options
context:
space:
mode:
Diffstat (limited to 'Redim/config.py')
-rw-r--r--Redim/config.py35
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))