human
Complete this python program:
def _cmp_by_origin(path1, path2):
assistant
#Here is the Python code you requested.

    """Select the best path based on origin attribute.
    IGP is preferred over EGP; EGP is preferred over Incomplete.
    If both paths have same origin, we return None.
    """
    def get_origin_pref(origin):
        if (origin.value == BGP_ATTR_ORIGIN_IGP):
            return 3
        elif (origin.value == BGP_ATTR_ORIGIN_EGP):
            return 2
        elif (origin.value == BGP_ATTR_ORIGIN_INCOMPLETE):
            return 1
        else:
            LOG.error('Invalid    origin    value    encountered    %s.', origin)
            return 0
    origin1 = path1.get_pattr(BGP_ATTR_TYPE_ORIGIN)
    origin2 = path2.get_pattr(BGP_ATTR_TYPE_ORIGIN)
    assert ((origin1 is not None) and (origin2 is not None))
    if (origin1.value == origin2.value):
        return None
    origin1 = get_origin_pref(origin1)
    origin2 = get_origin_pref(origin2)
    if (origin1 == origin2):
        return None
    elif (origin1 > origin2):
        return path1
    return path2