G-Node / python-odml

odML libraries
http://g-node.github.io/python-odml/
BSD 4-Clause "Original" or "Old" License
24 stars 30 forks source link

Attribute error when writing xml output #306

Open graslandschaft opened 5 years ago

graslandschaft commented 5 years ago

odml version 1.4.1 INFO:rdflib:RDFLib Version: 4.2.2

Traceback: 
writer.write_file('{0}.xml'.format("bla"))
  File "/usr/local/lib/python2.7/dist-packages/odml/tools/xmlparser.py", line 128, in write_file
    data = unicode(self).encode('utf-8')
  File "/usr/local/lib/python2.7/dist-packages/odml/tools/xmlparser.py", line 122, in __unicode__
    return ET.tounicode(self.save_element(self.doc), pretty_print=True)
  File "/usr/local/lib/python2.7/dist-packages/odml/tools/xmlparser.py", line 108, in save_element
    ele = XMLWriter.save_element(v)
  File "/usr/local/lib/python2.7/dist-packages/odml/tools/xmlparser.py", line 108, in save_element
    ele = XMLWriter.save_element(v)
  File "/usr/local/lib/python2.7/dist-packages/odml/tools/xmlparser.py", line 82, in save_element
    cur = E(fmt.name)
AttributeError: 'unicode' object has no attribute 'name'
mpsonntag commented 5 years ago

Thanks for reporting this issue!

I saved a document using Python 2.7 with odml 1.4.1 but was not able to recreate the reported error. Could you give more details about what you are trying to save? If you could run ...

from odml.tools import dumper
dumper.dumpDoc(doc)

... where doc is the document that results in your error and paste the resulting printed document maybe I can get a better idea what is actually going wrong.

graslandschaft commented 5 years ago
 *datasets (type='dataset')
  :files (value=./2018-11-09/trial_0004_info.dat, dtype='string')
 *[u'Recording'] (type='recording')
  :Comment (definition='Comments on the recording session.', value=, dtype='string')
  :StartDate (definition='The date the recording session was conducted\n      (YYYY-MM-DD format).', value=, dtype='date')
  :EndDate (definition='The date the recording session ended (YYYY-MM-DD\n      format).', value=, dtype='date')
  :Experimenter (definition='The name of the person actually performing the\n      recordings.', value=Joerg Henninger, dtype='person')
  :StartTime (value=2018-11-09 20:02:34, dtype='string')
 *[u'Fish tank at Krahe Lab'] (type='setup')
  :Maintainer (definition='The person who is responsible for the setup\n      maintanance.', value=Joerg Henninger, dtype='string')
  :Description (definition='A textual description of the setup.', value=, dtype='string')
  :Creator (definition='The person who built the setup.', value=[Joerg Henninger,Jan Benda], dtype='string')
  :Location (definition='The location of the setup (e.g. room).', value=Krahe Lab, HU Berlin, dtype='string')
  :Department (definition='The department where the setup is\n      located.', value=Abteilung Neuroethologie, dtype='string')
  :Config (definition='An identifier of the used setup\n      configuration, e.g. if variations of the same setup are\n      used.', value=, dtype='string')
 *[u'Observation of Behavior'] (type='experiment/bahavior')
  :IndividualCount (definition='The number of individuals that are\n      observed/investigated at the same time.', value=1, dtype='int')
  :Task (value=, dtype='string')
  :definition (definition='A definition of the conducted experiment.', value=, dtype='string')
 *[u'Subject'] (type='subject')
  :Comment (definition='A general comment on a specific\n      subject.', value=, dtype='text')
  :- (definition='The tank in which the subject is housed.', value=, dtype='string')
  :Subject id (value=, dtype='string')
  :TrivialName (definition='The trivial name of the species like\n      Honeybee, Human.', value=, dtype='string')
  :Species (definition='The scientific name of the species e.g. Apis\n      mellifera, Homo sapiens.', value=, dtype='string')
 *camera00 (type='hardware/camera')
  :Framerate (value=25, unit='Hz', dtype='int')
 *events (type='event_list')