def find_local_config()

in cid/helpers/quicksight.py [0:0]


    def find_local_config(self) -> Union[dict, None]:

        if self.localConfig:
            return self.localConfig
        # Set base paths
        abs_path = Path().absolute()

        # Load TPL file
        file_path = None
        files_to_find = [
            f'work/{self.account_id}/{self.id.lower()}-update-dashboard.json',
            f'work/{self.account_id}/{self.id.lower()}-create-dashboard.json',
            f'work/{self.account_id}/{self.id.lower()}-update-dashboard-{self.account_id}.json',
            f'work/{self.account_id}/{self.id.lower()}-create-dashboard-{self.account_id}.json',
        ]
        files_to_find += [f'work/{self.account_id}/{f.lower()}' for f in self.definition.get('localConfigs', list())]
        for file in files_to_find:
            logger.info(f'Checking local config file {file}')
            if os.path.isfile(os.path.join(abs_path, file)):
                file_path = os.path.join(abs_path, file)
                logger.info(f'Found local config file {file}, using it')
                break
            
        if file_path:
            try:
                with open(file_path) as f:
                    self.localConfig = json.loads(f.read())
                    if self.localConfig:
                        for dataset in self.localConfig.get('SourceEntity').get('SourceTemplate').get('DataSetReferences'):
                            if not self.datasets.get(dataset.get('DataSetPlaceholder')):    
                                logger.info(f"Using dataset {dataset.get('DataSetPlaceholder')} ({dataset.get('DataSetId')})")
                                self.datasets.update({dataset.get('DataSetPlaceholder'): dataset.get('DataSetArn')})
            except:
                logger.info(f'Failed to load local config file {file_path}')