当前位置: 首页>>代码示例>>Python>>正文


Python pkg_resources.safe_name方法代码示例

本文整理汇总了Python中pip._vendor.pkg_resources.safe_name方法的典型用法代码示例。如果您正苦于以下问题:Python pkg_resources.safe_name方法的具体用法?Python pkg_resources.safe_name怎么用?Python pkg_resources.safe_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pip._vendor.pkg_resources的用法示例。


在下文中一共展示了pkg_resources.safe_name方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_locked_candidates

# 需要导入模块: from pip._vendor import pkg_resources [as 别名]
# 或者: from pip._vendor.pkg_resources import safe_name [as 别名]
def get_locked_candidates(
        self, section: Optional[str] = None
    ) -> Dict[str, Candidate]:
        if not self.lockfile_file.is_file():
            return {}
        section = section or "default"
        result = {}
        for package in [dict(p) for p in self.lockfile.get("package", [])]:
            if section != "__all__" and section not in package["sections"]:
                continue
            version = package.get("version")
            if version:
                package["version"] = f"=={version}"
            package_name = package.pop("name")
            req = Requirement.from_req_dict(package_name, dict(package))
            can = Candidate(req, self.environment, name=package_name, version=version)
            can.marker = req.marker
            can.hashes = {
                item["file"]: item["hash"]
                for item in self.lockfile["metadata"].get(f"{req.key} {version}", [])
            } or None
            result[req.identify()] = can
        if section in ("default", "__all__") and self.meta.name and self.meta.version:
            result[safe_name(self.meta.name).lower()] = self.make_self_candidate(True)
        return result 
开发者ID:frostming,项目名称:pdm,代码行数:27,代码来源:core.py

示例2: working_set

# 需要导入模块: from pip._vendor import pkg_resources [as 别名]
# 或者: from pip._vendor.pkg_resources import safe_name [as 别名]
def working_set(mocker, repository):
    from pip._internal.utils import logging

    rv = MockWorkingSet()
    mocker.patch.object(Environment, "get_working_set", return_value=rv)

    def install(candidate):
        logging._log_state.indentation = 0
        dependencies = repository.get_dependencies(candidate)[0]
        key = safe_name(candidate.name).lower()
        dist = Distribution(key, candidate.version)
        dist.dependencies = dependencies
        rv.add_distribution(dist)

    def uninstall(dist):
        del rv[dist.key]

    installer = mocker.MagicMock()
    installer.install.side_effect = install
    installer.uninstall.side_effect = uninstall
    mocker.patch("pdm.installers.synchronizers.Installer", return_value=installer)
    mocker.patch("pdm.installers.Installer", return_value=installer)

    yield rv 
开发者ID:frostming,项目名称:pdm,代码行数:26,代码来源:conftest.py

示例3: fmt_ctl_handle_mutual_exclude

# 需要导入模块: from pip._vendor import pkg_resources [as 别名]
# 或者: from pip._vendor.pkg_resources import safe_name [as 别名]
def fmt_ctl_handle_mutual_exclude(value, target, other):
    new = value.split(',')
    while ':all:' in new:
        other.clear()
        target.clear()
        target.add(':all:')
        del new[:new.index(':all:') + 1]
        if ':none:' not in new:
            # Without a none, we want to discard everything as :all: covers it
            return
    for name in new:
        if name == ':none:':
            target.clear()
            continue
        name = pkg_resources.safe_name(name).lower()
        other.discard(name)
        target.add(name) 
开发者ID:chalasr,项目名称:Flask-P2P,代码行数:19,代码来源:index.py

示例4: name

# 需要导入模块: from pip._vendor import pkg_resources [as 别名]
# 或者: from pip._vendor.pkg_resources import safe_name [as 别名]
def name(self):
        if self.req is None:
            return None
        return native_str(pkg_resources.safe_name(self.req.name)) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:6,代码来源:req_install.py

示例5: add_dependencies

