From 26ccb0bbb8d83ddf90d369e1a5df49bfc21f662e Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Wed, 7 Jul 2021 10:01:55 +0200 Subject: [PATCH] =?UTF-8?q?Lecture=20liste=20d=C3=A9partements.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scodoc_manager.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/scodoc_manager.py b/scodoc_manager.py index 403bb3ea4..3bf8d4da0 100644 --- a/scodoc_manager.py +++ b/scodoc_manager.py @@ -48,19 +48,28 @@ class ScoDeptDescription: self.db_uri = db_uri -class ScoDocManager: +class ScoDocManager(object): + """Gestion de la liste des départements + En ScoDoc8, c'est très simple: on intègre tous les départements pour + lesquels un fichier de config est présent. + """ + def __init__(self): + _ = self.get_dept_descriptions() + + def get_dept_descriptions(self): filenames = glob.glob(Config.SCODOC_VAR_DIR + "/config/depts/*.cfg") descr_list = [ScoDeptDescription(f) for f in filenames] - self.dept_descriptions = {d.dept_id: d for d in descr_list} + self._dept_descriptions = {d.dept_id: d for d in descr_list} + return self._dept_descriptions def get_dept_db_uri(self, dept_id): "DB URI for this dept id" - return self.dept_descriptions[dept_id].db_uri + return self._dept_descriptions[dept_id].db_uri def get_dept_ids(self): "get (sorted) dept ids" - return sorted(self.dept_descriptions.keys()) + return sorted(self.get_dept_descriptions().keys()) def get_db_uri(self): """