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:
parent
ca65d11a5a
commit
456403ba1b
1 changed files with 16 additions and 6 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue