msaf/configparser.py
def parse_config_string(config_string, issue_warnings=True):
    """
    Parses a config string (comma-separated key=value components) into a dict.
    """
    config_dict = {}
    my_splitter = shlex.shlex(config_string, posix=True)
    my_splitter.whitespace = ','
    my_splitter.whitespace_split = True
    for kv_pair in my_splitter:
        kv_pair = kv_pair.strip()
        if not kv_pair:
            continue
        kv_tuple = kv_pair.split('=', 1)
        if len(kv_tuple) == 1:
            if issue_warnings:
                MsafConfigWarning.warn(
                    ("Config key '%s' has no value, ignoring it" %
                     kv_tuple[0]), stacklevel=1)
        else:
            k, v = kv_tuple
            # subsequent values for k will override earlier ones
            config_dict[k] = v
    return config_dict
def parse_config_string(config_string, issue_warnings=True):
    """
    Parses a config string (comma-separated key=value components) into a dict.
    """
    config_dict = {}
    my_splitter = shlex.shlex(config_string, posix=True)
    my_splitter.whitespace = ','
    my_splitter.whitespace_split = True
    for kv_pair in my_splitter:
        kv_pair = kv_pair.strip()
        if not kv_pair:
            continue
        kv_tuple = kv_pair.split('=', 1)
        if len(kv_tuple) == 1:
            if issue_warnings:
                MsafConfigWarning.warn(
                    ("Config key '%s' has no value, ignoring it" %
                     kv_tuple[0]), stacklevel=1)
        else:
            k, v = kv_tuple
            # subsequent values for k will override earlier ones
            config_dict[k] = v
    return config_dict
def parse_config_string ( config_string , issue_warnings = True ) : config_dict = { } my_splitter = shlex . shlex ( config_string , posix = True ) my_splitter . whitespace = ',' my_splitter . whitespace_split = True for kv_pair in my_splitter : kv_pair = kv_pair . strip ( ) if not kv_pair : continue kv_tuple = kv_pair . split ( '=' , 1 ) if len ( kv_tuple ) == 1 : if issue_warnings : MsafConfigWarning . warn ( ( "Config key '%s' has no value, ignoring it" % kv_tuple [ 0 ] ) , stacklevel = 1 ) else : k , v = kv_tuple # subsequent values for k will override earlier ones config_dict [ k ] = v return config_dict
Parses a config string (comma-separated key=value components) into a dict.
Parses a config string ( comma - separated key = value components ) into a dict .