当前位置: 首页>>代码示例>>Python>>正文


Python Course.getSeats方法代码示例

本文整理汇总了Python中models.Course.getSeats方法的典型用法代码示例。如果您正苦于以下问题:Python Course.getSeats方法的具体用法?Python Course.getSeats怎么用?Python Course.getSeats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Course的用法示例。


在下文中一共展示了Course.getSeats方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: process

# 需要导入模块: from models import Course [as 别名]
# 或者: from models.Course import getSeats [as 别名]

#.........这里部分代码省略.........
                    value = convert_time(value, student_wb)

                student_args[name] = value

        if not(invalid_row):
            students.append(Student(**student_args))
        else:
            # Student was mising a column they needed.
            invalid_students.append(i)

    courses = {}
    
    # Values that may be blank.
    course_acceptable_blanks = []
    invalid_courses = []

    # Put course information into course object.
    for i in range(1, course_sheet.nrows):
        invalid_row = False
        course_args = {}
        for name, col in course_headers.iteritems():
            cell_type = course_sheet.cell_type(i, col)
            if cell_type == xlrd.XL_CELL_EMPTY:
                invalid_row = True
                break
            else:
                course_args[name] = course_sheet.cell_value(i, col)

        if not(invalid_row):
            course = Course(**course_args)
            # Either add seats to existing course, or set course that
            # we haven't seen before.
            try:
                courses[course.getName()].addSeats(course.getSeats())
            except KeyError:
                courses[course.getName()] = course
        else:
            invalid_courses.append(i)

    # For testing, print values of courses.
    #for k, v in courses.iteritems():
    #    print([k])
    #    print(u"Course: {}; Seats: {}".format(v.getName(), v.getSeats()))

    # Do allocation of students, returns unsorted students and courses that were
    # not found, and also inserts students into the students list in each course
    unsorted_students, missing_courses = sortStudents(students, courses)
    # At this point,  courses will have had their arrays filled with students.
    
    ### UNSORTED STUDENTS ###
    u_students_filename = timeStamped("unsorted-students.xls")
    u_students_wb_path = os.path.join(
        app.config['UPLOAD_FOLDER'],
        u_students_filename
    )

    # Construct workbooks and populate them.
    unsorted_students_wb = xlwt.Workbook()
    unsorted_students_sheet = unsorted_students_wb.add_sheet("Students")
    unsorted_student_headers = [
        "ID", "First Name", "Last Name", "First Year Seminar DDB 1", "First Year Seminar DDB 2", "First Year Seminar DDB 3"
    ]
    for index, header in enumerate(unsorted_student_headers):
        unsorted_students_sheet.write(0, index, header)

    for i, student in enumerate(unsorted_students):
开发者ID:chrahunt,项目名称:fsem-scheduler,代码行数:70,代码来源:app.py


注:本文中的models.Course.getSeats方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。