本文整理汇总了Python中files.models.FileValidation.from_json方法的典型用法代码示例。如果您正苦于以下问题:Python FileValidation.from_json方法的具体用法?Python FileValidation.from_json怎么用?Python FileValidation.from_json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类files.models.FileValidation
的用法示例。
在下文中一共展示了FileValidation.from_json方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: file_validator
# 需要导入模块: from files.models import FileValidation [as 别名]
# 或者: from files.models.FileValidation import from_json [as 别名]
def file_validator(file_id, **kw):
if not settings.VALIDATE_ADDONS:
return None
log.info('VALIDATING file: %s' % file_id)
file = File.objects.get(pk=file_id)
result = run_validator(file.file_path)
return FileValidation.from_json(file, result)
示例2: handle_file_validation_result
# 需要导入模块: from files.models import FileValidation [as 别名]
# 或者: from files.models.FileValidation import from_json [as 别名]
def handle_file_validation_result(results, file_id):
"""Annotates a set of validation results and saves them to the given
File instance."""
result = annotate_validation_results(results)
file_ = File.objects.get(pk=file_id)
return FileValidation.from_json(file_, result)
示例3: handle_file_validation_result
# 需要导入模块: from files.models import FileValidation [as 别名]
# 或者: from files.models.FileValidation import from_json [as 别名]
def handle_file_validation_result(results, file_id, annotate=True):
"""Annotates a set of validation results, unless `annotate is false, and
saves them to the given File instance."""
if annotate:
results = annotate_validation_results(results)
file_ = File.objects.get(pk=file_id)
return FileValidation.from_json(file_, results)
示例4: file_validator
# 需要导入模块: from files.models import FileValidation [as 别名]
# 或者: from files.models.FileValidation import from_json [as 别名]
def file_validator(file_id, **kw):
if not settings.VALIDATE_ADDONS:
return None
log.info(u'[File:%s] Validating file.' % file_id)
try:
file = File.objects.get(pk=file_id)
except File.DoesNotExist:
log.info(u'[File:%s] Does not exist.' % file_id)
return
# Unlike upload validation, let the validator raise an exception if there
# is one.
result = run_validator(file.file_path)
return FileValidation.from_json(file, result)