From fc525a0878244fa8f4222a66827031c51a8eaaa2 Mon Sep 17 00:00:00 2001 From: Djalim Simaila Date: Tue, 2 May 2023 10:33:56 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=96=20chore(SettingManager.py):=20add?= =?UTF-8?q?=20version=20attribute=20to=20SettingManager=20class=20and=20up?= =?UTF-8?q?date=20config.yml=20version=20if=20needed=20The=20SettingManage?= =?UTF-8?q?r=20class=20now=20has=20a=20version=20attribute=20to=20keep=20t?= =?UTF-8?q?rack=20of=20the=20version=20of=20the=20configuration=20file.=20?= =?UTF-8?q?If=20the=20version=20in=20the=20configuration=20file=20is=20dif?= =?UTF-8?q?ferent=20from=20the=20version=20in=20the=20SettingManager=20cla?= =?UTF-8?q?ss,=20the=20version=20in=20the=20configuration=20file=20is=20up?= =?UTF-8?q?dated=20to=20match=20the=20version=20in=20the=20SettingManager?= =?UTF-8?q?=20class.=20This=20ensures=20that=20the=20configuration=20file?= =?UTF-8?q?=20is=20always=20up-to-date=20with=20the=20latest=20version=20o?= =?UTF-8?q?f=20the=20application.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/settings/SettingManager.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/utils/settings/SettingManager.py b/utils/settings/SettingManager.py index 5d4d83a..1dd93d4 100644 --- a/utils/settings/SettingManager.py +++ b/utils/settings/SettingManager.py @@ -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 , Djalim Simaila ' self.settings['description'] = 'Analyse Morphologique'