本文整理汇总了Python中pip.utils方法的典型用法代码示例。如果您正苦于以下问题:Python pip.utils方法的具体用法?Python pip.utils怎么用?Python pip.utils使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pip
的用法示例。
在下文中一共展示了pip.utils方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: uninstallation_paths
# 需要导入模块: import pip [as 别名]
# 或者: from pip import utils [as 别名]
def uninstallation_paths(dist):
"""
Yield all the uninstallation paths for dist based on RECORD-without-.pyc
Yield paths to all the files in RECORD. For each .py file in RECORD, add
the .pyc in the same directory.
UninstallPathSet.add() takes care of the __pycache__ .pyc.
"""
from pip.utils import FakeFile # circular import
r = csv.reader(FakeFile(dist.get_metadata_lines('RECORD')))
for row in r:
path = os.path.join(dist.location, row[0])
yield path
if path.endswith('.py'):
dn, fn = os.path.split(path)
base = fn[:-3]
path = os.path.join(dn, base + '.pyc')
yield path
示例2: pluginManager
# 需要导入模块: import pip [as 别名]
# 或者: from pip import utils [as 别名]
def pluginManager(monkeypatch):
pluginManager = PluginManager()
monkeypatch.setattr(importlib, 'import_module', mockImportModule)
packagesCnt = 3
packages = [pluginManager.prefix + randomText(10)
for _ in range(packagesCnt)]
monkeypatch.setattr(pip.utils, 'get_installed_distributions',
partial(mockGetInstalledDistributions,
packages=packages))
imported, found = pluginManager.importPlugins()
assert imported == 3
assert hasattr(pluginManager, 'prefix')
assert hasattr(pluginManager, '_sendMessage')
assert hasattr(pluginManager, '_findPlugins')
yield pluginManager
monkeypatch.undo()
示例3: pluginManagerWithImportedModules
# 需要导入模块: import pip [as 别名]
# 或者: from pip import utils [as 别名]
def pluginManagerWithImportedModules(pluginManager, monkeypatch):
monkeypatch.setattr(pip.utils, 'get_installed_distributions',
partial(mockGetInstalledDistributions,
packages=[]))
monkeypatch.setattr(importlib, 'import_module', mockImportModule)
imported, found = pluginManager.importPlugins()
assert imported == 0
packagesCnt = 3
packages = [pluginManager.prefix + randomText(10)
for _ in range(packagesCnt)]
monkeypatch.setattr(pip.utils, 'get_installed_distributions',
partial(mockGetInstalledDistributions,
packages=packages))
imported, found = pluginManager.importPlugins()
assert imported == 3
yield pluginManager
monkeypatch.undo()
pluginManager.importPlugins()
示例4: send
# 需要导入模块: import pip [as 别名]
# 或者: from pip import utils [as 别名]
def send(self, request, stream=None, timeout=None, verify=None, cert=None,
proxies=None):
pathname = url_to_path(request.url)
resp = Response()
resp.status_code = 200
resp.url = request.url
try:
stats = os.stat(pathname)
except OSError as exc:
resp.status_code = 404
resp.raw = exc
else:
modified = email.utils.formatdate(stats.st_mtime, usegmt=True)
content_type = mimetypes.guess_type(pathname)[0] or "text/plain"
resp.headers = CaseInsensitiveDict({
"Content-Type": content_type,
"Content-Length": stats.st_size,
"Last-Modified": modified,
})
resp.raw = open(pathname, "rb")
resp.close = resp.raw.close
return resp