Split version to a list of integers
    that can be easily compared.

    :param version: Release version
    :type version: str
    :rtype: [int] or [string]
965811
def split_version(version):
    
    if re.match("^[^0-9].*", version):
        return [version]
    return [int(i) for i in version.split(".")]
233227
def _versions_from_changelog(changelog):
    
    versions = [Version(x) for x in changelog if BUGFIX_RELEASE_RE.match(x)]
    return sorted(versions)
442557
def _parse_java_version(line: str) -> tuple:
    
    m = VERSION_RE.search(line)
    version_str = m and m.group(0).replace('"', '') or '0.0.0'
    if '_' in version_str:
        fst, snd = version_str.split('_', maxsplit=2)
        version = parse_version(fst)
        return (version[1], version[2], int(snd))
    else:
        return parse_version(version_str)
170450
def parse_version_string(version_string):
    """"""
    string_parts =  version_string.split(".")
    version_parts = [
        int(re.match("([0-9]*)", string_parts[0]).group(0)),
        int(re.match("([0-9]*)", string_parts[1]).group(0)),
        int(re.match("([0-9]*)", string_parts[2]).group(0))
    ]
    return version_parts
446489
def version_to_int(value):
    
    # remove '-SNAPSHOT'
    value = value.replace('-SNAPSHOT', '')
    # remove '-RCx'
    if '-RC' in value:
        value = value.split('-RC', 1)[0]
    try:
        return int(value.split('.')[1])
    except (ValueError, IndexError):
        return
748342
def check_version(version, range_=None):
    
    if range_ and version not in range_:
        raise RezBindError("found version %s is not within range %s"
                           % (str(version), str(range_)))
205179
def parse_version(cls, version_str):
        
        match = cls.VERSION_RE.match(version_str)
        if match:
            major = int(match.group('major'))
            minor = int(match.group('minor'))
            flags = set(match.group('flags') or '')
        else:
            major, minor, flags = None, None, set()
        return cls(major, minor, flags)
85025
def _check_version(version):
    """"""
    if version != pyphi.__version__:
        raise pyphi.exceptions.JSONVersionError(
            'Cannot load JSON from a different version of PyPhi. '
            'JSON version = {0}, current version = {1}.'.format(
                version, pyphi.__version__))
652966
def version():
    '''
    
    '''
    ret = _client_wrapper('version')
    version_re = re.compile(VERSION_RE)
    if 'Version' in ret:
        match = version_re.match(six.text_type(ret['Version']))
        if match:
            ret['VersionInfo'] = tuple(
                [int(x) for x in match.group(1).split('.')]
            )
    if 'ApiVersion' in ret:
        match = version_re.match(six.text_type(ret['ApiVersion']))
        if match:
            ret['ApiVersionInfo'] = tuple(
                [int(x) for x in match.group(1).split('.')]
            )
    return ret
635512
def _sane_version_list(version):
    
    v0 = str(version[0])
    if v0:
        # Test if the major is a number.
        try:
            v0 = v0.lstrip("v").lstrip("V")
            # Handle the common case where tags have v before major.
            v0 = int(v0)
        except ValueError:
            v0 = None

    if v0 is None:
        version = [0, 0] + version
    else:
        version[0] = v0

    try:
        # Test if the minor is a number.
        version[1] = int(version[1])
    except ValueError:
        # Insert Minor 0.
        version = [version[0], 0] + version[1:]

    return version
44869
def _version_from_file(lines):
    
    def is_version_line(line):
        return line.lower().startswith('version:')
    version_lines = filter(is_version_line, lines)
    line = next(iter(version_lines), '')
    _, _, value = line.partition(':')
    return safe_version(value.strip()) or None
846959
def _parse_version(self, line):
        
        version_string = line.split(' ')[1]
        version_list = version_string.split('.')
        major_version = ''.join([version_list[0], version_list[1]])
        release_num = ''.join([version_list[2].rstrip(), "-03"])
        return (major_version, release_num)
652015
private int[] parse(String version) {
        final Matcher m = Pattern.compile("(\\d+)\\.(\\d+)\\.(\\d+)-?(SNAPSHOT)?\\.?(\\d*)?").matcher(version);
        if (!m.matches()) {
            throw new IllegalArgumentException("Malformed version string: " + version);
        }

        return new int[] {Integer.parseInt(m.group(1)),   // major
                Integer.parseInt(m.group(2)),             // minor
                Integer.parseInt(m.group(3)),             // revision
                m.group(4) == null ? 0                    // no SNAPSHOT suffix
                        : m.group(5).isEmpty() ? 0        // "SNAPSHOT"
                        : Integer.parseInt(m.group(5)),   // "SNAPSHOT.123"
        };
    }
219447
def version(*names, **kwargs):
    '''
    
    '''
    ret = {}
    versions_as_list = \
        salt.utils.data.is_true(kwargs.pop('versions_as_list', False))
    pkg_glob = False
    if names:
        pkgs = __salt__['pkg.list_pkgs'](versions_as_list=True, **kwargs)
        for name in names:
            if '*' in name:
                pkg_glob = True
                for match in fnmatch.filter(pkgs, name):
                    ret[match] = pkgs.get(match, [])
            else:
                ret[name] = pkgs.get(name, [])
    if not versions_as_list:
        __salt__['pkg_resource.stringify'](ret)
    # Return a string if no globbing is used, and there is one item in the
    # return dict
    if len(ret) == 1 and not pkg_glob:
        try:
            return next(six.itervalues(ret))
        except StopIteration:
            return ''
    return ret
348577
def _str_to_version(version_str, allow_wildcard=False):
  """"""
  reg = _VERSION_WILDCARD_REG if allow_wildcard else _VERSION_RESOLVED_REG
  res = reg.match(version_str)
  if not res:
    msg = "Invalid version '{}'. Format should be x.y.z".format(version_str)
    if allow_wildcard:
      msg += " with {x,y,z} being digits or wildcard."
    else:
      msg += " with {x,y,z} being digits."
    raise ValueError(msg)
  return tuple(
      v if v == "*" else int(v)
      for v in [res.group("major"), res.group("minor"), res.group("patch")])
1078644
def almost_the_same_version(
        self, version_list
    ):  # type: (List[str]) -> Optional[str]
        

        version_list = list(set(version_list))
        try:
            sem_ver_list = list(
                set([unicode(Version(x)) for x in version_list])
            )  # type: List[Version]
        except ValueError:
            # I hope htat was a bad semver
            return None

        # should be good sem vers from here
        if len(sem_ver_list) == 2:
            if (
                sem_ver_list[0] == unicode(Version(sem_ver_list[1]).next_patch())
                or unicode(Version(sem_ver_list[0]).next_patch()) == sem_ver_list[1]
            ):
                if sem_ver_list[0] > sem_ver_list[1]:
                    return unicode(sem_ver_list[0])
                return unicode(sem_ver_list[1])
        return None
1216750
def all_versions_equal(self, versions):  # type: (Dict[str,str]) -> bool
        
        if len(versions) <= 1:
            return True

        semver = None
        for key, version in versions.items():
            if semver is None:
                try:
                    semver, _, __ = version_object_and_next(version)
                except ValueError:
                    logger.error("Invalid version at:" + unicode((key, version)))
                    return False
                continue
            try:
                version_as_version, _, __ = version_object_and_next(version)
            except:
                return False
            if version_as_version != semver:
                return False
        return True