Internal function to convert a version string to an integer.
489145
def _revint(self, version):
        '''
        
        '''
        intrev = 0
        vsplit = version.split('.')
        for c in range(len(vsplit)):
            item = int(vsplit[c]) * (10 ** (((len(vsplit) - c - 1) * 2)))
            intrev += item
        return intrev
767729
def bump_version(version, bump='patch'):
    """"""
    try:
        parts = map(int, version.split('.'))
    except ValueError:
        fail('Current version is not numeric')

    if bump == 'patch':
        parts[2] += 1
    elif bump == 'minor':
        parts[1] += 1
        parts[2] = 0
    elif bump == 'major':
        parts[0] +=1
        parts[1] = 0
        parts[2] = 0

    return '.'.join(map(str, parts))
513638
def version_to_string(version):
        
        c_string = cairo.cairo_svg_version_to_string(version)
        if c_string == ffi.NULL:
            raise ValueError(version)
        return ffi.string(c_string).decode('ascii')
681517
public static int parseVersionSpec(String versionString) throws NumberFormatException {
        if (versionString == null)
            return 0;
        int dot = versionString.indexOf('.');
        int major, minor;
        if (dot > 0) {
            major = Integer.parseInt(versionString.substring(0, dot));
            minor = Integer.parseInt(versionString.substring(dot + 1));
        }
        else {
            major = Integer.parseInt(versionString);
            minor = 0;
        }
        return major * 1000 + minor;
    }
1028391
def version_parser(version_string):
    
    version, commit, branch = version_string.split('-', 3)

    # Remove the "v"
    version_number = version[1:]
    version_number = int(version_number)

    return Version(version_number, commit, branch)
1114572
def get_version():
    """"""
    if isinstance(VERSION[-1], str):
        return '.'.join(map(str, VERSION[:-1])) + VERSION[-1]
    return '.'.join(map(str, VERSION))
739144
def iddversiontuple(afile):
    """"""
    def versiontuple(vers):
        """version tuple"""
        return tuple([int(num) for num in vers.split(".")])
    try:
        fhandle = open(afile, 'rb')
    except TypeError:
        fhandle = afile
    line1 = fhandle.readline()
    try:
        line1 = line1.decode('ISO-8859-2')
    except AttributeError:
        pass
    line = line1.strip()
    if line1 == '':
        return (0,)
    vers = line.split()[-1]
    return versiontuple(vers)
982799
def to_ints(version):
        

        # Example strings: "NSS_3_7_9_RTM", "NSS_3_6_BRANCH_20021026", "NSS_3_6_BETA2",
        #                  "3.18 Basic ECC Beta", "3.16.5 Basic ECC"

        # normalize version strings
        norm_version = version.replace('NSS_', '').replace('.', '_').replace(' ', '_').upper().split('_')

        # Asserting minimumum length of 3 as in [major,minor,tag]
        assert len(norm_version) >= 3

        # Asserting the first two fields are numeric major and minor
        assert norm_version[0].isdigit() and norm_version[1].isdigit()

        # Asserting last field is always a non-numeric tag or a date tag
        # CAVE: fails with obscure date dags like certdata.txt-NSS_3_4_20020403_2
        assert not norm_version[-1].isdigit() or len(norm_version[-1]) > 2

        # fill in missing point and pointpoint versions
        if not (norm_version[2].isdigit() and len(norm_version[2]) < 4):  # <4 to distinguish from numeric date tags
            norm_version.insert(2, "0")
        if not (norm_version[3].isdigit() and len(norm_version[3]) < 4):
            norm_version.insert(3, "0")

        # Strictly ordering by RTM > RC > BETA > *
        # CAVE: Order rule may result in bogus sorting of obscure tags (WITH_CBKI*, TPATCH*, BRANCHPOINT*, ...)
        # Recent versions are tagged non-obscurely and consistently

        tag_value = 0
        for v in norm_version[4:]:
            if v.startswith('BETA'):
                tag_value = 100
                if len(v[4:]) == 1 or len(v[4:]) == 2:
                    try:
                        tag_value += int(v[4:])
                    except ValueError:
                        pass
        for v in norm_version[4:]:
            if v.startswith('RC'):
                tag_value = 200
                if len(v[3:]) == 1 or len(v[3:]) == 2:
                    try:
                        tag_value += int(v[3:])
                    except ValueError:
                        pass
        for v in norm_version[4:]:
            if v == 'RTM':
                tag_value = 300

        # Special case: "x.y.z Basic ECC" is counted as RTM
        # TODO: research the set of potential version string formats reported by libnss.
        if norm_version[-2] == 'BASIC' and norm_version[-1] == 'ECC' and norm_version[-3].isdigit():
            tag_value = 300

        major, minor, point, pointpoint = (int(x) for x in norm_version[:4])

        return [major, minor, point, pointpoint, tag_value]
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)
635279
def _asString(self, value):
        """"""
        if sys.version_info[0] == 3:
            if isinstance(value, str):
                return value
            elif isinstance(value, bytes):
                return value.decode('utf-8')
        elif sys.version_info[0] == 2:
            return value.encode('ascii')
377445
private static int[] toJavaVersionIntArray(String version, int limit) {
        if (version == null) {
            return ArrayUtils.EMPTY_INT_ARRAY;
        }
        String[] strings = StringUtils.split(version, "._- ");
        int[] ints = new int[Math.min(limit, strings.length)];
        int j = 0;
        for (int i = 0; i < strings.length && j < limit; i++) {
            String s = strings[i];
            if (s.length() > 0) {
                try {
                    ints[j] = Integer.parseInt(s);
                    j++;
                } catch (Exception e) {
                }
            }
        }
        if (ints.length > j) {
            int[] newInts = new int[j];
            System.arraycopy(ints, 0, newInts, 0, j);
            ints = newInts;
        }
        return ints;
    }
1094892
function toVersionString(versions) {
  return Object.keys(versions).sort().filter(key => versions[key]).map((key) => {
    return versions[key] ? `${key}@${versions[key]}` : '';
  }).join(', ');
}
393968
def version(modfile):
    '''
    
    '''
    import re
    with open(modfile) as fh:
        for line in fh:
            m = re.search(r"^__version__ = '([^']+)'$", line)
            if m:
                return m.group(1)
    raise Exception('No __version__ string found in {fn}'.format(fn=modfile))
22625
def cleanupversion(ver):
    """"""
    lst = ver.split(".")
    if len(lst) == 1:
        lst.extend(['0', '0'])
    elif len(lst) == 2:
        lst.extend(['0'])
    elif len(lst) > 2:
        lst = lst[:3]
    lst[2] = '0' # ensure the 3rd number is 0    
    cleanver = '.'.join(lst)
    return cleanver
1172960
private static int toInt(String str, int defaultVal) {
    try {
      return Integer.parseInt(str.trim());
    } catch (Exception e) {
      return defaultVal;
    }
  }
1064141
def get_version(path):
    """"""

    with open(os.path.join(path, 'VERSION'), 'rb') as f:
        version = f.read().decode('ascii').strip()
    return version.strip()
934924
private static String parseVersionNumber(String line) {
        StringTokenizer tokenizer = new StringTokenizer(line, " \t");

        if (!expect(tokenizer, "sourceInfo") || !expect(tokenizer, "version") || !tokenizer.hasMoreTokens()) {
            return null;
        }

        return tokenizer.nextToken();
    }