def expanded_simctrl_path(self): """ Path used to load simctrl file. This allows to use a custom simctrl configuration for a target. :return: str """ return "".join(expand_searchpaths(paths=self.cfg.simctrl_path, rel_path_reference=self.prj_cfg.root))
def read_filesets(self, validate_paths=False): if os.path.isfile(self._master_cfg_path): try: mcfg = yaml.safe_load(open(self._master_cfg_path, "r")) except yaml.YAMLError as exc: raise Exception(exc) # Read source paths from master config self._parseconfig(cfg=mcfg, cfg_path=self._master_cfg_path) # Read source paths from sub configs while (bool(self._sub_config_paths)): for config in self._sub_config_paths: self._sub_config_paths.remove(config) files = expand_searchpaths(config.files, rel_path_reference=os.path.dirname(config.config_path)) for file in files: if os.path.isfile(file): try: cfg = yaml.safe_load(open(file, "r")) except yaml.YAMLError as exc: raise Exception(exc) self._parseconfig(cfg=cfg, cfg_path=file) self._config_paths.append(config) #Store processed config path else: print(f"WARNING: provided path:'{file}' does not exist, skipping config file") # Check if fileset paths exist if validate_paths: for key in self.fileset_dict.keys(): for path in self.fileset_dict[key]: if not os.path.exists(path): raise ValueError(f"Provided path:{path} of fileset:{key} does not exist") else: print(f"No config file existing, skipping to read source files.")
def expand_paths(self): """ Expand environment variables in provided list of paths. Check if path is absolute or relative, in case of a relative path, it will be expanded to an absolute path, whereas the folder of the config_file will be used to complete the path. """ self.files = expand_searchpaths(paths=self.files, rel_path_reference=os.path.dirname( self.config_path))