From 5429b5ca767892eba2548fea660d295f62f68ea7 Mon Sep 17 00:00:00 2001 From: caufieldjh <j.harry.caufield@gmail.com> Date: Wed, 4 Sep 2024 17:50:33 -0400 Subject: [PATCH] Truncate overly verbose version texts --- src/kg_bioportal/downloader.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/kg_bioportal/downloader.py b/src/kg_bioportal/downloader.py index 8bc64bd..eae80e3 100644 --- a/src/kg_bioportal/downloader.py +++ b/src/kg_bioportal/downloader.py @@ -105,6 +105,8 @@ def get_ontology_list(self) -> None: """Get the list of ontologies from BioPortal. This includes the descriptive name and most recent version. + Some versions are not specified, while others are verbose. + In the latter case, they are truncated to the first three words. Args: None. @@ -136,8 +138,14 @@ def get_ontology_list(self) -> None: name = metadata["name"].replace("\n", " ").replace("\t", " ") if len(latest_submission) > 0: - if current_version: - current_version = latest_submission["version"].replace("\n", " ").replace("\t", " ") + if latest_submission["version"]: + current_version = " ".join( + ( + latest_submission["version"] + .replace("\n", " ") + .replace("\t", " ") + ).split()[:3] + ) else: current_version = "NA" submission_id = latest_submission["submissionId"]