1
0
Fork 0
mirror of https://github.com/yweber/lodel2.git synced 2026-01-15 19:22:14 +01:00

[Model] mise en conformité pep8 et pylint

This commit is contained in:
Roland Haroutiounian 2015-07-17 10:56:00 +02:00
commit 456403ba1b

View file

@ -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