def load_with_config(filename: Union[str, List[str]], config: dict) -> Any: """Load yaml config files with case statement handling. :param filename: a path or list of path. When a list of path is given, config files are loaded in order each one updating the result of the previous parsing. :param config: initial state :return: the final object """ if isinstance(filename, str): filename = [filename] result = None parser = CaseParser(config) for f in filename: try: e3.log.debug("load config file: %s", f) conf_data = load_ordered(f) result = parser.parse(conf_data) except OSError: raise YamlError(f"cannot read: {f}", "load_with_config").with_traceback( sys.exc_info()[2] ) except (yaml.parser.ParserError, yaml.constructor.ConstructorError) as e: raise YamlError( f"{f} is an invalid yaml file: {e}", "load_with_config" ).with_traceback(sys.exc_info()[2]) return result
def load_with_config(filename, config): """Load yaml config files with case statement handling. :param filename: a path or list of path. When a list of path is given, config files are loaded in order each one updating the result of the previous parsing. :type filename: str | list[str] :param config: initial state :type config: dict :return: the final object """ if isinstance(filename, basestring): filename = [filename] result = None parser = CaseParser(config) for f in filename: try: e3.log.debug('load config file: %s', f) conf_data = load_ordered(f) result = parser.parse(conf_data) except IOError: raise YamlError("cannot read: %s" % f, 'load_with_config'), None, sys.exc_traceback except (yaml.parser.ParserError, yaml.constructor.ConstructorError) as e: raise YamlError('%s is an invalid yaml file: %s' % (f, e), 'load_with_config'), None, sys.exc_traceback return result