zhanglab / psamm

Curation and analysis of metabolic models
https://zhanglab.github.io/psamm/
GNU General Public License v3.0
34 stars 15 forks source link

sbml: Use cElementTree if possible #245

Closed jonls closed 7 years ago

jonls commented 7 years ago

It was also considered whether lxml could be used. lxml would have been able to supply additional information, such as line numbers of element definitions. However, lxml has compatibility issues with the way namespaces are handled in the sbml module currently.

The tests that rely on inline XML data were modified. On Python 2.7, cElementTree only works with a file that reads bytes. StringIO returns unicode if initialized with a unicode string. This results in cElementTree failing if a unicode string is supplied in test cases (or if unicode_literals is set). Instead use BytesIO with a string explicitly encoded as UTF-8. This works in all cases.