Extract plugin name and version specifiers from plugin descriptor string.

    .. versionchanged:: 0.25.2
        Import from `pip_helpers` locally to avoid error `sci-bots/mpm#5`_.

        .. _sci-bots/mpm#5: https://github.com/sci-bots/mpm/issues/5
335880
def plugin_request(plugin_str):
    '''
    
    '''
    from pip_helpers import CRE_PACKAGE

    match = CRE_PACKAGE.match(plugin_str)
    if not match:
        raise ValueError('Invalid plugin descriptor. Must be like "foo", '
                         '"foo==1.0", "foo>=1.0", etc.')
    return match.groupdict()
817147
def deconstruct_version_string(version)
      match = version.match(/^(\d+)\.(\d+)(?:\.(\d+))?$/)

      # Match should have 4 parts [0] = input string, [1] = major
      # [2] = minor, [3] = patch (possibly blank)
      if match && match.size == 4
        return [match[1].to_i, match[2].to_i, match[3].to_i || 0]
      else
        return nil
      end
    end
872476
def get_impl_version_info():
    # type: () -> Tuple[int, ...]
    """"""
    if get_abbr_impl() == 'pp':
        # as per https://github.com/pypa/pip/issues/2882
        # attrs exist only on pypy
        return (sys.version_info[0],
                sys.pypy_version_info.major,  # type: ignore
                sys.pypy_version_info.minor)  # type: ignore
    else:
        return sys.version_info[0], sys.version_info[1]
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
548584
def get_info(cls):
        
        mod = try_import(cls.mod_name)
        if not mod:
            return None
        version = getattr(mod, '__version__', None) or getattr(mod, 'version',
                                                               None)
        return BackendInfo(version or 'deprecated', '')
32208
def extract_version():
    
    with open('ggplot/__init__.py') as fd:
        ns = {}
        for line in fd:
            if line.startswith('__version__'):
                exec(line.strip(), ns)
                return ns['__version__']
514234
def version(self):
        
        if self.find:
            return self.meta.sp + split_package(self.find)[1]
        return ""
1252199
def pyVersionStr(self):
        
        from sys import version_info

        return "Python Interpreter Version: {}.{}.{}".format(version_info.major,
                                                             version_info.minor,
                                                             version_info.micro)
137118
def extract_version(filepath='jeni.py', name='__version__'):
    
    context = {}
    for line in open(filepath):
        if name in line:
            exec(line, context)
            break
    else:
        raise RuntimeError('{} not found in {}'.format(name, filepath))
    return context[name]
754593
def get_plugins_by_name(self, *names):
        
        self._import_plugins()
        plugin_instances = []
        for name in names:
            if isinstance(name, six.string_types):
                try:
                    plugin_instances.append(self.plugins[name.lower()])
                except KeyError:
                    raise PluginNotFound("No plugin named '{0}'.".format(name))
            elif isinstance(name, type) and issubclass(name, ContentPlugin):
                # Will also allow classes instead of strings.
                plugin_instances.append(self.plugins[self._name_for_model[name.model]])
            else:
                raise TypeError("get_plugins_by_name() expects a plugin name or class, not: {0}".format(name))
        return plugin_instances
