本文整理汇总了Python中files.models.FileValidation类的典型用法代码示例。如果您正苦于以下问题:Python FileValidation类的具体用法?Python FileValidation怎么用?Python FileValidation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileValidation类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: file_validator
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
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
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
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)