Formats a version string for list_pkgs.
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
569644
def parse_pkg_info(fn):
    
    res = {}
    for ln in open(fn).read().splitlines():
        if not ln or not ln[:1].strip():
            continue
        key, value = ln.split(": ", 1)
        res[key] = value
    return res
167688
def load_version_as_string():
    """"""
    with open(VERSION_PATH, 'r') as rfile:
        contents = rfile.read().strip()

    _, version = contents.split('=')
    version = version.strip()

    # Remove quotes
    return version.strip('"\'')
1370720
def get_versioned_files(cls):
        """"""
        encoding = cls._get_terminal_encoding()
        output = run(['bzr', 'ls', '-VR'], encoding=encoding)
        return output.splitlines()
88469
def print_version():
    """"""
    click.echo("Versions:")
    click.secho(
        "CLI Package Version: %(version)s"
        % {"version": click.style(get_cli_version(), bold=True)}
    )
    click.secho(
        "API Package Version: %(version)s"
        % {"version": click.style(get_api_version(), bold=True)}
    )
901150
def version_variants(version):
    """"""

    result = [version]

    # Add trailing ".0" as needed to ensure that we have at least
    # major.minor.patch
    parts = version.split(".")
    while len(parts) < 3:
        parts.append("0")
        result.append(".".join(parts))

    return result
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
490512
def pkg_version_list(self, pkg_id):
        '''
        
        '''
        pkg_data = self.__reg_software.get(pkg_id, None)
        if not pkg_data:
            return []

        if isinstance(pkg_data, list):
            # raw data is 'pkgid': [sorted version list]
            return pkg_data  # already sorted oldest to newest

        # Must be a dict or OrderDict, and contain full details
        installed_versions = list(pkg_data.get('version').keys())
        return sorted(installed_versions, key=cmp_to_key(self.__oldest_to_latest_version))
954841
def get_pkg_version():
    """"""
    try:
        with open("PKG-INFO", "r") as fp:
            rgx = re.compile(r"Version: (\d+)")
            for line in fp.readlines():
                match = rgx.match(line)
                if match:
                    return match.group(1)
    except IOError:
        return None
136883
def list_pkgs(versions_as_list=False, **kwargs):
    '''
    
    '''
    versions_as_list = salt.utils.data.is_true(versions_as_list)
    # not yet implemented or not applicable
    if any([salt.utils.data.is_true(kwargs.get(x))
            for x in ('removed', 'purge_desired')]):
        return {}

    if 'pkg.list_pkgs' in __context__:
        if versions_as_list:
            return __context__['pkg.list_pkgs']
        else:
            ret = copy.deepcopy(__context__['pkg.list_pkgs'])
            __salt__['pkg_resource.stringify'](ret)
            return ret

    cmd = ['pacman', '-Q']

    if 'root' in kwargs:
        cmd.extend(('-r', kwargs['root']))

    ret = {}
    out = __salt__['cmd.run'](cmd, output_loglevel='trace', python_shell=False)
    for line in salt.utils.itertools.split(out, '\n'):
        if not line:
            continue
        try:
            name, version_num = line.split()[0:2]
        except ValueError:
            log.error('Problem parsing pacman -Q: Unexpected formatting in '
                      'line: \'%s\'', line)
        else:
            __salt__['pkg_resource.add_pkg'](ret, name, version_num)

    __salt__['pkg_resource.sort_pkglist'](ret)
    __context__['pkg.list_pkgs'] = copy.deepcopy(ret)
    if not versions_as_list:
        __salt__['pkg_resource.stringify'](ret)
    return ret
1358101
def cmd_version(unused_conf):
    """"""
    import pkg_resources
    print('This is {} version {}, imported from {}'
          .format(__oneliner__, __version__, __file__))
    if len(Plugin.builders) > 0:
        print('setuptools registered builders:')
    for entry_point in pkg_resources.iter_entry_points('yabt.builders'):
        print('  {0.module_name}.{0.name} (dist {0.dist})'.format(entry_point))
285735
def _repack_pkgs(pkgs, normalize=True):
    '''
    
    '''
    if normalize and 'pkg.normalize_name' in __salt__:
        _normalize_name = __salt__['pkg.normalize_name']
    else:
        _normalize_name = lambda pkgname: pkgname
    return dict(
        [
            (_normalize_name(six.text_type(x)), six.text_type(y) if y is not None else y)
            for x, y in six.iteritems(salt.utils.data.repack_dictlist(pkgs))
        ]
    )
350539
function listWithoutVersions() {
  const options = {
    transforms() {
      return [filter({wantStrings: true}, function (str) {
        return str.indexOf('@') === -1;
      })];
    }
  };

  return list(options);
}
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('"')
732493
def python_version_matchers():
    """"""
    version = sys.version_info
    patterns = [
        "{0}",
        "{0}{1}",
        "{0}.{1}",
    ]
    matchers = [
        pattern.format(*version)
        for pattern in patterns
    ] + [None]
    return set(matchers)
98176
def list_pkgs(*packages, **kwargs):
    '''
    
    '''
    pkgs = {}
    cmd = ['rpm']
    if kwargs.get('root'):
        cmd.extend(['--root', kwargs['root']])
    cmd.extend(['-q' if packages else '-qa',
                '--queryformat', r'%{NAME} %{VERSION}\n'])
    if packages:
        cmd.extend(packages)
    out = __salt__['cmd.run'](cmd, output_loglevel='trace', python_shell=False)
    for line in salt.utils.itertools.split(out, '\n'):
        if 'is not installed' in line:
            continue
        comps = line.split()
        pkgs[comps[0]] = comps[1]
    return pkgs
291076
def pretty_version_text():
    """"""
    version_lines = ["dtool, version {}".format(dtool_version)]
    version_lines.append("\nBase:")
    version_lines.append("dtoolcore, version {}".format(dtoolcore.__version__))
    version_lines.append("dtool-cli, version {}".format(__version__))

    # List the storage broker packages.
    version_lines.append("\nStorage brokers:")
    for ep in iter_entry_points("dtool.storage_brokers"):
        package = ep.module_name.split(".")[0]
        dyn_load_p = __import__(package)
        version = dyn_load_p.__version__
        storage_broker = ep.load()
        version_lines.append(
            "{}, {}, version {}".format(
                storage_broker.key,
                package.replace("_", "-"),
                version))

    # List the plugin packages.
    modules = [ep.module_name for ep in iter_entry_points("dtool.cli")]
    packages = set([m.split(".")[0] for m in modules])
    version_lines.append("\nPlugins:")
    for p in packages:
        dyn_load_p = __import__(p)
        version_lines.append(
            "{}, version {}".format(
                p.replace("_", "-"),
                dyn_load_p.__version__))

    return "\n".join(version_lines)