def dict_from_string(string): """ Parse `string` and return a dictionary that can be used to construct/override a ProblemConf instance. """ if string is None: return {} if isinstance(string, dict): return string parser = create_bnf() out = {} for r in parser.parseString(string): out.update(r) return out
def dict_from_string(string): """ Parse `string` and return a dictionary that can be used to construct/override a ProblemConf instance. """ if string is None: return {} if isinstance(string, dict): return string parser = create_bnf() out = {} for r in parser.parseString(string, parseAll=True): out.update(r) return out
def dict_from_string(string, allow_tuple=False, free_word=False): """ Parse `string` and return a dictionary that can be used to construct/override a ProblemConf instance. """ if string is None: return {} if isinstance(string, dict): return string parser = create_bnf(allow_tuple=allow_tuple, free_word=free_word) out = {} for r in parser.parseString(string, parseAll=True): out.update(r) return out