|
@@ -16,17 +16,19 @@ LodelContext.expose_modules(globals(), {
|
16
|
16
|
#
|
17
|
17
|
# Structure of a xml file which represents an editorial model:
|
18
|
18
|
# <ul>
|
19
|
|
-# <li>\<name\>: name of the model, field <b><em>name</em></b> in class <b><em>EditorialModel</em></b>
|
20
|
|
-# <li>\<description\>: field <b><em>description</em></b> of a composed element, one for each language translation named
|
21
|
|
-# <ul><li>\<fre\> for french,
|
22
|
|
-# <li>\<eng\> for english,
|
23
|
|
-# <li>\<esp\> for spanish,
|
24
|
|
-# <li>\<ger\> for german</ul>
|
25
|
|
-# <li>\<classes\>: set of all <b><em>EmClass</em></b> in the model \n
|
|
19
|
+# <li>\<name\>: name of the model, field <b><em>name</em></b> in class <b><em>EditorialModel</em></b>
|
|
20
|
+# <li>\<description\>: field <b><em>description</em></b> of a composed element, one for each language translation named
|
|
21
|
+# <ul>
|
|
22
|
+# <li>\<fre\> for french,
|
|
23
|
+# <li>\<eng\> for english,
|
|
24
|
+# <li>\<esp\> for spanish,
|
|
25
|
+# <li>\<ger\> for german
|
|
26
|
+# </ul>
|
|
27
|
+# <li>\<classes\>: set of all <b><em>EmClass</em></b> in the model \n
|
26
|
28
|
# for each classe: \n
|
27
|
29
|
# \<class\><ul>
|
28
|
|
-# <li>\<uid\>the class's id
|
29
|
|
-# <li>\<display_name\> The name of the class, field <b><em>display_name</em></b> of the <b><em>EmClass</em></b> , in different languages if they're available :
|
|
30
|
+# <li>\<uid\>the class's id
|
|
31
|
+# <li>\<display_name\> The name of the class, field <b><em>display_name</em></b> of the <b><em>EmClass</em></b> , in different languages if they're available :
|
30
|
32
|
# <ul><li>\<fre\> for french,
|
31
|
33
|
# <li>\<eng\> for english,
|
32
|
34
|
# <li>\<esp\> for spanish,
|
|
@@ -43,8 +45,9 @@ LodelContext.expose_modules(globals(), {
|
43
|
45
|
# <li>\<help_text\> Short explanation of the class's purpose, in different languages, as above
|
44
|
46
|
# <li>\<group\><b><em>uid</em></b> of the group of the field <b><em>group</em></b> of the <b><em>EmClass</em></b>
|
45
|
47
|
# <li>\<datahandler_name\> field <b><em>datahandler_name</em></b> of the Emfield, the name of a datahandler
|
46
|
|
-# <li>\<datahandler_options\>, a list of xml items, each of them named with an option name and contains its value</ul></ul>
|
47
|
|
-# <li>\<groups\>: set of all the groups <b><em>EmGroup</em></b> in the model\n
|
|
48
|
+# <li>\<datahandler_options\>, a list of xml items, each of them named with an option name and contains its value</ul>
|
|
49
|
+# </ul>
|
|
50
|
+# <li>\<groups\>: set of all the groups <b><em>EmGroup</em></b> in the model\n
|
48
|
51
|
# for each group:\n
|
49
|
52
|
# <ul><li>\<uid\> uid of the <b><em>EmField</em></b>
|
50
|
53
|
# <li>\<display_name\> field <b><em>display_name</em></b> of the <b><em>EmField</em></b>, in different languages, as above
|
|
@@ -58,7 +61,7 @@ LodelContext.expose_modules(globals(), {
|
58
|
61
|
# <li>\<emclasses\> all the emclasses with, for each of them:\n
|
59
|
62
|
# \<emclass\> \n
|
60
|
63
|
# <ul><li> \<uid\> <b><em>uid</em></b> of the <b><em>EmClass</em></b></ul></ul></ul>
|
61
|
|
-
|
|
64
|
+# </ul>
|
62
|
65
|
|
63
|
66
|
|
64
|
67
|
|
|
@@ -66,8 +69,8 @@ LodelContext.expose_modules(globals(), {
|
66
|
69
|
|
67
|
70
|
##@brief Saves a model in a xml file
|
68
|
71
|
# @param model EditorialModel : the model to save
|
69
|
|
-# @param filename str|None : if None display on stdout else writes in the file filename
|
70
|
|
-
|
|
72
|
+# @param kwargs dict :
|
|
73
|
+# - filename str|None : if None display on stdout else writes in the file filename
|
71
|
74
|
def save(model, **kwargs):
|
72
|
75
|
Em = etree.Element("editorial_model")
|
73
|
76
|
em_name = etree.SubElement(Em, 'name')
|
|
@@ -144,9 +147,9 @@ def write_datahandler_xml(etree, elem, dhdl_name, **kwargs):
|
144
|
147
|
# @param uid : the uid of the EmField
|
145
|
148
|
# @param name : the name of the field
|
146
|
149
|
# @param help_text : explanations of the EmField
|
147
|
|
-# @param group_uid : the uid of a group, can be None
|
148
|
|
-# @datahandler_name
|
149
|
|
-# @**kwargs : options of the datahandler
|
|
150
|
+# @param group : the uid of a group, can be None
|
|
151
|
+# @param datahandler_name str
|
|
152
|
+# @param **kwargs : options of the datahandler
|
150
|
153
|
def write_emfield_xml(etree, elem, uid, name, help_text, group, datahandler_name, **kwargs):
|
151
|
154
|
emfield = etree.SubElement(elem,'field')
|
152
|
155
|
emfield_uid = etree.SubElement(emfield, 'uid')
|
|
@@ -170,9 +173,11 @@ def write_emfield_xml(etree, elem, uid, name, help_text, group, datahandler_name
|
170
|
173
|
##@brief Writes a representation of a EmGroup in xml
|
171
|
174
|
# @param etree : the xml object
|
172
|
175
|
# @param elem : the element for the EmGroup
|
|
176
|
+# @param uid str : lodel unique identifier
|
173
|
177
|
# @param name : the name of the group
|
174
|
178
|
# @param help_text : explanations of the EmGroup
|
175
|
179
|
# @param requires : a list of the group's uids whose this group depends
|
|
180
|
+# @param components
|
176
|
181
|
def write_emgroup_xml(etree, elem, uid, name, help_text, requires, components):
|
177
|
182
|
emgroup = etree.SubElement(elem, 'group')
|
178
|
183
|
emgroup_uid = etree.SubElement(emgroup, 'uid')
|
|
@@ -207,8 +212,10 @@ def write_emgroup_xml(etree, elem, uid, name, help_text, requires, components):
|
207
|
212
|
##@brief Writes a representation of a EmClass in xml
|
208
|
213
|
# @param etree : the xml object
|
209
|
214
|
# @param elem : the element for the EmClass
|
|
215
|
+# @param uid
|
210
|
216
|
# @param name : the name of the group
|
211
|
217
|
# @param help_text : explanations of the EmClass
|
|
218
|
+# @param group
|
212
|
219
|
# @param fields : a dict
|
213
|
220
|
# @param parents : a list of EmClass uids
|
214
|
221
|
# @param abstract : a boolean
|
|
@@ -245,7 +252,7 @@ def write_emclass_xml(etree, elem, uid, name, help_text, group, fields, parents,
|
245
|
252
|
emclass_parents.text = ",".join(parents_list)
|
246
|
253
|
|
247
|
254
|
##@brief Loads a model from a xml file
|
248
|
|
-# @param model EditorialModel : the model to load
|
|
255
|
+# @param filename str : file path of the XML file from which the model will be loaded
|
249
|
256
|
# @return a new EditorialModel object
|
250
|
257
|
def load(filename):
|
251
|
258
|
|
|
@@ -452,7 +459,6 @@ def load_group_xml(model, elem):
|
452
|
459
|
|
453
|
460
|
##@brief Constructs a MlString from a xml description
|
454
|
461
|
# @param elem : the element which represents the MlString
|
455
|
|
-# @param model : the model which will contain the new group
|
456
|
462
|
# @return a new MlString object
|
457
|
463
|
def load_mlstring_xml(elem):
|
458
|
464
|
mlstr = dict()
|