本文整理匯總了Python中jsonschema.RefResolver.store[schema['id']]方法的典型用法代碼示例。如果您正苦於以下問題:Python RefResolver.store[schema['id']]方法的具體用法?Python RefResolver.store[schema['id']]怎麽用?Python RefResolver.store[schema['id']]使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類jsonschema.RefResolver
的用法示例。
在下文中一共展示了RefResolver.store[schema['id']]方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: RefResolver
# 需要導入模塊: from jsonschema import RefResolver [as 別名]
# 或者: from jsonschema.RefResolver import store[schema['id']] [as 別名]
from jsonschema import Draft4Validator, FormatChecker, RefResolver
from jsonmapping import SchemaVisitor
from aleph.model.constants import COUNTRY_NAMES, LANGUAGE_NAMES
from aleph.model.constants import SOURCE_CATEGORIES
resolver = RefResolver('core.json#', {})
schema_dir = os.path.join(os.path.dirname(__file__), '..', 'schema')
for (root, dirs, files) in os.walk(schema_dir):
for schema_file in files:
with open(os.path.join(root, schema_file), 'r') as fh:
schema = json.load(fh)
resolver.store[schema['id']] = schema
format_checker = FormatChecker()
# JS: '^([12]\\d{3}(-[01]?[1-9](-[0123]?[1-9])?)?)?$'
date_re = re.compile('^([12]\d{3}(-[01]?[1-9](-[0123]?[1-9])?)?)?$')
@format_checker.checks('country-code')
def is_country_code(code):
return code.lower() in COUNTRY_NAMES.keys()
@format_checker.checks('partial-date')
def is_partial_date(date):
if date is None:
return True