Ejemplo n.º 1
0
    def class_sum_info(key):
        filename = '../InData/' + key['TeacherID'] + '_' + key[
            'CourseID'] + '_Sum.csv'
        class_info = DataManage(DataManage.target_info,
                                args=(filename, )).run()

        if not class_info:
            print '课程%s没有生成考勤汇总表!无法显示考勤结果 ' % (key['CourseID'])
            return False

        course_info = DataManage(DataManage.target_info,
                                 args=('../InData/courseInfo.csv', {
                                     'CourseID':
                                     key['CourseID'],
                                     'TeacherID':
                                     key['teacher_info']['TeacherID']
                                 })).run()

        if not course_info:
            print '当前没有与您相关的课程!'
            return False

        class_list = []

        for course in course_info:
            if course['ClassName'] not in class_list:
                class_list.append(course['ClassName'])

        stu_list = []
        stu_info = DataManage(DataManage.target_info,
                              args=('../InData/studentInfo.csv', )).run()
        for stu in stu_info:
            if stu['ClassID'] in class_list:
                stu_list.append(stu)

        length = len(class_info[0].keys())
        stu_info = {}
        for stu in class_info:
            if not stu_info.has_key(stu['StuID']):
                info = {}
                for s in stu_list:
                    if s['StuID'] == stu['StuID']:
                        info['Name'] = s['StuName']
                        break
                info['normal'] = 0
                info['Absence'] = 0
                info['approve'] = 0
                info['leaveEarlier'] = 0
                info['Late'] = 0
                stu_info[stu['StuID']] = info

            for index in range(1, length):
                stu_info[stu['StuID']][stu['checkin' + str(index)]] += 1

        for (key, item) in stu_info.items():
            print '学号 :%-15s 姓名:%-10s出勤:%-2d 缺勤:%-2d 早退:%-2d 迟到:%-2d 请假:%-2d ' \
                  % (key, item['Name'], item['normal'], item['Absence'], item['leaveEarlier'], item['Late'],
                     item['approve'])

        return True
Ejemplo n.º 2
0
 def import_file(source_file,
                 out_file,
                 _format=None,
                 primary_key=None,
                 operation=None,
                 path=''):
     if operation:
         data = operation(out_file, path)
         if not data:
             print '文件不存在或与标准形式不符,请检查您的输入!'
             return False
     else:
         data = DataManage(DataManage.target_info, args=(out_file, )).run()
     error = DataManage(DataManage.format_check, args=(data, _format)).run()
     if DataManage(DataManage.get_result, args=(error, )).run():
         for (key, item) in error.items():
             print key, item
         Log().add(error)
         return False
     for key in primary_key:
         DataManage(DataManage.update,
                    args=(source_file, 'w', data, key)).run()
         data = DataManage(DataManage.target_info,
                           args=(source_file, )).run()
     return True