diff options
author | Martin Czygan <martin.czygan@gmail.com> | 2019-12-26 17:53:26 +0100 |
---|---|---|
committer | Martin Czygan <martin.czygan@gmail.com> | 2019-12-28 23:07:32 +0100 |
commit | 133cc910c07187a349a336b1b7107d67dc3aed3e (patch) | |
tree | 868cbb86bc9c873bb77718e0cabfe3ba39e20506 /python/fatcat_tools/importers | |
parent | 13430af9e8c2e39ba90a7db2135496503fb020b2 (diff) | |
download | fatcat-133cc910c07187a349a336b1b7107d67dc3aed3e.tar.gz fatcat-133cc910c07187a349a336b1b7107d67dc3aed3e.zip |
datacite: include container_name top level key in extra
Diffstat (limited to 'python/fatcat_tools/importers')
-rw-r--r-- | python/fatcat_tools/importers/datacite.py | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/python/fatcat_tools/importers/datacite.py b/python/fatcat_tools/importers/datacite.py index 16431928..322e3db9 100644 --- a/python/fatcat_tools/importers/datacite.py +++ b/python/fatcat_tools/importers/datacite.py @@ -374,6 +374,7 @@ class DataciteImporter(EntityImporter): # Container. For the moment, only ISSN as container. container_id = None + container_name = None container = attributes.get('container', {}) or {} if container.get('type') in CONTAINER_TYPE_MAP.keys(): @@ -388,21 +389,30 @@ class DataciteImporter(EntityImporter): container_id = self.lookup_issnl(issnl) if container_id is None and container.get('title'): - container_title = container.get('title') - if isinstance(container_title, list): - if len(container_title) > 0: + container_name = container.get('title') + if isinstance(container_name, list): + if len(container_name) > 0: print('[{}] too many container titles: {}'.format(doi, - len(container_title))) - container_title = container_title[0] - assert isinstance(container_title, str) + len(container_name))) + container_name = container_name[0] + assert isinstance(container_name, str) ce = fatcat_openapi_client.ContainerEntity( issnl=issnl, container_type=container_type, - name=container_title, + name=container_name, ) ce_edit = self.create_container(ce) container_id = ce_edit.ident self._issnl_id_map[issnl] = container_id + else: + # TODO(martin): factor this out into a testable function. + # TODO(martin): "container_name": "№1(1) (2018)" / 10.26087/inasan.2018.1.1.013 + container_name = container.get('title') + if isinstance(container_name, list): + if len(container_name) > 0: + print('[{}] too many container titles: {}'.format(doi, + len(container_name))) + container_name = container_name[0] # Volume and issue. volume = container.get('volume') @@ -558,6 +568,10 @@ class DataciteImporter(EntityImporter): extra = dict() + # top-level extra keys + if not container_id and container_name: + extra['container_name'] = container_name + if extra_datacite: extra['datacite'] = extra_datacite |