BlueBrain / nat

Python module to use the annotations created with NeuroCurator, for example in a Jupyter notebook.
https://pypi.python.org/pypi/nat/
Other
8 stars 4 forks source link

[ZoteroWrap] Handle Zotero references without 'lastName' for 'creators' (NeuroCurator crashes) #17

Closed christian-oreilly closed 6 years ago

christian-oreilly commented 6 years ago

NAT version: 0.4.2

Unexpected behaviour: Crashes when the interface of Neurocurator tries to display a record where the author name is not decomposed in name and surname.

Code to reproduce the behaviour:

1. Create a zotero record with just "name" information for author, no "lastName" field.
2. In NeuroCurator, filter by Creators.

Stack trace:

Loading cached Zotero data...
Loading distant Zotero data...
Distant Zotero data loaded.
Traceback (most recent call last):
  File "/home/oreilly/.local/lib/python3.6/site-packages/neurocurator/zotero_model.py", line 63, in data
    return self._cell_data(row, column)
  File "/home/oreilly/.local/lib/python3.6/site-packages/neurocurator/zotero_model.py", line 170, in _cell_data
    return self._zotero_wrap.reference_creator_surnames_str(row)
  File "/home/oreilly/.local/lib/python3.6/site-packages/nat/zotero_wrap.py", line 208, in reference_creator_surnames_str
    return ", ".join(self.reference_creator_surnames(index))
  File "/home/oreilly/.local/lib/python3.6/site-packages/nat/zotero_wrap.py", line 202, in reference_creator_surnames
    return [x["lastName"] for x in creators if x["creatorType"] == "author"]
  File "/home/oreilly/.local/lib/python3.6/site-packages/nat/zotero_wrap.py", line 202, in <listcomp>
    return [x["lastName"] for x in creators if x["creatorType"] == "author"]
KeyError: 'lastName'
Aborted
pafonta commented 6 years ago

Notes:

pafonta commented 6 years ago

To see what is the behaviour of the impacted methods of ZoteroWrap when the field 'name' is used in Zotero instead of 'lastName' (and 'firstName'), please refer to the updated tests by searching for tests with ID 'no_last_name'.