Get the pkgin version
542581
def _get_version():
    '''
    
    '''
    version_string = __salt__['cmd.run'](
        [_check_pkgin(), '-v'],
        output_loglevel='trace')
    if version_string is None:
        # Dunno why it would, but...
        return False

    version_match = VERSION_MATCH.search(version_string)
    if not version_match:
        return False

    return version_match.group(1).split('.')
1374465
def load_version():
    """"""
    filename = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                            "cpt", "__init__.py"))
    with open(filename, "rt") as version_file:
        conan_init = version_file.read()
        version = re.search("__version__ = '([0-9a-z.-]+)'", conan_init).group(1)
        return version
866687
def upgrade_available(name, **kwargs):
    '''
    
    '''
    version = None
    cmd = ['pkg', 'list', '-Huv', name]
    lines = __salt__['cmd.run_stdout'](cmd).splitlines()
    if not lines:
        return {}
    ret = {}
    for line in lines:
        ret[_ips_get_pkgname(line)] = _ips_get_pkgversion(line)
    return ret
680358
def _check_version():
    """"""
    from ._config import APP_NAME

    if VersionCache.load(APP_NAME).is_fresh:
        return

    from pkg_resources import parse_version
    from renku.version import __version__

    version = parse_version(__version__)
    allow_prereleases = version.is_prerelease

    latest_version = find_latest_version(
        'renku', allow_prereleases=allow_prereleases
    )

    if version < latest_version:
        click.secho(
            'You are using renku version {version}, however version '
            '{latest_version} is available.\n'
            'You should consider upgrading ...'.format(
                version=__version__,
                latest_version=latest_version,
            ),
            fg='yellow',
            bold=True,
        )

    VersionCache(pypi_version=str(latest_version)).dump(APP_NAME)
645265
def _get_pkg_meta(self):
        
        logger = logging.getLogger('pyrocore.scripts.base.version_info')
        pkg_info = None
        warnings = []

        for info_ext, info_name in (('.dist-info', 'METADATA'), ('.egg-info', 'PKG-INFO')):
            try:
                # Development setup
                pkg_path = os.path.join(
                    __file__.split(__name__.replace('.', os.sep))[0],  # containing path
                    __name__.split(".")[0]  # package name
                )
                if os.path.exists(pkg_path + info_ext):
                    pkg_path += info_ext
                else:
                    globbed_paths = glob.glob(pkg_path + "-*-py%d.%d" % sys.version_info[:2] + info_ext)
                    if len(globbed_paths) == 1:
                        pkg_path = globbed_paths[0]
                    elif globbed_paths:
                        warnings.append("Found {} release-specific candidate versions in *{}"
                                        .format(len(globbed_paths), info_ext))
                        pkg_path = None
                    else:
                        globbed_paths = glob.glob(pkg_path + "-*" + info_ext)
                        if len(globbed_paths) == 1:
                            pkg_path = globbed_paths[0]
                        else:
                            warnings.append("Found {} candidate versions in *{}"
                                            .format(len(globbed_paths), info_ext))
                            pkg_path = None
                if pkg_path:
                    with open(os.path.join(pkg_path, info_name)) as handle:
                        pkg_info = handle.read()
                    break
            except IOError:
                continue

        if not pkg_info:
            logger.warn("Software version cannot be determined! ({})".format(', '.join(warnings)))

        return pkg_info or "Version: 0.0.0\n"
894605
def versions_installed(pkg):
    '''
    
    '''

    try:
        # Try to run it, merging stderr into output
        output = subprocess.check_output([SNAP_BINARY_NAME, 'list', pkg], stderr=subprocess.STDOUT)
    except subprocess.CalledProcessError:
        return []

    lines = output.splitlines()[1:]
    ret = []
    for item in lines:
        # If fields contain spaces this will break.
        i = item.split()
        # Ignore 'Notes' field
        ret.append({
            'name':         i[0],
            'version':      i[1],
            'rev':          i[2],
            'tracking':     i[3],
            'publisher':    i[4]
            })

    return ret
