def read_user_config(directory: str) -> UserConfig: try: profile = read_profile(directory) if profile: user_cfg = coerce_dict_str(profile.get('config', {})) if user_cfg is not None: return UserConfig.from_dict(user_cfg) except (RuntimeException, ValidationError): pass return UserConfig()
def get_key_dicts(self) -> Iterable[Dict[str, Any]]: data = self.yaml.data.get(self.key, []) if not isinstance(data, list): raise CompilationException( '{} must be a list, got {} instead: ({})'.format( self.key, type(data), _trimmed(str(data)))) path = self.yaml.path.original_file_path for entry in data: if coerce_dict_str(entry) is not None: yield entry else: msg = error_context(path, self.key, data, 'expected a dict with string keys') raise CompilationException(msg)