Loading csp-lmc-common/csp_lmc_common/csp_manage_json.py +22 −5 Original line number Diff line number Diff line import json from ska_telmodel.csp.schema import validate_csp_config class ManageJson: class JsonConfiguration: """ A set of methods to manage the json configuration inside CSP code """ def __init__(self, json_config:str, logger): self.major_version=None self.minor_version=None Loading @@ -9,6 +12,9 @@ class ManageJson: self.logger = logger def detect_version(self): """ Detect the version of the json configuration """ #ADR-22 if 'interface' in self.config.keys(): interface = self.config['interface'] Loading @@ -16,7 +22,7 @@ class ManageJson: self.major_version = int(version_str.split('.')[0]) self.minor_version = int(version_str.split('.')[1]) #ADR-18 elif 'common' in config.keys(): elif 'common' in self.config.keys(): self.major_version = 0 self.minor_version = 2 #pre ADR-18 Loading @@ -24,9 +30,12 @@ class ManageJson: self.major_version = 0 self.minor_version = 1 self.version = [self.major_version, self.minor_version] self.logger.info(f'Version is{major_version}{minor_version}') self.logger.info(f'Version is{self.major_version}{self.minor_version}') def get_section(self, name:str): """ Returns the correpondant section of json configuration """ try: return self.config[name] except KeyError as e: Loading @@ -34,13 +43,21 @@ class ManageJson: raise ValueError(e) from e def conversion_02_01(self): """ Converts the json from version 0.2 to version 0.1 """ common_dict = self.get_section('common') cbf_dict = self.get_section('cbf') config_converted = {**common_dict, **cbf_dict} validate_csp_config(0, config_converted) validate_csp_config(version=0, template=True, config=config_converted) #check template parameter self.config = config_converted def build_json(self): def build_json_cbf(self) -> dict: " Returns the json configuration dictionary to be passed to cbf. If a version 0.2 is given, it converts to 0.1 " self.detect_version() if self.version == [0, 1]: pass elif self.version == [0,2]: Loading Loading
csp-lmc-common/csp_lmc_common/csp_manage_json.py +22 −5 Original line number Diff line number Diff line import json from ska_telmodel.csp.schema import validate_csp_config class ManageJson: class JsonConfiguration: """ A set of methods to manage the json configuration inside CSP code """ def __init__(self, json_config:str, logger): self.major_version=None self.minor_version=None Loading @@ -9,6 +12,9 @@ class ManageJson: self.logger = logger def detect_version(self): """ Detect the version of the json configuration """ #ADR-22 if 'interface' in self.config.keys(): interface = self.config['interface'] Loading @@ -16,7 +22,7 @@ class ManageJson: self.major_version = int(version_str.split('.')[0]) self.minor_version = int(version_str.split('.')[1]) #ADR-18 elif 'common' in config.keys(): elif 'common' in self.config.keys(): self.major_version = 0 self.minor_version = 2 #pre ADR-18 Loading @@ -24,9 +30,12 @@ class ManageJson: self.major_version = 0 self.minor_version = 1 self.version = [self.major_version, self.minor_version] self.logger.info(f'Version is{major_version}{minor_version}') self.logger.info(f'Version is{self.major_version}{self.minor_version}') def get_section(self, name:str): """ Returns the correpondant section of json configuration """ try: return self.config[name] except KeyError as e: Loading @@ -34,13 +43,21 @@ class ManageJson: raise ValueError(e) from e def conversion_02_01(self): """ Converts the json from version 0.2 to version 0.1 """ common_dict = self.get_section('common') cbf_dict = self.get_section('cbf') config_converted = {**common_dict, **cbf_dict} validate_csp_config(0, config_converted) validate_csp_config(version=0, template=True, config=config_converted) #check template parameter self.config = config_converted def build_json(self): def build_json_cbf(self) -> dict: " Returns the json configuration dictionary to be passed to cbf. If a version 0.2 is given, it converts to 0.1 " self.detect_version() if self.version == [0, 1]: pass elif self.version == [0,2]: Loading