|
@@ -9,8 +9,7 @@ from lodel.utils.mlstring import MlString
|
9
|
9
|
|
10
|
10
|
##@brief Saves a model in a xml file
|
11
|
11
|
# @param model EditorialModel : the model to save
|
12
|
|
-# @param filename str|None : if None display on stdout
|
13
|
|
-
|
|
12
|
+# @param filename str|None : if None display on stdout else writes in the file filename
|
14
|
13
|
def save(model, **kwargs):
|
15
|
14
|
Em = etree.Element("editorial_model")
|
16
|
15
|
em_name = etree.SubElement(Em, 'name')
|
|
@@ -99,7 +98,6 @@ def write_emfield_xml(etree, elem, uid, name, help_text, group, datahandler_name
|
99
|
98
|
# @param name : the name of the group
|
100
|
99
|
# @param help_text : explanations of the EmGroup
|
101
|
100
|
# @param requires : a list of the group's uids whose this group depends
|
102
|
|
-
|
103
|
101
|
def write_emgroup_xml(etree, elem, uid, name, help_text, requires, components):
|
104
|
102
|
emgroup = etree.SubElement(elem, 'group')
|
105
|
103
|
emgroup_uid = etree.SubElement(emgroup, 'uid')
|
|
@@ -144,7 +142,6 @@ def write_emgroup_xml(etree, elem, uid, name, help_text, requires, components):
|
144
|
142
|
# @param parents : a list of EmClass uids
|
145
|
143
|
# @param abstract : a boolean
|
146
|
144
|
# @param pure_abstract : a boolean
|
147
|
|
-
|
148
|
145
|
def write_emclass_xml(etree, elem, uid, name, help_text, group, fields, parents, abstract = False, pure_abstract = False):
|
149
|
146
|
emclass = etree.SubElement(elem, 'class')
|
150
|
147
|
emclass_uid = etree.SubElement(emclass, 'uid')
|
|
@@ -178,7 +175,7 @@ def write_emclass_xml(etree, elem, uid, name, help_text, group, fields, parents,
|
178
|
175
|
|
179
|
176
|
##@brief Loads a model from a xml file
|
180
|
177
|
# @param model EditorialModel : the model to load
|
181
|
|
-
|
|
178
|
+# @return a new EditorialModel object
|
182
|
179
|
def load(**kwargs):
|
183
|
180
|
|
184
|
181
|
Em = etree.parse(kwargs['filename'])
|
|
@@ -198,8 +195,12 @@ def load(**kwargs):
|
198
|
195
|
if grp.uid not in model.all_groups():
|
199
|
196
|
grp = model.add_group(grp)
|
200
|
197
|
|
201
|
|
- return model;
|
|
198
|
+ return model
|
202
|
199
|
|
|
200
|
+##@brief Creates a EmClass from a xml description
|
|
201
|
+# @param elem : the element which represents the EmClass
|
|
202
|
+# @param model : the model which will contain the new class
|
|
203
|
+# @return a new EmClass object
|
203
|
204
|
def load_class_xml(model, elem):
|
204
|
205
|
uid = elem.find('uid').text
|
205
|
206
|
if elem.find('display_name').text is None:
|
|
@@ -251,7 +252,10 @@ def load_class_xml(model, elem):
|
251
|
252
|
|
252
|
253
|
return emclass
|
253
|
254
|
|
254
|
|
-
|
|
255
|
+##@brief Creates a EmField from a xml description
|
|
256
|
+# @param elem : the element which represents the EmField
|
|
257
|
+# @param model : the model which will contain the new field
|
|
258
|
+# @return a new EmField object
|
255
|
259
|
def load_field_xml(model, elem):
|
256
|
260
|
uid = elem.find('uid').text
|
257
|
261
|
if elem.find('display_name').text is None:
|
|
@@ -276,7 +280,11 @@ def load_field_xml(model, elem):
|
276
|
280
|
emfield = EmField(uid, dhdl.text, name, help_text, group)
|
277
|
281
|
|
278
|
282
|
return emfield
|
279
|
|
-
|
|
283
|
+
|
|
284
|
+##@brief Creates a EmGroup from a xml description
|
|
285
|
+# @param elem : the element which represents the EmGroup
|
|
286
|
+# @param model : the model which will contain the new group
|
|
287
|
+# @return a new EmGroup object
|
280
|
288
|
def load_group_xml(model, elem):
|
281
|
289
|
uid = elem.find('uid')
|
282
|
290
|
|
|
@@ -325,6 +333,10 @@ def load_group_xml(model, elem):
|
325
|
333
|
|
326
|
334
|
return group
|
327
|
335
|
|
|
336
|
+##@brief Constructs a MlString from a xml description
|
|
337
|
+# @param elem : the element which represents the MlString
|
|
338
|
+# @param model : the model which will contain the new group
|
|
339
|
+# @return a new MlString object
|
328
|
340
|
def load_mlstring_xml(elem):
|
329
|
341
|
mlstr = dict()
|
330
|
342
|
for lang in elem:
|