🔖 chore(SettingManager.py): add version attribute to SettingManager class and update config.yml version if needed

The SettingManager class now has a version attribute to keep track of the version of the configuration file. If the version in the configuration file is different from the version in the SettingManager class, the version in the configuration file is updated to match the version in the SettingManager class. This ensures that the configuration file is always up-to-date with the latest version of the application.
This commit is contained in:
Djalim Simaila 2023-05-02 10:33:56 +02:00
parent bb6f078ec2
commit fc525a0878

View File

@ -19,11 +19,15 @@ class SettingManager:
:ivar instance: The instance of the class
"""
instance = None
version = "1.1.1"
def __init__(self):
try:
with open('config.yml', 'r') as f:
self.settings = load(f.read(), Loader=Loader)
self.settings = load(f.read(), Loader=Loader)
if self.settings['version'] != self.version:
self.settings['version'] = self.version
self.save()
except FileNotFoundError:
self.settings = {}
self.createInitialSettings()
@ -48,7 +52,7 @@ class SettingManager:
f.write(dump(self.settings, Dumper=Dumper))
def createInitialSettings(self):
self.settings['version'] = "1.0.0"
self.settings['version'] = self.version
self.settings['name'] = 'Analyse Morphologique'
self.settings['authors'] = 'Alexis Doghmane <alexis@doghmane.fr>, Djalim Simaila <djalim.simaila@inrae.fr>'
self.settings['description'] = 'Analyse Morphologique'