本文整理汇总了Python中jsonschema._utils.format_as_index方法的典型用法代码示例。如果您正苦于以下问题:Python _utils.format_as_index方法的具体用法?Python _utils.format_as_index怎么用?Python _utils.format_as_index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jsonschema._utils
的用法示例。
在下文中一共展示了_utils.format_as_index方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __unicode__
# 需要导入模块: from jsonschema import _utils [as 别名]
# 或者: from jsonschema._utils import format_as_index [as 别名]
def __unicode__(self):
essential_for_verbose = (
self.validator, self.validator_value, self.instance, self.schema,
)
if any(m is _unset for m in essential_for_verbose):
return self.message
pschema = pprint.pformat(self.schema, width=72)
pinstance = pprint.pformat(self.instance, width=72)
return self.message + textwrap.dedent("""
Failed validating %r in schema%s:
%s
On instance%s:
%s
""".rstrip()
) % (
self.validator,
_utils.format_as_index(list(self.relative_schema_path)[:-1]),
_utils.indent(pschema),
_utils.format_as_index(self.relative_path),
_utils.indent(pinstance),
)
示例2: __unicode__
# 需要导入模块: from jsonschema import _utils [as 别名]
# 或者: from jsonschema._utils import format_as_index [as 别名]
def __unicode__(self):
essential_for_verbose = (
self.validator,
self.validator_value,
self.instance,
self.schema,
)
if any(m is _unset for m in essential_for_verbose):
return self.message
self.schema = yaml.dump(
json.loads(json.dumps(self.schema, sort_keys=True, indent=4))
)
self.instance = yaml.dump(
json.loads(json.dumps(self.instance, sort_keys=True, indent=4))
)
pschema = yaml.dump(self.schema, default_flow_style=False)
pinstance = yaml.dump(self.instance, default_flow_style=False)
return (
self.message
+ textwrap.dedent(
"""
Failed validating %s at %s:
%s
By %r validator in %s at %s:
%s
""".rstrip()
)
% (
self._word_for_instance_in_error_message,
_utils.format_as_index(self.relative_path),
pinstance,
self.validator,
self._word_for_schema_in_error_message,
_utils.format_as_index(list(self.relative_schema_path)[:-1]),
pschema,
)
)