本文整理匯總了Python中cms.db.FileCacher.FileCacher.purge_cache方法的典型用法代碼示例。如果您正苦於以下問題:Python FileCacher.purge_cache方法的具體用法?Python FileCacher.purge_cache怎麽用?Python FileCacher.purge_cache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cms.db.FileCacher.FileCacher
的用法示例。
在下文中一共展示了FileCacher.purge_cache方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: extract_complexity
# 需要導入模塊: from cms.db.FileCacher import FileCacher [as 別名]
# 或者: from cms.db.FileCacher.FileCacher import purge_cache [as 別名]
def extract_complexity(task_id, file_lengther=None):
"""Extract the complexity of all submissions of the task. The
results are stored in a file task_<id>.info
task_id (int): the id of the task we are interested in.
file_lengther (class): a File-like object that tell the dimension
of the input (see example above for how to
write one).
return (int): 0 if operation was successful.
"""
with SessionGen() as session:
task = Task.get_from_id(task_id, session)
if task is None:
return -1
# Extracting the length of the testcase.
file_cacher = FileCacher()
testcases_lengths = [file_length(testcase.input,
file_cacher, file_lengther)
for testcase in task.testcases]
file_cacher.purge_cache()
# Compute the complexity of the solutions.
with open("task_%s.info" % task_id, "wt") as info:
for submission in task.contest.get_submissions():
if submission.task_id == task_id and \
submission.evaluated():
print submission.user.username
result = extract_complexity_submission(testcases_lengths,
submission)
if result[1] is None:
continue
info.write("Submission: %s" % submission.id)
info.write(" - user: %15s" % submission.user.username)
info.write(" - task: %s" % task.name)
if result[0] is not None:
info.write(" - score: %6.2lf" % result[0])
info.write(" - complexity: %20s" %
complexity_to_string(result[1]))
if result[2] is not None:
info.write(" - confidence %5.1lf" % result[2])
info.write("\n")
return 0