Browse Source

Comments are added

prieto 8 years ago
parent
commit
42361efe7a
1 changed files with 20 additions and 8 deletions
  1. 20
    8
      lodel/editorial_model/translator/xmlfile.py

+ 20
- 8
lodel/editorial_model/translator/xmlfile.py View File

9
 
9
 
10
 ##@brief Saves a model in a xml file
10
 ##@brief Saves a model in a xml file
11
 # @param model EditorialModel : the model to save
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
 def save(model, **kwargs):
13
 def save(model, **kwargs):
15
     Em = etree.Element("editorial_model")
14
     Em = etree.Element("editorial_model")
16
     em_name = etree.SubElement(Em, 'name')
15
     em_name = etree.SubElement(Em, 'name')
99
 # @param name  : the name of the group
98
 # @param name  : the name of the group
100
 # @param help_text : explanations of the EmGroup
99
 # @param help_text : explanations of the EmGroup
101
 # @param requires : a list of the group's uids whose this group depends
100
 # @param requires : a list of the group's uids whose this group depends
102
-
103
 def write_emgroup_xml(etree, elem, uid, name, help_text, requires, components):
101
 def write_emgroup_xml(etree, elem, uid, name, help_text, requires, components):
104
     emgroup = etree.SubElement(elem, 'group')
102
     emgroup = etree.SubElement(elem, 'group')
105
     emgroup_uid = etree.SubElement(emgroup, 'uid')
103
     emgroup_uid = etree.SubElement(emgroup, 'uid')
144
 # @param parents : a list of EmClass uids
142
 # @param parents : a list of EmClass uids
145
 # @param abstract : a boolean
143
 # @param abstract : a boolean
146
 # @param pure_abstract : a boolean
144
 # @param pure_abstract : a boolean
147
-
148
 def write_emclass_xml(etree, elem, uid, name, help_text, group, fields, parents, abstract = False, pure_abstract = False):
145
 def write_emclass_xml(etree, elem, uid, name, help_text, group, fields, parents, abstract = False, pure_abstract = False):
149
     emclass = etree.SubElement(elem, 'class')
146
     emclass = etree.SubElement(elem, 'class')
150
     emclass_uid  = etree.SubElement(emclass, 'uid')
147
     emclass_uid  = etree.SubElement(emclass, 'uid')
178
 
175
 
179
 ##@brief Loads a model from a xml file
176
 ##@brief Loads a model from a xml file
180
 # @param model EditorialModel : the model to load
177
 # @param model EditorialModel : the model to load
181
-
178
+# @return a new EditorialModel object
182
 def load(**kwargs):
179
 def load(**kwargs):
183
 
180
 
184
     Em = etree.parse(kwargs['filename'])
181
     Em = etree.parse(kwargs['filename'])
198
         if grp.uid not in model.all_groups():
195
         if grp.uid not in model.all_groups():
199
             grp = model.add_group(grp)
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
 def load_class_xml(model, elem):
204
 def load_class_xml(model, elem):
204
     uid = elem.find('uid').text
205
     uid = elem.find('uid').text
205
     if elem.find('display_name').text is None:
206
     if elem.find('display_name').text is None:
251
             
252
             
252
     return emclass
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
 def load_field_xml(model, elem):
259
 def load_field_xml(model, elem):
256
     uid = elem.find('uid').text
260
     uid = elem.find('uid').text
257
     if elem.find('display_name').text is None:
261
     if elem.find('display_name').text is None:
276
         emfield = EmField(uid, dhdl.text, name, help_text, group)
280
         emfield = EmField(uid, dhdl.text, name, help_text, group)
277
     
281
     
278
     return emfield
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
 def load_group_xml(model, elem):
288
 def load_group_xml(model, elem):
281
     uid = elem.find('uid')
289
     uid = elem.find('uid')
282
     
290
     
325
         
333
         
326
     return group
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
 def load_mlstring_xml(elem):
340
 def load_mlstring_xml(elem):
329
     mlstr = dict()
341
     mlstr = dict()
330
     for lang in elem:
342
     for lang in elem:

Loading…
Cancel
Save