aboutsummaryrefslogtreecommitdiffstats
path: root/python/fatcat_tools
diff options
context:
space:
mode:
authorMartin Czygan <martin.czygan@gmail.com>2019-12-26 17:24:50 +0100
committerMartin Czygan <martin.czygan@gmail.com>2019-12-28 23:07:32 +0100
commita57919b05d8b1f24041713e85b7fa4322c0591c6 (patch)
tree9c00bdab567cea2daffe57383be0286d668ec8d1 /python/fatcat_tools
parent91bd7b82608e5e27a10c649cf8205243b8ba96c6 (diff)
downloadfatcat-a57919b05d8b1f24041713e85b7fa4322c0591c6.tar.gz
fatcat-a57919b05d8b1f24041713e85b7fa4322c0591c6.zip
datacite: use iso 639-1 codes
Diffstat (limited to 'python/fatcat_tools')
-rw-r--r--python/fatcat_tools/importers/datacite.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/python/fatcat_tools/importers/datacite.py b/python/fatcat_tools/importers/datacite.py
index 19b89edf..26520164 100644
--- a/python/fatcat_tools/importers/datacite.py
+++ b/python/fatcat_tools/importers/datacite.py
@@ -10,7 +10,7 @@ import datetime
import fatcat_openapi_client
import hashlib
import json
-import langcodes
+import pycountry
import langdetect
import sqlite3
import sys
@@ -433,12 +433,9 @@ class DataciteImporter(EntityImporter):
value = attributes.get('language', '') or ''
try:
- language = langcodes.find(value).language
- except LookupError:
- try:
- language = langcodes.get(value).language
- except langcodes.tag_parser.LanguageTagError:
- pass
+ language = pycountry.languages.lookup(value).alpha_2
+ except (LookupError, AttributeError) as err:
+ print('language lookup miss for {}: {}'.format(value, err), file=sys.stderr)
# Abstracts appear in "attributes.descriptions[].descriptionType", some
# of the observed values: "Methods", "TechnicalInfo",