python库缺少pkg_resource_Python pkg_resources.ResourceManager方法代码示例
本文整理汇总了Python中pkg_resources.ResourceManager方法的典型用法代码示例。如果您正苦于以下问题:Python pkg_resources.ResourceManager方法的具体用法?Python pkg_resources.ResourceManager怎么用?Python pkg_resources.ResourceManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块pkg_resources的用法示例。
在下文中一共展示了pkg_resources.ResourceManager方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_resource_filename_rewrites_on_change
点赞 6
# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import ResourceManager [as 别名]
def test_resource_filename_rewrites_on_change(self):
"""
If a previous call to get_resource_filename has saved the file, but
the file has been subsequently mutated with different file of the
same size and modification time, it should not be overwritten on a
subsequent call to get_resource_filename.
"""
import mod
manager = pkg_resources.ResourceManager()
zp = pkg_resources.ZipProvider(mod)
filename = zp.get_resource_filename(manager, 'data.dat')
actual = datetime.datetime.fromtimestamp(os.stat(filename).st_mtime)
assert actual == self.ref_time
f = open(filename, 'w')
f.write('hello, world?')
f.close()
ts = timestamp(self.ref_time)
os.utime(filename, (ts, ts))
filename = zp.get_resource_filename(manager, 'data.dat')
with open(filename) as f:
assert f.read() == 'hello, world!'
manager.cleanup_resources()
开发者ID:pypa,项目名称:pkg_resources,代码行数:24,
示例2: test_resource_filename_rewrites_on_change
点赞 6
# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import ResourceManager [as 别名]
def test_resource_filename_rewrites_on_change(self):
"""
If a previous call to get_resource_filename has saved the file, but
the file has been subsequently mutated with different file of the
same size and modification time, it should not be overwritten on a
subsequent call to get_resource_filename.
"""
import mod
manager = pkg_resources.ResourceManager()
zp = pkg_resources.ZipProvider(mod)
filename = zp.get_resource_filename(manager, 'data.dat')
actual = datetime.datetime.fromtimestamp(os.stat(filename).st_mtime)
assert actual == self.ref_time
f = open(filename, 'w')
f.write('hello, world?')
f.close()
ts = timestamp(self.ref_time)
os.utime(filename, (ts, ts))
filename = zp.get_resource_filename(manager, 'data.dat')
f = open(filename)
assert f.read() == 'hello, world!'
manager.cleanup_resources()
开发者ID:francelabs,项目名称:datafari,代码行数:24,
示例3: get_package_loader
点赞 5
# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import ResourceManager [as 别名]
def get_package_loader(self, package, package_path):
from pkg_resources import DefaultProvider, ResourceManager, get_provider
loadtime = datetime.utcnow()
provider = get_provider(package)
manager = ResourceManager()
filesystem_bound = isinstance(provider, DefaultProvider)
def loader(path):
if path is None:
return None, None
path = posixpath.join(package_path, path)
if not provider.has_resource(path):
return None, None
basename = posixpath.basename(path)
if filesystem_bound:
return (
basename,
self._opener(provider.get_resource_filename(manager, path)),
)
s = provider.get_resource_string(manager, path)
return basename, lambda: (BytesIO(s), loadtime, len(s))
return loader
开发者ID:Frank-qlu,项目名称:recruit,代码行数:31,
示例4: __init__
点赞 5
# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import ResourceManager [as 别名]
def __init__(self, egg_or_spec, resource_name, manager=None, root_resource=None):
if pkg_resources is None:
raise NotImplementedError("This class requires pkg_resources.")
if isinstance(egg_or_spec, (str, unicode)):
self.egg = pkg_resources.get_distribution(egg_or_spec)
else:
self.egg = egg_or_spec
self.resource_name = resource_name
if manager is None:
manager = pkg_resources.ResourceManager()
self.manager = manager
if root_resource is None:
root_resource = resource_name
self.root_resource = os.path.normpath(root_resource)
开发者ID:linuxscout,项目名称:mishkal,代码行数:16,
示例5: test_get_cache_path
点赞 5
# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import ResourceManager [as 别名]
def test_get_cache_path(self):
mgr = pkg_resources.ResourceManager()
path = mgr.get_cache_path('foo')
type_ = str(type(path))
message = "Unexpected type from get_cache_path: " + type_
assert isinstance(path, (unicode, str)), message
开发者ID:pypa,项目名称:pkg_resources,代码行数:8,
示例6: __init__
点赞 5
# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import ResourceManager [as 别名]
def __init__(self, package_name, package_path="templates", encoding="utf-8"):
from pkg_resources import DefaultProvider
from pkg_resources import get_provider
from pkg_resources import ResourceManager
provider = get_provider(package_name)
self.encoding = encoding
self.manager = ResourceManager()
self.filesystem_bound = isinstance(provider, DefaultProvider)
self.provider = provider
self.package_path = package_path
开发者ID:pypa,项目名称:pipenv,代码行数:13,
示例7: installed_location
点赞 5
# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import ResourceManager [as 别名]
def installed_location(filename):
"""
Returns the full path for the given installed file or None if not found.
:param filename: The filename to search for.
:returns: The absolute filepath for the file or None if not installed.
"""
try:
return ResourceManager().resource_filename(Requirement.parse("websnort"), filename)
except DistributionNotFound:
return None
开发者ID:shendo,项目名称:websnort,代码行数:13,
示例8: test_get_cache_path
点赞 5
# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import ResourceManager [as 别名]
def test_get_cache_path(self):
mgr = pkg_resources.ResourceManager()
path = mgr.get_cache_path('foo')
type_ = str(type(path))
message = "Unexpected type from get_cache_path: " + type_
assert isinstance(path, string_types), message
开发者ID:pypa,项目名称:setuptools,代码行数:8,
示例9: test_get_cache_path_race
点赞 5
# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import ResourceManager [as 别名]
def test_get_cache_path_race(self, tmpdir):
# Patch to os.path.isdir to create a race condition
def patched_isdir(dirname, unpatched_isdir=pkg_resources.isdir):
patched_isdir.dirnames.append(dirname)
was_dir = unpatched_isdir(dirname)
if not was_dir:
os.makedirs(dirname)
return was_dir
patched_isdir.dirnames = []
# Get a cache path with a "race condition"
mgr = pkg_resources.ResourceManager()
mgr.set_extraction_path(str(tmpdir))
archive_name = os.sep.join(('foo', 'bar', 'baz'))
with mock.patch.object(pkg_resources, 'isdir', new=patched_isdir):
mgr.get_cache_path(archive_name)
# Because this test relies on the implementation details of this
# function, these assertions are a sentinel to ensure that the
# test suite will not fail silently if the implementation changes.
called_dirnames = patched_isdir.dirnames
assert len(called_dirnames) == 2
assert called_dirnames[0].split(os.sep)[-2:] == ['foo', 'bar']
assert called_dirnames[1].split(os.sep)[-1:] == ['foo']
开发者ID:pypa,项目名称:setuptools,代码行数:29,
注:本文中的pkg_resources.ResourceManager方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。
python库缺少pkg_resource_Python pkg_resources.ResourceManager方法代码示例相关推荐
- python中的scaler_Python preprocessing.MaxAbsScaler方法代码示例
本文整理汇总了Python中sklearn.preprocessing.MaxAbsScaler方法的典型用法代码示例.如果您正苦于以下问题:Python preprocessing.MaxAbsSc ...
- python管理工具ports_Python options.port方法代码示例
本文整理汇总了Python中tornado.options.port方法的典型用法代码示例.如果您正苦于以下问题:Python options.port方法的具体用法?Python options.p ...
- python os path isfile_Python path.isfile方法代码示例
本文整理汇总了Python中os.path.isfile方法的典型用法代码示例.如果您正苦于以下问题:Python path.isfile方法的具体用法?Python path.isfile怎么用?P ...
- python html模板_Python html.format_html方法代码示例
本文整理汇总了Python中django.utils.html.format_html方法的典型用法代码示例.如果您正苦于以下问题:Python html.format_html方法的具体用法?Pyt ...
- python session模块_Python backend.set_session方法代码示例
本文整理汇总了Python中keras.backend.set_session方法的典型用法代码示例.如果您正苦于以下问题:Python backend.set_session方法的具体用法?Pyth ...
- python get score gain_Python functional.linear方法代码示例
本文整理汇总了Python中torch.nn.functional.linear方法的典型用法代码示例.如果您正苦于以下问题:Python functional.linear方法的具体用法?Pytho ...
- python中string.digits_Python string.hexdigits方法代码示例
本文整理汇总了Python中string.hexdigits方法的典型用法代码示例.如果您正苦于以下问题:Python string.hexdigits方法的具体用法?Python string.he ...
- python color属性_Python turtle.color方法代码示例
本文整理汇总了Python中turtle.color方法的典型用法代码示例.如果您正苦于以下问题:Python turtle.color方法的具体用法?Python turtle.color怎么用?P ...
- python end用法_Python turtle.end_fill方法代码示例
本文整理汇总了Python中turtle.end_fill方法的典型用法代码示例.如果您正苦于以下问题:Python turtle.end_fill方法的具体用法?Python turtle.end_ ...
- python qt 按钮_Python QtWidgets.QPushButton方法代码示例
本文整理汇总了Python中PySide2.QtWidgets.QPushButton方法的典型用法代码示例.如果您正苦于以下问题:Python QtWidgets.QPushButton方法的具体用 ...
最新文章
- __block的初步用法
- SharePoint 2013中的视频体验增强(1)——把大象装进冰箱
- CCNP-EIGRP不等价负载均衡
- Linux 脚本文件中开头的#!/bin/bash和#!/bin/sh是什么意思
- 第二节:简易安装 和 快速入门Vue.js
- 鸿蒙是否会开源,鸿蒙会不会开源?鸿蒙终于迎来新发展
- java混淆of_java – 是否有任何级别的混淆可以“欺骗”instanceof?
- android统计库,android jacoco 统计多模块
- n皇后问题c语言_九章算法 | N皇后问题
- MySQL5.7 group by新特性报错1055的解决办法
- (2016弱校联盟十一专场10.2) 	E.Coins
- UE4官方文档UI学习:1.UMG UI设计器快速入门
- UI——day15.H5和小程序的设计
- FFmpeg 加水印 加马赛克
- 织梦网站模板的建站优势
- Jenkins HTML Publisher 插件
- php 排它性,排他性
- 快手光合计划完整版攻略
- 14-用Python 读写 Excel 文件
- CORBA的简单介绍及HelloWorld
热门文章
- 第11.25节 Python正则表达式编译re.compile及正则对象使用
- 目前最新全国行政区域JSON数据截止2015年9月30日
- 如何给centos设置中文、如何给火狐浏览器设置中文
- 四六级分数根据比例给分
- 盘点!电价市场化改革后,数据中心电费涨了多少?
- 红蜘蛛5屏幕测试软件,红蜘蛛5校色仪怎么用?显示器校色及测试色域和色彩精准度详细教程(2)...
- 易维联温湿度记录仪的使用
- Unity 在安卓手机上实时调试
- Linux之软件包安装——06
- 联想win7无法连接无线网络连接服务器,联想笔记本连不上wifi该怎么处理