From 456403ba1b84e44ccf4618c7c68a157377c84b8a Mon Sep 17 00:00:00 2001 From: Roland Haroutiounian Date: Fri, 17 Jul 2015 10:56:00 +0200 Subject: [PATCH] =?UTF-8?q?[Model]=20mise=20en=20conformit=C3=A9=20pep8=20?= =?UTF-8?q?et=20pylint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EditorialModel/model.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/EditorialModel/model.py b/EditorialModel/model.py index e6a2b88..2ac5552 100644 --- a/EditorialModel/model.py +++ b/EditorialModel/model.py @@ -5,16 +5,24 @@ from EditorialModel.classes import EmClass + class Model(object): + componentClass = EmClass + ## Constructor + # + # @param backend unknown: A backend object instanciated from one of the classes in the backend module def __init__(self, backend): self.backend = backend + self.uids = {} self.load() + ## Loads the structure of the Editorial Model + # + # Gets all the objects contained in that structure and creates a list indexed by their uids def load(self): data = self.backend.load() - self.uids = {} for uid, component in data.items(): cls_name = 'component' + component['component'] cls = getattr(Model, cls_name) @@ -22,15 +30,17 @@ class Model(object): component['uid'] = uid self.uids[uid] = cls(component) - # save data using the current backend + ## Saves data using the current backend def save(self): return self.backend.save() - # change the current backend + ## Changes the current backend + # + # @param backend unknown: A backend object def set_backend(self, backend): self.backend = backend - # return a list of all EmClass of the model - def classes(): - classes = [component for component in self.data.uids if isinstance(component, EmClass)] + ## Returns a list of all the EmClass objects of the model + def classes(self): + classes = [component for _, component in self.uids if isinstance(component, EmClass)] return classes