|
@@ -7,9 +7,63 @@ from lodel.editorial_model.model import EditorialModel
|
7
|
7
|
from lodel.editorial_model.components import *
|
8
|
8
|
from lodel.utils.mlstring import MlString
|
9
|
9
|
|
|
10
|
+## @package lodel.editorial_model.translator Lodel 2 Editorial Model Translators
|
|
11
|
+## @brief Packahg for saving a Editorial µModel in a xml fiel and loading an Editorial Model from a xml file
|
|
12
|
+#
|
|
13
|
+# Structure of a xml file which represents an editorial model:
|
|
14
|
+# <ul>
|
|
15
|
+# <li>\<name\>: name of the model, field <b><em>name</em></b> in class <b><em>EditorialModel</em></b>
|
|
16
|
+# <li>\<description\>: field <b><em>description</em></b> of a composed element, one for each language translation named
|
|
17
|
+# <ul><li>\<fre\> for french,
|
|
18
|
+# <li>\<eng\> for english,
|
|
19
|
+# <li>\<esp\> for spanish,
|
|
20
|
+# <li>\<ger\> for german</ul>
|
|
21
|
+# <li>\<classes\>: set of all <b><em>EmClass</em></b> in the model \n
|
|
22
|
+# for each classe: \n
|
|
23
|
+# \<class\><ul>
|
|
24
|
+# <li>\<uid\>the class's id
|
|
25
|
+# <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 :
|
|
26
|
+# <ul><li>\<fre\> for french,
|
|
27
|
+# <li>\<eng\> for english,
|
|
28
|
+# <li>\<esp\> for spanish,
|
|
29
|
+# <li>\<ger> for german</ul>
|
|
30
|
+# <li>\<help_text\> Short explanation of the class's purpose, in different languages, as above
|
|
31
|
+# <li>\<abstract\> True or False, field <b><em>abstract</em></b> of the <b><em>EmClass</em></b>
|
|
32
|
+# <li>\<pure_abstract\> True or False, field <b><em>pure_bastract</em></b> of the <b><em>EmClass</em></b>
|
|
33
|
+# <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>
|
|
34
|
+# <li>\<fields\>: set of all the <b><em>EmField</em></b> of the <b><em>EmClass</em></b>\n
|
|
35
|
+# for each field: \n
|
|
36
|
+# \<field\>
|
|
37
|
+# <ul><li>\<uid\> uid of the <b><em>EmField</em></b>
|
|
38
|
+# <li>\<display_name\> field <b><em>display_name</em></b> of the <b><em>EmField</em></b>, in different languages, as above
|
|
39
|
+# <li>\<help_text\> Short explanation of the class's purpose, in different languages, as above
|
|
40
|
+# <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>
|
|
41
|
+# <li>\<datahandler_name\> field <b><em>datahandler_name</em></b> of the Emfield, the name of a datahandler
|
|
42
|
+# <li>\<datahandler_options\>, a list of xml items, each of them named with an option name and contains its value</ul></ul>
|
|
43
|
+# <li>\<groups\>: set of all the groups <b><em>EmGroup</em></b> in the model\n
|
|
44
|
+# for each group:\n
|
|
45
|
+# <ul><li>\<uid\> uid of the <b><em>EmField</em></b>
|
|
46
|
+# <li>\<display_name\> field <b><em>display_name</em></b> of the <b><em>EmField</em></b>, in different languages, as above
|
|
47
|
+# <li>\<help_text\> Short explanation of the class's purpose, in different languages, as above
|
|
48
|
+# <li>\<requires\> all uids of the <b><em>EmGroups</em></b> required by this group and which are in the fields <b><em>require</em></b>
|
|
49
|
+# <li>\<components\> Set of all components of the <b><em>EmGroups</em></b>, representation of the field <b><em>__components</em></b> \n
|
|
50
|
+# this item is splitted in two parts :\
|
|
51
|
+# <ul><li>\<emfields\> all the emfields with, for each of them:\n
|
|
52
|
+# \<emfield\> \n
|
|
53
|
+# <ul><li> \<uid\> <b><em>uid</em></b> of the <b><em>EmField</em></b></ul>
|
|
54
|
+# <li>\<emclasses\> all the emclasses with, for each of them:\n
|
|
55
|
+# \<emclass\> \n
|
|
56
|
+# <ul><li> \<uid\> <b><em>uid</em></b> of the <b><em>EmClass</em></b></ul></ul></ul>
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
10
|
63
|
##@brief Saves a model in a xml file
|
11
|
64
|
# @param model EditorialModel : the model to save
|
12
|
65
|
# @param filename str|None : if None display on stdout else writes in the file filename
|
|
66
|
+
|
13
|
67
|
def save(model, **kwargs):
|
14
|
68
|
Em = etree.Element("editorial_model")
|
15
|
69
|
em_name = etree.SubElement(Em, 'name')
|