Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions pygeometa/schemas/openaire/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def import_(self, metadata: str) -> dict:
mcf['metadata']['dataseturi'] = next(iter(urls), '')

# mcf: identification
language_ = metadata_.get('language', {}).get('code')
language_ = (metadata_.get('language') or {}).get('code')
if language_ is not None:
mcf['identification']['language'] = language_

Expand All @@ -173,11 +173,12 @@ def import_(self, metadata: str) -> dict:
if version_ is not None:
mcf['identification']['edition'] = version_

right_ = metadata_.get('bestAccessRight', {}).get('label')
right_ = (metadata_.get('bestAccessRight') or {}).get('label')

instance_right_ = None
if main_instance_:
instance_right_ = main_instance_.get(
'accessRight', {}).get('label')
instance_right_ = (main_instance_.get(
'accessRight') or {}).get('label')
if right_ is not None and right_ != 'unspecified':
mcf['identification']['rights'] = right_
elif instance_right_ is not None and instance_right_ != 'unspecified':
Expand Down Expand Up @@ -348,7 +349,7 @@ def process_keywords(subjects: list) -> dict:

:returns: `dict` grouped keywords
"""
unique_scheme = list(set([s.get('subject', {}).get('scheme')
unique_scheme = list(set([(s.get('subject') or {}).get('scheme')
for s in subjects]))

scheme_uuid_dict = {scheme: str(uuid.uuid4()) for scheme in unique_scheme}
Expand All @@ -364,7 +365,7 @@ def process_keywords(subjects: list) -> dict:
}

for s in subjects:
s_value = s.get('subject')
s_value = s.get('subject') or {}
for k, v in keywords_dict.items():
if s_value.get('scheme') == v.get('vocabulary', {}).get('name'):
v['keywords'].append(s_value.get('value'))
Expand Down
Loading