Used to parse emerge output to provide meaningful output when emerge fails

def _process_emerge_err(stdout, stderr):
    '''
    Used to parse emerge output to provide meaningful output when emerge fails
    '''
    ret = {}
    rexp = re.compile(r'^[<>=][^ ]+/[^ ]+ [^\n]+', re.M)

    slot_conflicts = re.compile(r'^[^ \n]+/[^ ]+:[^ ]', re.M).findall(stderr)
    if slot_conflicts:
        ret['slot conflicts'] = slot_conflicts

    blocked = re.compile(r'(?m)^\[blocks .+\] '
                         r'([^ ]+/[^ ]+-[0-9]+[^ ]+)'
                         r'.*$').findall(stdout)

    unsatisfied = re.compile(
            r'Error: The above package list contains').findall(stderr)

    # If there were blocks and emerge could not resolve it.
    if blocked and unsatisfied:
        ret['blocked'] = blocked

    sections = re.split('\n\n', stderr)
    for section in sections:
        if 'The following keyword changes' in section:
            ret['keywords'] = rexp.findall(section)
        elif 'The following license changes' in section:
            ret['license'] = rexp.findall(section)
        elif 'The following USE changes' in section:
            ret['use'] = rexp.findall(section)
        elif 'The following mask changes' in section:
            ret['mask'] = rexp.findall(section)
    return ret