@@ -223,10 +223,10 @@ def parse_element(self, node):
223
223
return None # won't be able to parse this one
224
224
return getattr (self , "parse_" + node .tag )(node , self .tags [node .tag ])
225
225
226
- def parse_tag (self , root , fmt , insert_children = True , create = None ):
226
+ def parse_tag (self , root , fmt , insert_children = True ):
227
227
"""
228
228
Parse an odml node based on the format description *fmt*
229
- and a function *create* to instantiate a corresponding object
229
+ and instantiate the corresponding object.
230
230
"""
231
231
arguments = {}
232
232
extra_args = {}
@@ -284,10 +284,9 @@ def parse_tag(self, root, fmt, insert_children=True, create=None):
284
284
self .check_mandatory_arguments (dict (arguments .items () +
285
285
extra_args .items ()),
286
286
fmt , root .tag , root )
287
- if create is None :
288
- obj = fmt .create ()
289
- else :
290
- obj = create (args = arguments , text = '' .join (text ), children = children )
287
+
288
+ # Instantiate the current odML object with the parsed attributes.
289
+ obj = fmt .create (** arguments )
291
290
292
291
for k , v in arguments .items ():
293
292
if hasattr (obj , k ) and (getattr (obj , k ) is None or k == 'id' ):
@@ -312,12 +311,10 @@ def parse_odML(self, root, fmt):
312
311
return doc
313
312
314
313
def parse_section (self , root , fmt ):
315
- return self .parse_tag (root , fmt ,
316
- create = lambda args , ** kargs : fmt .create (** args ))
314
+ return self .parse_tag (root , fmt )
317
315
318
316
def parse_property (self , root , fmt ):
319
- create = lambda children , args , ** kargs : fmt .create (** args )
320
- return self .parse_tag (root , fmt , insert_children = False , create = create )
317
+ return self .parse_tag (root , fmt , insert_children = False )
321
318
322
319
323
320
if __name__ == '__main__' :
0 commit comments