aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/fatcat_tools/transforms/csl.py23
-rw-r--r--python/tests/web_citation_csl.py2
2 files changed, 12 insertions, 13 deletions
diff --git a/python/fatcat_tools/transforms/csl.py b/python/fatcat_tools/transforms/csl.py
index 989629ab..f94fa372 100644
--- a/python/fatcat_tools/transforms/csl.py
+++ b/python/fatcat_tools/transforms/csl.py
@@ -34,31 +34,30 @@ def release_to_csl(entity):
contribs = []
for contrib in (entity.contribs or []):
if contrib.creator:
- # TODO: should we actually be pulling creator metadata? or just
- # using release-local raw metadata?
- family = contrib.creator.surname
- if not family:
- if not contrib.raw_name:
- raise ValueError("CSL requires some surname (family name)")
- family = contrib.raw_name.split()[-1]
+ # Default to "local" (publication-specific) metadata; fall back to
+ # creator-level
+ family = contrib.surname or contrib.creator.surname or (contrib.raw_name and contrib.raw_name.split()[-1])
+ if not contrib.raw_name:
+ raise ValueError("CSL requires some surname (family name)")
c = dict(
- family=contrib.creator.surname,
- given=contrib.creator.given_name,
+ family=family,
+ given=contrib.given_name or contrib.creator.given_name,
#dropping-particle
#non-dropping-particle
#suffix
#comma-suffix
#static-ordering
- literal=contrib.raw_name, # or display_name?
+ literal=contrib.raw_name or contrib.creator.display_name,
#parse-names,
role=contrib.role,
)
else:
+ family = contrib.surname or (contrib.raw_name and contrib.raw_name.split()[-1])
if not contrib.raw_name:
raise ValueError("CSL requires some surname (family name)")
c = dict(
- # XXX: possible inclusion of full name metadata in release_contrib
- family=contrib.raw_name.split()[-1],
+ family=family,
+ given=contrib.given_name,
literal=contrib.raw_name,
role=contrib.role,
)
diff --git a/python/tests/web_citation_csl.py b/python/tests/web_citation_csl.py
index cf50f3c3..241f450f 100644
--- a/python/tests/web_citation_csl.py
+++ b/python/tests/web_citation_csl.py
@@ -23,7 +23,7 @@ def test_release_bibtex(app):
json.loads(rv.data.decode('utf-8'))
rv = app.get('/release/aaaaaaaaaaaaarceaaaaaaaaam/citeproc?style=modern-language-association')
assert rv.status_code == 200
- assert rv.data.decode('utf-8').startswith('Ioannidis. “Why Most Published Research Findings Are False”. 2.8 (2005)')
+ assert rv.data.decode('utf-8').startswith('Ioannidis, John. “Why Most Published Research Findings Are False”. 2.8 (2005)')
# "dummy" demo entity
rv = app.get('/release/aaaaaaaaaaaaarceaaaaaaaaai')