本文整理汇总了Python中detector.Detector.run方法的典型用法代码示例。如果您正苦于以下问题:Python Detector.run方法的具体用法?Python Detector.run怎么用?Python Detector.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类detector.Detector
的用法示例。
在下文中一共展示了Detector.run方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from detector import Detector [as 别名]
# 或者: from detector.Detector import run [as 别名]
def run(self):
'''Reads assignments from Assignment_* folders, student numbers from
their Assignment_x folder, generates a zip of each students' code
files and runs the Detector on it'''
assignment_id_map = {}
assignments = self.get_folder_names(self.path)
database = DatabaseManager()
for assignment in assignments:
document_assignment_number = self.get_assignment_number(assignment)
if document_assignment_number not in (6, 5):
continue
if document_assignment_number not in assignment_id_map:
name = 'Assignment %d' % document_assignment_number
assignment_id_map[document_assignment_number] = database.store_assignment(name, name, '2015-01-01')
assignment_number = assignment_id_map[document_assignment_number]
assignment_path = os.path.join(self.path, assignment)
student_numbers = self.get_folder_names(assignment_path)
for student_number in student_numbers:
student_folder = os.path.join(assignment_path, student_number)
output_file = StringIO()
zip = zipfile.ZipFile(output_file, 'w')
for file in self.get_file_names(student_folder):
zip.write(os.path.join(student_folder, file), file)
print('zipping: ' + file)
zip.close()
detector = Detector()
detector.run(output_file, assignment_number,student_number)