def _parse_config(self, config_str, generate_unknown_reference_errors=False): parser = config_parser.ConfigParser( config_str, _TestParserDelegate(generate_unknown_reference_errors)) config = {} imports = [] includes = [] blocks = [] for statement in parser: if isinstance(statement, config_parser.BindingStatement): scope, selector, arg_name, value, _ = statement config.setdefault((scope, selector), {})[arg_name] = value elif isinstance(statement, config_parser.BlockDeclaration): blocks.append(statement) elif isinstance(statement, config_parser.ImportStatement): imports.append(statement) elif isinstance(statement, config_parser.IncludeStatement): includes.append(statement.filename) return _ParsedConfig(config=config, imports=imports, includes=includes, blocks=blocks)
def _parse_config(self, config_str, only_bindings=True, generate_unknown_reference_errors=False): parser = config_parser.ConfigParser( config_str, _TestParserDelegate(generate_unknown_reference_errors)) config = {} imports = [] includes = [] for statement in parser: if isinstance(statement, config_parser.BindingStatement): scope, selector, arg_name, value, _ = statement config.setdefault((scope, selector), {})[arg_name] = value elif isinstance(statement, config_parser.ImportStatement): imports.append(statement.module) elif isinstance(statement, config_parser.IncludeStatement): includes.append(statement.filename) if only_bindings: return config return config, imports, includes
def _parse_value(self, literal): parser = config_parser.ConfigParser(literal, _TestParserDelegate()) return parser.parse_value()