本文整理汇总了Python中jsonschema._utils.URIDict方法的典型用法代码示例。如果您正苦于以下问题:Python _utils.URIDict方法的具体用法?Python _utils.URIDict怎么用?Python _utils.URIDict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jsonschema._utils
的用法示例。
在下文中一共展示了_utils.URIDict方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_non_default_resolver_validator
# 需要导入模块: from jsonschema import _utils [as 别名]
# 或者: from jsonschema._utils import URIDict [as 别名]
def test_non_default_resolver_validator(markdown_examples):
ms = URIDict()
draft3 = load_schema("draft3")
draft4 = load_schema("draft4")
ms[draft3["id"]] = draft3
ms[draft4["id"]] = draft4
resolver_with_store = RefResolver(draft3["id"], draft3, ms)
# 'Other' schema should be valid with draft3
builder = pjo.ObjectBuilder(
markdown_examples["Other"],
resolver=resolver_with_store,
validatorClass=Draft3Validator,
resolved=markdown_examples,
)
klasses = builder.build_classes()
a = klasses.Other(MyAddress="where I live")
assert a.MyAddress == "where I live"
示例2: __init__
# 需要导入模块: from jsonschema import _utils [as 别名]
# 或者: from jsonschema._utils import URIDict [as 别名]
def __init__(
self,
base_uri,
referrer,
store=(),
cache_remote=True,
handlers=(),
urljoin_cache=None,
remote_cache=None,
):
if urljoin_cache is None:
urljoin_cache = lru_cache(1024)(urljoin)
if remote_cache is None:
remote_cache = lru_cache(1024)(self.resolve_from_url)
self.referrer = referrer
self.cache_remote = cache_remote
self.handlers = dict(handlers)
self._scopes_stack = [base_uri]
self.store = _utils.URIDict(
(id, validator.META_SCHEMA)
for id, validator in iteritems(meta_schemas)
)
self.store.update(store)
self.store[base_uri] = referrer
self._urljoin_cache = urljoin_cache
self._remote_cache = remote_cache