(lines, multiline_values=True, key_hints=None)
return rtn
Utility method to parse name=value pairs (GETINFO etc). Takes a
    string with newline-separated lines and expects at most one = sign
    per line. Accumulates multi-line values.

    :param multiline_values:
        The default is True which allows for multi-line values until a
        line with the next = sign on it. So: '''Foo=bar\nBar'''
        produces one key, 'Foo', with value 'bar\nBar' -- set to
        False, there would be two keys: 'Foo' with value 'bar' and
        'Bar' with value DEFAULT_VALUE.
Utility method to parse name=value pairs (GETINFO etc). Takes a
    string with newline-separated lines and expects at most one = sign
    per line. Accumulates multi-line values.
Utility method to parse name = value pairs ( GETINFO etc ) . Takes a string with newline - separated lines and expects at most one = sign per line . Accumulates multi - line values .
def parse_keywords(lines, multiline_values=True, key_hints=None):
    """
    Utility method to parse name=value pairs (GETINFO etc). Takes a
    string with newline-separated lines and expects at most one = sign
    per line. Accumulates multi-line values.

    :param multiline_values:
        The default is True which allows for multi-line values until a
        line with the next = sign on it. So: '''Foo=bar\nBar'''
        produces one key, 'Foo', with value 'bar\nBar' -- set to
        False, there would be two keys: 'Foo' with value 'bar' and
        'Bar' with value DEFAULT_VALUE.
    """

    rtn = {}
    key = None
    value = ''
    # FIXME could use some refactoring to reduce code duplication!
    for line in lines.split('\n'):
        if line.strip() == 'OK':
            continue

        sp = line.split('=', 1)
        found_key = ('=' in line and ' ' not in sp[0])
        if found_key and key_hints and sp[0] not in key_hints:
            found_key = False
        if found_key:
            if key:
                if key in rtn:
                    if isinstance(rtn[key], list):
                        rtn[key].append(unquote(value))
                    else:
                        rtn[key] = [rtn[key], unquote(value)]
                else:
                    rtn[key] = unquote(value)
            (key, value) = line.split('=', 1)

        else:
            if key is None:
                rtn[line.strip()] = DEFAULT_VALUE

            elif multiline_values is False:
                rtn[key] = value
                rtn[line.strip()] = DEFAULT_VALUE
                key = None
                value = ''

            else:
                value = value + '\n' + line
    if key:
        if key in rtn:
            if isinstance(rtn[key], list):
                rtn[key].append(unquote(value))
            else:
                rtn[key] = [rtn[key], unquote(value)]
        else:
            rtn[key] = unquote(value)
    return rtn
def parse_keywords ( lines , multiline_values = True , key_hints = None ) : rtn = { } key = None value = '' # FIXME could use some refactoring to reduce code duplication! for line in lines . split ( '\n' ) : if line . strip ( ) == 'OK' : continue sp = line . split ( '=' , 1 ) found_key = ( '=' in line and ' ' not in sp [ 0 ] ) if found_key and key_hints and sp [ 0 ] not in key_hints : found_key = False if found_key : if key : if key in rtn : if isinstance ( rtn [ key ] , list ) : rtn [ key ] . append ( unquote ( value ) ) else : rtn [ key ] = [ rtn [ key ] , unquote ( value ) ] else : rtn [ key ] = unquote ( value ) ( key , value ) = line . split ( '=' , 1 ) else : if key is None : rtn [ line . strip ( ) ] = DEFAULT_VALUE elif multiline_values is False : rtn [ key ] = value rtn [ line . strip ( ) ] = DEFAULT_VALUE key = None value = '' else : value = value + '\n' + line if key : if key in rtn : if isinstance ( rtn [ key ] , list ) : rtn [ key ] . append ( unquote ( value ) ) else : rtn [ key ] = [ rtn [ key ] , unquote ( value ) ] else : rtn [ key ] = unquote ( value ) return rtn