Source code for ibllib.misc.version

import pkg_resources


def _compare_version_tag(v1, v2, fcn):
    v1_ = ''.join(['{:03d}'.format(int(v)) for v in v1.split('.')])
    v2_ = ''.join(['{:03d}'.format(int(v)) for v in v2.split('.')])
    return fcn(v1_, v2_)


[docs]def gt(v1, v2): """ check if v1 > v2 :param v1: version string, in the form "1.23.3" :type v1: str :param v2: version string, in the form "1.23.3" :type v2: str :return: bool """ return _compare_version_tag(v1, v2, str.__gt__)
[docs]def ge(v1, v2): """ check if v1 >= v2 :param v1: version string, in the form "1.23.3" :type v1: str :param v2: version string, in the form "1.23.3" :type v2: str :return: bool """ return _compare_version_tag(v1, v2, str.__ge__)
[docs]def lt(v1, v2): """ check if v1 < v2 :param v1: version string, in the form "1.23.3" :type v1: str :param v2: version string, in the form "1.23.3" :type v2: str :return: bool """ return _compare_version_tag(v1, v2, str.__lt__)
[docs]def le(v1, v2): """ check if v1 <= v2 :param v1: version string, in the form "1.23.3" :type v1: str :param v2: version string, in the form "1.23.3" :type v2: str :return: bool """ return _compare_version_tag(v1, v2, str.__le__)
[docs]def eq(v1, v2): """ check if v1 == v2 :param v1: version string, in the form "1.23.3" :type v1: str :param v2: version string, in the form "1.23.3" :type v2: str :return: bool """ return _compare_version_tag(v1, v2, str.__eq__)
[docs]def ibllib(): try: version = pkg_resources.get_distribution("ibllib").version except pkg_resources.DistributionNotFound: version = 'unversioned' return version