Return a tuple of (epoch, version, release) from a version string

    This function replaces rpmUtils.miscutils.stringToVersion, see
    https://bugzilla.redhat.com/1364504
320001
def string_to_version(verstring):
    
    # is there an epoch?
    components = verstring.split(':')
    if len(components) > 1:
        epoch = components[0]
    else:
        epoch = 0

    remaining = components[:2][0].split('-')
    version = remaining[0]
    release = remaining[1]

    return (epoch, version, release)
1010292
def versionstring():
    # type: () -> Text
    '''
    
    '''
    pkg = pkg_resources.require("cwltool")
    if pkg:
        return u"%s %s" % (sys.argv[0], pkg[0].version)
    return u"%s %s" % (sys.argv[0], "unknown version")
504818
def read_version():
    
    regex = re.compile('^(?P<number>\d.*?) .*$')

    with open('../CHANGELOG.rst') as f:
        for line in f:
            match = regex.match(line)
            if match:
                return match.group('number')
188916
public static function fromString(string $versionString) : Version
    {
        if (!preg_match(
            '#^'
            . '(v|release\-)?'
            . '(?P<core>(?:[0-9]|[1-9][0-9]+)(?:\.(?:[0-9]|[1-9][0-9]+)){2})'
            . '(?:\-(?P<preRelease>[0-9A-Za-z\-\.]+))?'
            . '(?:\+(?P<build>[0-9A-Za-z\-\.]+))?'
            . '$#',
            $versionString,
            $parts
        )) {
            throw InvalidVersionStringException::forVersionString($versionString);
        }

        [$major, $minor, $patch] = explode('.', $parts['core']);
        $preRelease = !empty($parts['preRelease']) ? PreRelease::fromIdentifiersString($parts['preRelease']) : new NoPreRelease();
        $build = !empty($parts['build']) ? Build::fromIdentifiersString($parts['build']) : new NoBuild();

        return static::fromParts((int) $major, (int) $minor, (int) $patch, $preRelease, $build);
    }
481418
def get_package_version(path):
    ''''''
    with open(VERSION_FILE, "rt") as f:
        verstrline = f.read()

    VERSION = r"^version = ['\"]([^'\"]*)['\"]"
    results = re.search(VERSION, verstrline, re.M)

    if results:
        version = results.group(1)
    else:
        raise RuntimeError("Unable to find version string in {}.".format(path))

    return version
217722
def getVersion(data):
    
    data = data.splitlines()
    return next((
        v
        for v, u in zip(data, data[1:])  # v = version, u = underline
        if len(v) == len(u) and allSame(u) and hasDigit(v) and "." in v
    ))
1206815
def parse_package_for_version(name):
    
    from utool import util_regex
    init_fpath = join(name, '__init__.py')
    version_errmsg = textwrap.dedent(
        '''
        You must include a __version__ variable
        in %s\'s __init__.py file.
        Try something like:
        __version__ = '1.0.0.dev1' ''' % (name,))
    if not exists(init_fpath):
        raise AssertionError(version_errmsg)
    val_regex = util_regex.named_field('version', '[0-9a-zA-Z.]+')
    regexstr = '__version__ *= *[\'"]' + val_regex
    def parse_version(line):
        # Helper
        line = line.replace(' ', '').replace('\t', '')
        match_dict = util_regex.regex_parse(regexstr, line)
        if match_dict is not None:
            return match_dict['version']
    # Find the version  in the text of the source
    #version = 'UNKNOWN_VERSION'
    with open(init_fpath, 'r') as file_:
        for line in file_.readlines():
            if line.startswith('__version__'):
                version = parse_version(line)
                if version is not None:
                    return version
    raise AssertionError(version_errmsg)
948217
def get_version():
    
    contents = read(os.path.join(PATH_BASE, 'srptools', '__init__.py'))
    version = re.search('VERSION = \(([^)]+)\)', contents)
    version = version.group(1).replace(', ', '.').strip()
    return version
354259
function parseVersion(versionString) {
  const [release, prerelease] = versionString.split('-')
  const splitRelease = release.split('.').map(number => parseInt(number, 10))

  return {
    major: splitRelease[0],
    minor: splitRelease[1],
    patch: splitRelease[2],
    prerelease: prerelease || '',
    raw: versionString
  }
}
330557
def format_version(epoch, version, release):
    '''
    
    '''
    full_version = '{0}:{1}'.format(epoch, version) if epoch else version
    if release:
        full_version += '-{0}'.format(release)
    return full_version
1063130
function(str){
        var versionArray = str.split(",");//replace with regex
        return {
            "raw":str,
            "major":parseInt(versionArray[0].split(" ")[1], 10),
            "minor":parseInt(versionArray[1], 10),
            "revision":parseInt(versionArray[2], 10),
            "revisionStr":versionArray[2]
        };
    }
229680
def parse_version(vstring):
    
    try:
        version = StrictVersion(vstring)
    except ValueError:
        logging.getLogger('ipvs.common.debug').info('Strict parsing failed, falling back to LooseVersion instead')
        version = LooseVersion(vstring)
        version.version = tuple(version.version)

    return version
510974
def parse_version_string(version_string):
    
    components = version_string.split('-') + [None, None]
    version = list(map(int, components[0].split('.')))
    build_tag = components[1] if components[1] else BUILD_TAG
    build_number = int(components[2]) if components[2] else components[2]

    return (version, build_tag, build_number)
995537
def get_version():
    
    version_file = os.path.join(PKG, 'lib/version.py')
    ver_str_line = open(version_file, "rt").read()
    version_regex = r'^__version__ = [\'"]([^\'"]*)[\'"]'
    mo = re.search(version_regex, ver_str_line, re.M)
    if mo:
        return mo.group(1)
    else:
        raise RuntimeError('Unable to find version string in %s.'
                           % (version_file,))
147682
def get_version(version):
    

    # Now build the two parts of the version number:
    # major = X.Y[.Z]
    # sub = .devN - for development releases
    #     | {a|b|rc}N - for alpha, beta and rc releases
    #     | .postN - for post-release releases

    assert len(version) == 5

    version_parts = version[:2] if version[2] == 0 else version[:3]

    # Build the first part of the version
    major = '.'.join(str(x) for x in version_parts)

    # Just return it if this is a final release version
    if version[3] == 'final':
        return major

    # Add the rest
    sub = ''.join(str(x) for x in version[3:5])

    if version[3] == 'dev':
        # Override the sub part.  Add in a timestamp
        timestamp = get_git_changeset()
        sub = 'dev%s' % (timestamp if timestamp else version[4])
        return '%s.%s' % (major, sub)
    if version[3] == 'post':
        # We need a dot for post
        return '%s.%s' % (major, sub)
    elif version[3] in ('a', 'b', 'rc'):
        # No dot for these
        return '%s%s' % (major, sub)
    else:
        raise ValueError('Invalid version: %s' % str(version))
275957
def package_with_epoch(self):
        
        return u'{0}-{1}:{2}-{3}'.format(self.name,
                                         self.epoch,
                                         self.version,
                                         self.release)
376124
def get_version():
    

    if all([VERSION, UPDATED, any([isinstance(UPDATED, date), isinstance(UPDATED, datetime), ]), ]):

        return FORMAT_STRING.format(**{"version": VERSION, "updated": UPDATED, })
    elif VERSION:

        return VERSION
    elif UPDATED:

        return localize(UPDATED) if any([isinstance(UPDATED, date), isinstance(UPDATED, datetime), ]) else ""
    else:

        return ""