Helper function that retrieves and nicely formats the desired pkg (and
    version if specified) so that helpful information can be printed in the
    comment for the state.
484321
def _get_desired_pkg(name, desired):
    '''
    
    '''
    if not desired[name] or desired[name].startswith(('<', '>', '=')):
        oper = ''
    else:
        oper = '='
    return '{0}{1}{2}'.format(name, oper,
                              '' if not desired[name] else desired[name])
955192
def choose_upg(packages):
    
    selected_packages, data = [], []
    if packages:
        for pkg in packages:
            name = GetFromInstalled(pkg).name()
            ver = GetFromInstalled(pkg).version()
            binary = "{0}{1}".format(name, ver)
            installed = find_package(binary + _meta_.sp, _meta_.pkg_path)[0]
            data.append(installed)
        text = "Press 'spacebar' to unchoose packages from upgrade"
        title = " Upgrade "
        backtitle = "{0} {1}".format(_meta_.__all__, _meta_.__version__)
        status = True
        pkgs = DialogUtil(data, text, title, backtitle,
                          status).checklist()
        pkgs = [] if pkgs is None else pkgs
        for pkg in pkgs:
            name = split_package(pkg)[0]
            if name in packages:
                selected_packages.append(name)
        if not selected_packages:
            raise SystemExit()
        print("")
    return selected_packages
868820
def print_package_versions(self):
        """"""
        variants = self.context.get_tool_variants(self.tool_name)
        if variants:
            if len(variants) > 1:
                self._print_conflicting(variants)
                return 1
            else:
                from rez.packages_ import iter_packages
                variant = iter(variants).next()
                it = iter_packages(name=variant.name)
                rows = []
                colors = []

                for pkg in sorted(it, key=lambda x: x.version, reverse=True):
                    if pkg.version == variant.version:
                        name = "* %s" % pkg.qualified_name
                        col = heading
                    else:
                        name = "  %s" % pkg.qualified_name
                        col = local if pkg.is_local else None

                    label = "(local)" if pkg.is_local else ""
                    rows.append((name, pkg.path, label))
                    colors.append(col)

                _pr = Printer()
                for col, line in zip(colors, columnise(rows)):
                    _pr(line, col)
        return 0
817332
function printHelpInformation(examples, pkg) {
  let cmdName = this._name;
  if (this._alias) {
    cmdName = `${cmdName}|${this._alias}`;
  }

  const sourceInformation = pkg
    ? [`${chalk.bold('Source:')} ${pkg.name}@${pkg.version}`, '']
    : [];

  let output = [
    chalk.bold(`react-native ${cmdName}`),
    this._description ? `\n${this._description}\n` : '',
    ...sourceInformation,
    `${chalk.bold('Options:')}`,
    this.optionHelp().replace(/^/gm, '  '),
  ];

  if (examples && examples.length > 0) {
    const formattedUsage = examples
      .map(example => `  ${example.desc}: \n  ${chalk.cyan(example.cmd)}`)
      .join('\n\n');

    output = output.concat([chalk.bold('\nExample usage:'), formattedUsage]);
  }

  return output.join('\n').concat('\n');
}
1015047
def version(rest):
	""
	pkg = rest.strip() or 'pmxbot'
	if pkg.lower() == 'python':
		return sys.version.split()[0]
	return importlib_metadata.version(pkg)
321554
def from_pkg(self):
        
        if self._version is None:
            frame = caller(1)
            pkg = frame.f_globals.get('__package__')
            if pkg is not None:
                self._version = pkg_version(pkg)
        return self
467441
def get_version(package):
    
    init_py = readfile(os.path.join(package, '__init__.py'))
    return re.search("__version__ = ['\"]([^'\"]+)['\"]", init_py).group(1)
490778
function getBanner (packagePath) {
  // Read package.json
  const pkg = require(packagePath)
  const { name, version, license } = pkg

  // Remove '#readme' from the URL
  const url = pkg.homepage.replace(/#.*$/, '')

  // Print an always-showing banner (with a !), this way it'll show up
  // in minified sources as well
  return `/*! ${name} v${version} | ${license} | ${url} */`
}
571263
def upgrade():
    '''
    
    '''
    DETAILS = _load_state()
    pkgs = uptodate()
    DETAILS['packages'] = pkgs
    _save_state(DETAILS)
    return pkgs
188516
def package_info(pkg_name):
    
    indent = "  "
    for config, _ in _iter_packages():
        if pkg_name == config["name"]:
            print("Package:", pkg_name)
            print(indent, "Platform:", config["platform"])
            print(indent, "Version:", config["version"])
            print(indent, "Path:", config["path"])
            print(indent, "Worlds:")
            for world in config["maps"]:
                world_info(world["name"], world_config=world, initial_indent="    ")
1065981
def _get_pkg_license(pkg):
    '''
    
    '''
    licenses = set()
    cpr = "/usr/share/doc/{0}/copyright".format(pkg)
    if os.path.exists(cpr):
        with salt.utils.files.fopen(cpr) as fp_:
            for line in salt.utils.stringutils.to_unicode(fp_.read()).split(os.linesep):
                if line.startswith("License:"):
                    licenses.add(line.split(":", 1)[1].strip())

    return ", ".join(sorted(licenses))
1310271
function convertForPackage(context, pkg) {
	var name = pkg.name;
	var version = pkg.version;

	var conv = context.deferredConversions;
	var pkgConv = conv[name];
	var depPkg, fns, keys = 0;
	if(pkgConv) {
		for(var range in pkgConv) {
			depPkg = crawl.matchedVersion(context, name, range);
			if(depPkg) {
				fns = pkgConv[range];
				for(var i = 0, len = fns.length; i < len; i++) {
					fns[i].call(context);
				}
				delete pkgConv[range];
			} else {
				keys++;
			}
		}
		if(keys === 0) {
			delete conv[name];
		}
	}
}
1136380
function(context, pkg, source) {
		source = source || "{}";
		var packageJSON = JSON.parse(source);
		utils.extend(pkg, packageJSON);
		context.packages.push(pkg);
		return pkg;
	}
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))
        ]
    )
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)
276779
def _find_pkg_info(self):
        
        dist = pkg_resources.require(self.package_name)[0]
        self._pkg_resources_locations = [dist.location]
        ver, url = self._dist_version_url(dist)
        return {'version': ver, 'url': url}
404554
def get_version(package_name, version_file='_version.py'):
    """"""
    filename = os.path.join(os.path.dirname(__file__), package_name, version_file)
    with open(filename, 'rb') as fp:
        return fp.read().decode('utf8').split('=')[1].strip(" \n'")