699308
def get_version(cls):
        
        cmd_pieces = [cls.tool, '--version']
        process = Popen(cmd_pieces, stdout=PIPE, stderr=PIPE)
        out, err = process.communicate()
        if err:
            return ''
        else:
            return out.splitlines()[0].strip()
1192555
def _smartos_zone_pkgin_data():
    '''
    
    '''
    # Provides:
    #   pkgin_repositories

    grains = {
        'pkgin_repositories': [],
    }

    pkginrepo = re.compile('^(?:https|http|ftp|file)://.*$')
    if os.path.isfile('/opt/local/etc/pkgin/repositories.conf'):
        with salt.utils.files.fopen('/opt/local/etc/pkgin/repositories.conf', 'r') as fp_:
            for line in fp_:
                line = salt.utils.stringutils.to_unicode(line)
                if pkginrepo.match(line):
                    grains['pkgin_repositories'].append(line)

    return grains
1029577
def package_version(package_name: str) -> typing.Optional[str]:
    

    try:
        return pkg_resources.get_distribution(package_name).version
    except (pkg_resources.DistributionNotFound, AttributeError):
        return None
1200108
def _get_scope_versions(self, pkg_versions):
        '''
        
        '''
        get_in_versions = []
        for p_version in pkg_versions:
            if fnmatch.fnmatch(p_version, self.version):
                get_in_versions.append(p_version)
        return get_in_versions
1190672
def parse_pkginfo(line, osarch=None):
    '''
    
    '''
    try:
        name, epoch, version, release, arch, repoid, install_time = line.split('_|-')
    # Handle unpack errors (should never happen with the queryformat we are
    # using, but can't hurt to be careful).
    except ValueError:
        return None

    name = resolve_name(name, arch, osarch)
    if release:
        version += '-{0}'.format(release)
    if epoch not in ('(none)', '0'):
        version = ':'.join((epoch, version))

    if install_time not in ('(none)', '0'):
        install_date = datetime.datetime.utcfromtimestamp(int(install_time)).isoformat() + "Z"
        install_date_time_t = int(install_time)
    else:
        install_date = None
        install_date_time_t = None

    return pkginfo(name, version, arch, repoid, install_date, install_date_time_t)
98288
def get_os_version_package(pkg, fatal=True):
    ''''''
    codename = get_os_codename_package(pkg, fatal=fatal)

    if not codename:
        return None

    if 'swift' in pkg:
        vers_map = SWIFT_CODENAMES
        for cname, version in six.iteritems(vers_map):
            if cname == codename:
                return version[-1]
    else:
        vers_map = OPENSTACK_CODENAMES
        for version, cname in six.iteritems(vers_map):
            if cname == codename:
                return version
758206
def guess_version_by_running_live_package(
    pkg_key, default="?"
):  # type: (str,str) -> Any
    
    try:
        m = import_module(pkg_key)
    except ImportError:
        return default
    else:
        return getattr(m, "__version__", default)
330999
def package_version():
    """"""
    version_path = os.path.join(os.path.dirname(__file__), 'version.py')

    version = read_version(version_path)
    write_version(version_path, version)

    return version
1160193
def get_version():
    
    # "Spoof" the ``setup.py`` helper modules.
    sys.modules["setup_helpers"] = object()
    sys.modules["setup_helpers_macos"] = object()
    sys.modules["setup_helpers_windows"] = object()
    filename = os.path.join(_ROOT_DIR, "setup.py")
    loader = importlib.machinery.SourceFileLoader("setup", filename)
    setup_mod = loader.load_module()
    return setup_mod.VERSION
996493
def _get_version():
    """"""
    with open("../waliki/__init__.py") as fh:
        for line in fh:
            if line.startswith("__version__ = "):
                return line.split("=")[-1].strip().strip("'").strip('"')
598852
def get_version():
    """"""
    with io.open('grammar_check/__init__.py', encoding='utf-8') as input_file:
        for line in input_file:
            if line.startswith('__version__'):
                return ast.parse(line).body[0].value.s