在运行时创建临时pkg_资源入口点。
prybar的Python项目详细描述
用于临时定义pkg_resourcesentry points的python库 在运行时。主要用例是测试与入口点一起工作的代码。
安装
$ pip install prybar
Prybar需要Python3.6或更高版本。
用法
>>> importprybar>>> frompkg_resourcesimportiter_entry_points>>> # Entry point doesn't exist>>> list(iter_entry_points('example.hash_types','sha256'))[] >>> # With prybar's context manager we can create entry points temporarily>>> withprybar.dynamic_entrypoint('example.hash_types',... name='sha256',module='hashlib'):... hash=next(iter_entry_points('example.hash_types','sha256')).load()... hash(b'foo').hexdigest()[:6]'2c26b4' >>> # And it's gone again>>> list(iter_entry_points('example.hash_types','sha256'))[]
有关详细信息,请参见full documentation。