def load_yaml(self, config_files, file_names_as_key=False, return_config=False): """Load file (or files). Args: config_files: Preferably list of file paths file_names_as_key: False | True return_config: False | True """ if not isinstance(config_files, (list, np.ndarray)): config_files = [config_files] for config_file in config_files: with open(config_file, encoding='cp1252') as fd: try: file = yaml.load(fd, Loader=yaml.FullLoader) except yaml.YAMLError: file = yaml.safe_load(fd) if file_names_as_key: file_name = self.get_file_name(config_file) self.config[file_name] = file else: self.config = utils.recursive_dict_update( self.config, file) if return_config: return self.config
def get_metadata(self, serie, map_keys=True, **kwargs): """Return dictionary with metadata.""" meta_dict = {} data = self.get_meta_dict( serie, identifier=self.settings.datasets['vp2'].get('identifier_metadata'), separator=self.settings.datasets['vp2'].get('separator_metadata'), keys=self.settings.datasets['vp2'].get('keys_metadata'), ) meta_dict = utils.recursive_dict_update(meta_dict, data) if map_keys: meta_dict = {self.settings.pmap.get(key): meta_dict[key] for key in meta_dict} return meta_dict
def get_metadata(self, serie, map_keys=True, filename=None): """Return dictionary with metadata.""" meta_dict = {} for ident, sep in zip(['identifier_metadata', 'identifier_metadata_2'], ['separator_metadata', 'separator_metadata_2']): data = self.get_meta_dict(serie, identifier=self.settings.datasets['cnv'].get(ident), separator=self.settings.datasets['cnv'].get(sep), keys=self.settings.datasets['cnv'].get('keys_metadata')) meta_dict = utils.recursive_dict_update(meta_dict, data) if map_keys: meta_dict = {self.settings.pmap.get(key): meta_dict[key] for key in meta_dict} return meta_dict