Cannot read archive with python bindings
matthiaskoenig opened this issue · comments
Hi all,
I am trying to read combine archives via the python bindings,
but always get errors about empty XML content when trying to read the archives.
I am not sure what I am doing wrong
from __future__ import print_function, division
import libcombine
def get_content(path):
print(path)
# libsbml.readSBMLFromFile(path)
manifest = libcombine.readOMEXFromFile(str(path))
print("Errors:", manifest.getNumErrors())
for k in xrange(manifest.getNumErrors()):
error = manifest.getError(k)
print(error)
print(error.getErrorId())
print(error.getMessage())
# make CaListOfContents iteratable
contentsList = manifest.getListOfContents()
print('Contents: ', contentsList.getNumContents())
for k in xrange(contentsList.getNumContents()):
cabase = contentsList.get(k)
print(cabase)
print(manifest)
if __name__ == "__main__":
"""
Try to read the showcase archive.
"""
archive = "CombineArchiveShowCase.omex"
get_content(archive)
Archive is the CombineArchiveShowCase from
http://scripts.sems.uni-rostock.de/getshowcase.php
Errors are:
/usr/bin/python2.7 /home/mkoenig/git/tellurium-web/teweb/combine/oven/libcombine_example.py
CombineArchiveShowCase.omex
Errors: 2
<libcombine.CaError; proxy of <Swig Object of type 'CaError_t *' at 0x7effbde5d300> >
1035
Main XML content is empty.
<libcombine.CaError; proxy of <Swig Object of type 'CaError_t *' at 0x7effbde5d330> >
1002
Missing encoding attribute in XML declaration.
Contents: 0
<libcombine.CaOmexManifest; proxy of <Swig Object of type 'CaOmexManifest_t *' at 0x7effbfc77f90> >
Process finished with exit code 0
Hello Matthias,
the readOMEX functions are just there to read the manifest file. All the zip logic and other stuff is in the CombineArchive class as written in the release announcement. If you want just to read the archive, please have a look at the print example:
https://github.com/sbmlteam/libCombine/blob/master/examples/python/printExample.py
or if you would like to create one you could use the create example:
https://github.com/sbmlteam/libCombine/blob/master/examples/python/createArchiveExample.py
we also have rudimentary documentation of the combinearchive class available here:
https://sbmlteam.github.io/libCombine/html/class_combine_archive.html
best
Frank
Perfect.
Thanks a lot this makes everything clear.