示例#1
0
    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
示例#2
0
文件: conf.py 项目: LeiDai/sfepy
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
示例#3
0
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