import re


def parse_show_ip_ospf_neighbor(raw_result):
    """
    Parse the 'show ip ospf neighbor' command raw output.

    :param str raw_result: vtysh raw result string.
    :rtype: dict
    :return: The parsed result of the show ip ospf neighbor command in a \
        dictionary of the form:

     ::

        {
            'neighbor_id': '2.2.2.2',
            'priority': '1',
            'state': 'Full/Backup',
            'dead_time': '31.396s',
            'address': '10.0.1.1',
            'interface': '1:10.0.1.2/24',
            'rxmtl': '0',
            'rqstl': '0',
            'dbsml': '0'
        }
    """

    neighbor_re = (
        r'(?P<neighbor_id>[^ ]+)\s*(?P<priority>[^ ]+)\s*'
        '(?P<state>[^ ]+)'
        r'\s*(?P<dead_time>[^ ]+)\s*(?P<address>[^ ]+)\s*'
        '(?P<interface>[^ ]+)'
        r'\s*(?P<rxmtl>[^ ]+)\s*(?P<rqstl>[^ ]+)\s*(?P<dbsml>[^ ])'
    )

    result = {}
    pattern_found = False
    for line in raw_result.splitlines():
        if (pattern_found is True):
            re_result = re.search(neighbor_re, line)
            if (re_result):
                partial = re_result.groupdict()
                result[partial['neighbor_id']] = partial
        else:
            re_result = re.search('-+\s*-+', line)
            if (re_result):
                pattern_found = True

    return result