1
0
forked from ScoDoc/ScoDoc

Lecture liste départements.

This commit is contained in:
Emmanuel Viennet 2021-07-07 10:01:55 +02:00
parent 3a56364bbd
commit 26ccb0bbb8

View File

@ -48,19 +48,28 @@ class ScoDeptDescription:
self.db_uri = db_uri 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): def __init__(self):
_ = self.get_dept_descriptions()
def get_dept_descriptions(self):
filenames = glob.glob(Config.SCODOC_VAR_DIR + "/config/depts/*.cfg") filenames = glob.glob(Config.SCODOC_VAR_DIR + "/config/depts/*.cfg")
descr_list = [ScoDeptDescription(f) for f in filenames] 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): def get_dept_db_uri(self, dept_id):
"DB URI for this 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): def get_dept_ids(self):
"get (sorted) dept ids" "get (sorted) dept ids"
return sorted(self.dept_descriptions.keys()) return sorted(self.get_dept_descriptions().keys())
def get_db_uri(self): def get_db_uri(self):
""" """