From 4b7c87c4c3e9e112c5ab3b904da82e927fbb84a0 Mon Sep 17 00:00:00 2001 From: jiarongli Date: Tue, 9 Jun 2026 16:46:09 +0200 Subject: [PATCH 1/3] fix the Nonetype object error --- pygeometa/schemas/openaire/__init__.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pygeometa/schemas/openaire/__init__.py b/pygeometa/schemas/openaire/__init__.py index da07ba6..d9240c1 100644 --- a/pygeometa/schemas/openaire/__init__.py +++ b/pygeometa/schemas/openaire/__init__.py @@ -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_ @@ -173,11 +173,13 @@ 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', {}).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': @@ -348,7 +350,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} @@ -364,7 +366,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')) From 5cb8649a10fd1af4153ceb19d58fb49171c7045a Mon Sep 17 00:00:00 2001 From: jiarongli Date: Tue, 9 Jun 2026 16:49:32 +0200 Subject: [PATCH 2/3] fix --- pygeometa/schemas/openaire/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pygeometa/schemas/openaire/__init__.py b/pygeometa/schemas/openaire/__init__.py index d9240c1..0f6b0aa 100644 --- a/pygeometa/schemas/openaire/__init__.py +++ b/pygeometa/schemas/openaire/__init__.py @@ -173,7 +173,6 @@ 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 From 279e547b834ba92582fcad40ec9b07fe18088c9a Mon Sep 17 00:00:00 2001 From: jiarongli Date: Tue, 9 Jun 2026 16:53:33 +0200 Subject: [PATCH 3/3] remove blank line --- pygeometa/schemas/openaire/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygeometa/schemas/openaire/__init__.py b/pygeometa/schemas/openaire/__init__.py index 0f6b0aa..968234a 100644 --- a/pygeometa/schemas/openaire/__init__.py +++ b/pygeometa/schemas/openaire/__init__.py @@ -174,7 +174,7 @@ def import_(self, metadata: str) -> dict: mcf['identification']['edition'] = version_ right_ = (metadata_.get('bestAccessRight') or {}).get('label') - + instance_right_ = None if main_instance_: instance_right_ = (main_instance_.get(