855301
def parse_python(spec):  # Ignore PyDocStyleBear
        

        def _extract_op_version(spec):
            # https://www.python.org/dev/peps/pep-0440/#compatible-release
            if spec.operator == "~=":
                version = spec.version.split(".")
                if len(version) in {2, 3, 4}:
                    if len(version) in {3, 4}:
                        del version[-1]  # will increase the last but one in next line
                    version[-1] = str(int(version[-1]) + 1)
                else:
                    raise ValueError("%r must not be used with %r" % (spec.operator, spec.version))
                return [(">=", spec.version), ("<", ".".join(version))]
            # Trailing .* is permitted per
            # https://www.python.org/dev/peps/pep-0440/#version-matching
            elif spec.operator == "==" and spec.version.endswith(".*"):
                try:
                    result = check_output(["/usr/bin/semver-ranger", spec.version], universal_newlines=True).strip()
                    gte, lt = result.split()
                    return [(">=", gte.lstrip(">=")), ("<", lt.lstrip("<"))]
                except ValueError:
                    _LOGGER.warning("couldn't resolve ==%s", spec.version)
                    return spec.operator, spec.version
            # https://www.python.org/dev/peps/pep-0440/#arbitrary-equality
            # Use of this operator is heavily discouraged, so just convert it to 'Version matching'
            elif spec.operator == "===":
                return "==", spec.version
            else:
                return spec.operator, spec.version

        def _get_pip_spec(requirements):
            """There is no `specs` field In Pip 8+, take info from `specifier` field."""
            if hasattr(requirements, "specs"):
                return requirements.specs
            elif hasattr(requirements, "specifier"):
                specs = [_extract_op_version(spec) for spec in requirements.specifier]
                if len(specs) == 0:
                    # TODO: I'm not sure with this one
                    # we should probably return None instead and let pip deal with this
                    specs = [(">=", "0.0.0")]
                return specs

        _LOGGER.info("Parsing dependency %r", spec)
        # create a temporary file and store the spec there since
        # `parse_requirements` requires a file
        with NamedTemporaryFile(mode="w+", suffix="pysolve") as f:
            f.write(spec)
            f.flush()
            parsed = parse_requirements(f.name, session=f.name)
            dependency = [Dependency(x.name, _get_pip_spec(x.req)) for x in parsed].pop()

        return dependency
1051298
public static String[] extractNameVersionType(String url) {
		Matcher m = ARTIFACT_MATCHER.matcher(url);
		if (!m.matches()) {
			return new String[]{url.split("\\.")[0], DEFAULT_VERSION};
		} else {
			//CHECKSTYLE:OFF
			StringBuilder v = new StringBuilder();
			String d1 = m.group(1);
			String d2 = m.group(2);
			String d3 = m.group(3);
			String d4 = m.group(4);
			String d5 = m.group(5);
			String d6 = m.group(6);
			if (d2 != null) {
				v.append(d2);
				if (d3 != null) {
					v.append('.');
					v.append(d3);
					if (d4 != null) {
						v.append('.');
						v.append(d4);
						if (d5 != null) {
							v.append(".");
							cleanupModifier(v, d5);
						}
					} else if (d5 != null) {
						v.append(".0.");
						cleanupModifier(v, d5);
					}
				} else if (d5 != null) {
					v.append(".0.0.");
					cleanupModifier(v, d5);
				}
			}
			//CHECKSTYLE:ON
			return new String[]{d1, v.toString(), d6};
		}
	}
1270750
def _extract_version(version_string, pattern):
    
    if version_string:
        match = pattern.match(version_string.strip())
        if match:
            return match.group(1)
    return ""
1205318
def get_version(module):
    
    init_py = open('{0}.py'.format(module)).read()
    return re.search("__version__ = ['\"]([^'\"]+)['\"]", init_py).group(1)
101960
def get_version(package_name):
    
    module = 'prosper.' + package_name + '._version'
    package = importlib.import_module(module)

    version = package.__version__

    return version
313895
def _parse_version_string(version_conditions_string):
    '''
    
    '''
    result = []
    version_conditions_string = version_conditions_string.strip()
    if not version_conditions_string:
        return result
    for version_condition in version_conditions_string.split(','):
        operator_and_version = _get_comparison_spec(version_condition)
        result.append(operator_and_version)
    return result
216321
def get_version(mod, default="0.0.0"):
    
    name = mod
    if hasattr(mod, "__name__"):
        name = mod.__name__

    try:
        import pkg_resources

        return pkg_resources.get_distribution(name).version

    except Exception as e:
        LOG.warning("Can't determine version for %s: %s", name, e, exc_info=e)
        return default