# 需要导入模块: from pip._vendor import pkg_resources [as 别名]
# 或者: from pip._vendor.pkg_resources import safe_name [as 别名]
def add_dependencies(
        self, requirements: Dict[str, Requirement], show_message: bool = True
    ) -> None:
        for name, dep in requirements.items():
            if dep.from_section == "default":
                deps = self.tool_settings["dependencies"]
            elif dep.from_section == "dev":
                deps = self.tool_settings["dev-dependencies"]
            else:
                section = f"{dep.from_section}-dependencies"
                if section not in self.tool_settings:
                    self.tool_settings[section] = tomlkit.table()
                deps = self.tool_settings[section]

            matched_name = next(
                filter(
                    lambda k: strip_extras(name)[0] == safe_name(k).lower(), deps.keys()
                ),
                None,
            )
            name_to_save = dep.name if matched_name is None else matched_name
            _, req_dict = dep.as_req_dict()
            if isinstance(req_dict, dict):
                req = tomlkit.inline_table()
                req.update(req_dict)
                req_dict = req
            deps[name_to_save] = req_dict
        self.write_pyproject(show_message) 
开发者ID:frostming,项目名称:pdm,代码行数:30,代码来源:core.py

示例6: __init__

# 需要导入模块: from pip._vendor import pkg_resources [as 别名]
# 或者: from pip._vendor.pkg_resources import safe_name [as 别名]
def __init__(self, **kwargs):
        self._marker = None
        self.from_section = "default"
        self.marker_no_python = None  # type: Optional[Marker]
        self.requires_python = PySpecSet()  # type: PySpecSet
        for k, v in kwargs.items():
            if k == "specifier":
                v = get_specifier(v)
            setattr(self, k, v)
        if self.name and not self.project_name:
            self.project_name = safe_name(self.name)
            self.key = self.project_name.lower() 
开发者ID:frostming,项目名称:pdm,代码行数:14,代码来源:requirements.py

示例7: project_name

# 需要导入模块: from pip._vendor import pkg_resources [as 别名]
# 或者: from pip._vendor.pkg_resources import safe_name [as 别名]
def project_name(self) -> Optional[str]:
        return safe_name(self.name) if self.name else None 
开发者ID:frostming,项目名称:pdm,代码行数:4,代码来源:requirements.py

示例8: update_candidate

# 需要导入模块: from pip._vendor import pkg_resources [as 别名]
# 或者: from pip._vendor.pkg_resources import safe_name [as 别名]
def update_candidate(self, key: str) -> Tuple[Distribution, Candidate]:
        """Update candidate"""
        can = self.candidates[key]
        dist = self.working_set[safe_name(can.name).lower()]
        installer = self.get_installer()
        installer.uninstall(dist)
        installer.install(can)
        return dist, can 
开发者ID:frostming,项目名称:pdm,代码行数:10,代码来源:synchronizers.py

示例9: add_dependencies

# 需要导入模块: from pip._vendor import pkg_resources [as 别名]
# 或者: from pip._vendor.pkg_resources import safe_name [as 别名]
def add_dependencies(self, name, version, requirements):
        pypi_data = self._pypi_data[safe_name(name)][version]
        pypi_data.setdefault("dependencies", []).extend(requirements) 
开发者ID:frostming,项目名称:pdm,代码行数:5,代码来源:conftest.py

示例10: name

# 需要导入模块: from pip._vendor import pkg_resources [as 别名]
# 或者: from pip._vendor.pkg_resources import safe_name [as 别名]
def name(self):
        # type: () -> Optional[str]
        if self.req is None:
            return None
        return native_str(pkg_resources.safe_name(self.req.name)) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:7,代码来源:req_install.py

示例11: name

# 需要导入模块: from pip._vendor import pkg_resources [as 别名]
# 或者: from pip._vendor.pkg_resources import safe_name [as 别名]
def name(self):
        # type: () -> Optional[str]
        if self.req is None:
            return None
        return six.ensure_str(pkg_resources.safe_name(self.req.name)) 
开发者ID:pantsbuild,项目名称:pex,代码行数:7,代码来源:req_install.py


注:本文中的pip._vendor.pkg_resources.safe_name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。