Skip to content
This repository has been archived by the owner. It is now read-only.

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

Closed
christian-oreilly opened this issue Aug 10, 2018 · 2 comments
Assignees

Comments

@christian-oreilly
Copy link
Contributor

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
christian-oreilly added a commit that referenced this issue Aug 10, 2018
@pafonta pafonta changed the title [ZoteroWrap] Neurocurator crashers when processing zotero references through NAT [ZoteroWrap] Handle Zotero references without 'lastName' for 'creators' (NeuroCurator crashes) Aug 20, 2018
@pafonta pafonta self-assigned this Aug 20, 2018
@pafonta
Copy link
Contributor

pafonta commented Aug 21, 2018

Notes:

  • Only NeuroCurator v0.4.4 crashes. Previous versions do not. This is because PyQt5, introduced in NeuroCurator v0.4.4, handles differently Python exceptions compared to PySide (used in previous versions of NeuroCurator).

  • The Zotero field 'name' is not considered the same way as 'lastName' in ZoteroWrap because it also contains 'firstName'. Also, having 'lastName' and 'firstName' filled instead of 'name' is what is expected.

  • When the field 'name' is used in Zotero, users should modify the reference in Zotero. It is not the purpose of NeuroCurator to add logic to handle this. Even if it was, it would introduce inconsistencies: last names are expected but 'name' contains other parts of the name.

  • When the new ZoteroWrap has been designed, no Zotero reference was using the field 'name'. As of 20.08.18, only one does (DOI: 10.1113/JP274049) among 751.

@pafonta
Copy link
Contributor

pafonta commented Aug 21, 2018

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'.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants