def generate_from_file()

in iact3/config.py [0:0]


    def generate_from_file(cls, file_path: Path, fail_ok=True, validate=True) -> dict:
        config_dict = {}
        if not file_path.is_file() and fail_ok:
            return config_dict
        try:
            with open(str(file_path), 'r', encoding='utf-8') as file_handle:
                config_dict = yaml.load(file_handle, Loader=CustomSafeLoader)
            if validate:
                try:
                    cls.from_dict(config_dict)
                except ValidationError as e:
                    LOG.warning(f'config from {file_path} is illegal.')
                    LOG.debug(str(e), exc_info=True)
                    if not fail_ok:
                        raise e
            return config_dict
        except Exception as e:
            try:
                with open(str(file_path), 'r', encoding='utf-8') as file_handle:
                    file_content = file_handle.read()
            except Exception as ex:
                LOG.warning(f'failed to load config from {file_path}')
                raise ex

            LOG.warning(f'failed to load config from {file_path}, file content is {file_content}')
            LOG.debug(str(e), exc_info=True)
            if not fail_ok:
                raise e
        return config_dict