def version_cmp(ver1, ver2):
    '''
    .. versionadded:: 2015.8.9

    Do a cmp-style comparison on two packages. Return -1 if ver1 < ver2, 0 if
    ver1 == ver2, and 1 if ver1 > ver2. Return None if there was a problem
    making the comparison.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.version_cmp '0.2-001' '0.2.0.1-002'
    '''
    try:
        if HAS_RPM:
            cmp_func = rpm.labelCompare
        elif HAS_RPMUTILS:
            cmp_func = rpmUtils.miscutils.compareEVR
        else:
            cmp_func = None
        cmp_result = cmp_func is None and 2 or cmp_func(salt.utils.str_version_to_evr(ver1),
                                                        salt.utils.str_version_to_evr(ver2))
        if (-1, 0, 1) not in cmp_result:
            raise Exception("Comparison result '{0}' is invalid".format(cmp_result))

        return cmp_result
    except Exception as exc:
        log.warning("Failed to compare version '{0}' to '{1}' using RPM: {2}".format(ver1, ver2, exc))

    return salt.utils.version_cmp(ver1, ver2)
dataset/ETHPy150Open saltstack/salt/salt/modules/rpm.py/version_cmp/swapped operands of `not in`