From f2c16de904ac007a1271d588c8e42d83cdcc3099 Mon Sep 17 00:00:00 2001 From: Joshua Hampton Date: Mon, 25 Nov 2024 15:03:13 +0000 Subject: [PATCH] Updated get instrument url functions for local file use --- src/ncas_amof_netcdf_template/file_info.py | 36 +++++++++++++--------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/src/ncas_amof_netcdf_template/file_info.py b/src/ncas_amof_netcdf_template/file_info.py index 9c4fd49..0529ad0 100644 --- a/src/ncas_amof_netcdf_template/file_info.py +++ b/src/ncas_amof_netcdf_template/file_info.py @@ -338,25 +338,33 @@ def _get_ncas_instrument_tsv_url(self) -> str: """ Get the URL for the tsv file of NCAS instruments """ - vocab_version = self._get_github_latest_version( - "https://github.com/ncasuk/ncas-data-instrument-vocabs" - ) - file_loc = ( - "https://raw.githubusercontent.com/ncasuk/ncas-data-instrument-vocabs" - ) - return f"{file_loc}/{vocab_version}/product-definitions/tsv/_instrument_vocabs/ncas-instrument-name-and-descriptors.tsv" + if self.use_local_files is not None: + main_loc = f"{self.use_local_files}/{self.tag}" + else: + vocab_version = self._get_github_latest_version( + "https://github.com/ncasuk/ncas-data-instrument-vocabs" + ) + file_loc = ( + "https://raw.githubusercontent.com/ncasuk/ncas-data-instrument-vocabs" + ) + main_loc = f"{file_loc}/{vocab_version}" + return f"{main_loc}/product-definitions/tsv/_instrument_vocabs/ncas-instrument-name-and-descriptors.tsv" def _get_community_instrument_tsv_url(self) -> str: """ Get the URL for the tsv file of NCAS instruments """ - vocab_version = self._get_github_latest_version( - "https://github.com/ncasuk/ncas-data-instrument-vocabs" - ) - file_loc = ( - "https://raw.githubusercontent.com/ncasuk/ncas-data-instrument-vocabs" - ) - return f"{file_loc}/{vocab_version}/product-definitions/tsv/_instrument_vocabs/community-instrument-name-and-descriptors.tsv" + if self.use_local_files is not None: + main_loc = f"{self.use_local_files}/{self.tag}" + else: + vocab_version = self._get_github_latest_version( + "https://github.com/ncasuk/ncas-data-instrument-vocabs" + ) + file_loc = ( + "https://raw.githubusercontent.com/ncasuk/ncas-data-instrument-vocabs" + ) + main_loc = f"{file_loc}/{vocab_version}" + return f"{main_loc}/product-definitions/tsv/_instrument_vocabs/community-instrument-name-and-descriptors.tsv" def convert_instrument_dict_to_file_info(