diff --git a/datalad_catalog/translators/bids_dataset_translator.py b/datalad_catalog/translators/bids_dataset_translator.py index 9ed4c2d6..f2d97912 100644 --- a/datalad_catalog/translators/bids_dataset_translator.py +++ b/datalad_catalog/translators/bids_dataset_translator.py @@ -143,12 +143,12 @@ def get_authors(self): '"email":"", "honorificSuffix":"", "identifiers":[]}]' ) result = jq.first(program, self.extracted_metadata) - return result if len(result) > 0 else None - + return result if result is not None and len(result) > 0 else None + def get_keywords(self): program = ". as $parent | .entities.task + .variables.dataset" result = jq.first(program, self.extracted_metadata) - return result if len(result) > 0 else None + return result if result is not None and len(result) > 0 else None def get_funding(self): program = ( @@ -156,7 +156,7 @@ def get_funding(self): '{"name": "", "grant":"", "description":$fund}]' ) result = jq.first(program, self.extracted_metadata) - return result if len(result) > 0 else None + return result if result is not None and len(result) > 0 else None def get_publications(self): program = ( @@ -170,12 +170,12 @@ def get_publications(self): '"authors": []}]' ) result = jq.first(program, self.extracted_metadata) - return result if len(result) > 0 else None + return result if result is not None and len(result) > 0 else None def get_additional_display(self): program = '[{"name": "BIDS", "content": .entities}]' result = jq.first(program, self.extracted_metadata) - return result if len(result) > 0 else None + return result if result is not None and len(result) > 0 else None def get_top_display(self): program = ( @@ -185,7 +185,7 @@ def get_top_display(self): '{"name": "Runs", "value": (.entities.run | length)}]' ) result = jq.first(program, self.extracted_metadata) - return result if len(result) > 0 else None + return result if result is not None and len(result) > 0 else None def translate(self): translated_record = { diff --git a/datalad_catalog/translators/datacite_gin_translator.py b/datalad_catalog/translators/datacite_gin_translator.py index c60c930e..7bb5bf2b 100644 --- a/datalad_catalog/translators/datacite_gin_translator.py +++ b/datalad_catalog/translators/datacite_gin_translator.py @@ -117,7 +117,7 @@ def get_license(self): program = '.license | { "name": .name, "url": .url}' result = jq.first(program, self.extracted_metadata) # todo check for license info missing - return result if len(result) > 0 else None + return result if result is not None and len(result) > 0 else None def get_authors(self): program = ( @@ -130,7 +130,7 @@ def get_authors(self): "else null end]" ) result = jq.first(program, self.extracted_metadata) - return result if len(result) > 0 else None + return result if result is not None and len(result) > 0 else None def get_keywords(self): return self.extracted_metadata.get("keywords") @@ -141,7 +141,7 @@ def get_funding(self): '{"name": $element, "identifier": "", "description": ""}]' ) result = jq.first(program, self.extracted_metadata) - return result if len(result) > 0 else None + return result if result is not None and len(result) > 0 else None def get_publications(self): program = ( @@ -155,7 +155,7 @@ def get_publications(self): '"authors": []}]' ) result = jq.first(program, self.extracted_metadata) - return result if len(result) > 0 else None + return result if result is not None and len(result) > 0 else None def translate(self): translated_record = { diff --git a/datalad_catalog/translators/metalad_core_translator.py b/datalad_catalog/translators/metalad_core_translator.py index b3b6354d..7f2eb5f0 100644 --- a/datalad_catalog/translators/metalad_core_translator.py +++ b/datalad_catalog/translators/metalad_core_translator.py @@ -140,7 +140,7 @@ def get_subdatasets(self): '"dirs_from_path": []}]' ) result = jq.first(program, self.graph) - return result if len(result) > 0 else None + return result if result is not None and len(result) > 0 else None def get_file_url(self): program = ".distribution? | .url?" diff --git a/datalad_catalog/translators/metalad_studyminimeta_translator.py b/datalad_catalog/translators/metalad_studyminimeta_translator.py index 98848684..a63f61e3 100644 --- a/datalad_catalog/translators/metalad_studyminimeta_translator.py +++ b/datalad_catalog/translators/metalad_studyminimeta_translator.py @@ -168,7 +168,7 @@ def get_funding(self): '{"name": .name, "identifier": "", "description": ""}]' ) result = jq.first(program, self.graph) # [] if nothing found - return result if len(result) > 0 else None + return result if result is not None and len(result) > 0 else None def get_publications(self): if self.combinedpersonspubs is not None: @@ -194,7 +194,7 @@ def get_subdatasets(self): '"dataset_path": .name, "dirs_from_path": []}]' ) result = jq.first(program, self.graph) # [] if nothing found - return result if len(result) > 0 else None + return result if result is not None and len(result) > 0 else None def translate(self): translated_record = {