跳转到主要内容

DottedNameResolver和其他从pyramid.path提取的内容

项目描述

python_dotted_name_resolver

Build Status Latest Version

DottedNameResolver和其他从pyramid.path提取的内容,来自出色的Pyramid Web框架。

一些使用示例

In [1]: from dotted_name_resolver import DottedNameResolver

In [2]: r = DottedNameResolver()

In [3]: r.resolve('os.path')
Out[3]: <module 'posixpath' from
'/Users/marca/python/virtualenvs/dotted_name_resolver/lib/python2.7/posixpath.pyc'>

In [4]: r.resolve('os.path.exists')
Out[4]: <function genericpath.exists>

In [5]: r.resolve('dotted_name_resolver.DottedNameResolver.maybe_resolve')
Out[5]: <unbound method DottedNameResolver.maybe_resolve>

In [6]: import os.path

In [7]: r.resolve(os.path.exists)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call
last)
<ipython-input-9-0fd311498cae> in <module>()
----> 1 r.resolve(os.path.exists)

/Users/marca/dev/git-repos/python_dotted_name_resolver/dotted_name_resolver/__init__.pyc
in resolve(self, dotted)
    328         if not isinstance(dotted, string_types):
--> 329             raise ValueError('%r is not a string' % (dotted,))
    330         package = self.package
    331         if package is CALLER_PACKAGE:

ValueError: <function exists at 0x1002a5398> is not a string

In [8]: r.maybe_resolve(os.path.exists)
Out[8]: <function genericpath.exists>

In [24]: from dotted_name_resolver import AssetResolver

In [25]: a = AssetResolver('IPython')

In [26]: a.resolve('html/static/notebook/js/notebook.js').abspath()
Out[26]:
'/Users/marca/python/virtualenvs/dotted_name_resolver/lib/python2.7/site-packages/IPython/html/static/notebook/js/notebook.js'

文档

有关详细文档,请参阅pyramid.path的文档,并将所有提及pyramid.path的地方替换为dotted_name_resolver

支持的Python版本

$ /Library/Frameworks/Python.framework/Versions/3.3/bin/tox
...
  py26: commands succeeded
  py27: commands succeeded
  py33: commands succeeded
  py34: commands succeeded
  pypy: commands succeeded
  congratulations :)

0.1

0.0

  • 首次发布

项目详情


下载文件

下载适合您平台的项目文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分发

dotted_name_resolver-0.1.tar.gz (9.2 kB 查看哈希值

上传时间:

支持者

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面