import re


def _parse_keyvals(keyvals):
    """Parse the key=val pairs from the newline-separated string.

    :param keyvals: Newline-separated string with key=val pairs
    :rtype: Dict of key=val pairs.
    """
    re_keyval = re.compile(r'([\w_]+) \s* = \s* (.*)', re.VERBOSE)
    keyvalout = {}
    for keyval in keyvals:
        m = re.search(re_keyval, keyval.strip())
        if m:
            key, val = m.groups()
            keyvalout[key] = val
    return keyvalout