Exemple #1
0
def process(p1Subjects, p2Subjects, P1_CLASHES, P2_CLASHES, SORTING_ORDER=None):
    shared_classes = {}

    p1_classes = {}
    p2_classes = {}

    sharedSubjects = set.intersection(p1Subjects, p2Subjects)
    p1Subjects = set.difference(p1Subjects, sharedSubjects)
    p2Subjects = set.difference(p2Subjects, sharedSubjects)

    for classTup in [ (p1Subjects, p1_classes),
                      (p2Subjects, p2_classes),
                      (sharedSubjects, shared_classes) ]:
        for c in classTup[0]:
            classes = get_classes(c)
            classTup[1].update(classes)
#            if not classes:
#                pass

     #           return c

    stuff = shared_classes.items()
    time_slots = [[False] * 24 for i in xrange(5)]
    tables = circles_generator.generate(stuff, time_slots, 0)
    # CLASHES is 0... if you try for clashes in your shared classes, you're
    # gonna have a bad time.

    tables.sort()

#    p1_tables = None
#    p2_tables = None

    for t in tables:
        p1_tmp_tables = tryMatch(t, p1_classes, P1_CLASHES)
        if p1_tmp_tables is not None:
            p2_tmp_tables = tryMatch(t, p2_classes, P2_CLASHES)
            if p2_tmp_tables is not None:
                p1_tables = p1_tmp_tables
                p2_tables = p2_tmp_tables

    p1_tables = circles_generator.sort_timetables(p1_tables, SORTING_ORDER)
    p2_tables = circles_generator.sort_timetables(p2_tables, SORTING_ORDER)

    return (p1_tables, p2_tables)
def process(subjects, SORTING_ORDER=None, CLASHES=0):
    all_classes = {}

    for c in subjects:
        classes = get_classes(c)
        all_classes.update(classes)

    stuff = all_classes.items()
    time_slots = [[False] * 24 for i in xrange(5)]
    tables = circles_generator.generate(stuff, time_slots, CLASHES)

    tables.sort()
    uniq = []
    for t in tables:
        if uniq == [] or uniq[-1] != t:
            uniq.append(t)
    tables = uniq

    tables = circles_generator.sort_timetables(tables, SORTING_ORDER)

    return tables