Example #1
0
def main():
    group_id = get_group_id('Фт-340007')
    schedule = get_group_schedule(group_id)
    periods = extract_periods(schedule)
    tt = Timetable()
    tt.load_periods(periods)
    print(tt)
Example #2
0
    def setUp(self):
        #create an empty timetable of 5 days
        classrooms = [
            Classroom('LT ', 45, 'PBOO2'),
            Classroom('PB001', 100, 'Petroleum building'),
            Classroom('Main Library ', 60, 'Admiss'),
            Classroom('Room C', 67, 'N1'),
            Classroom(' A110', 300, 'Libary')
        ]

        timeslots = [
            TimeSlot('8:00', '9:00'),
            TimeSlot('9:00', '10:00'),
            TimeSlot('10:00', '11:00'),
            TimeSlot('11:00', '12:00'),
            TimeSlot('12:00', '13:00'),
            TimeSlot('13:00', '14:00')
        ]

        days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']
        day_tables = []

        self.days = days
        for day in days:
            day_tables.append(DayTimetable(classrooms, timeslots, day))

        self.timetable = Timetable(days, day_tables)
Example #3
0
def fetch_timetables(subjects):
    from timetable import Timetable
    subject_timetables = []
    for year, semester, subject_code in subjects:
        subject_timetables.append(
            Timetable.get(year, semester, subject_code))

    return subject_timetables
Example #4
0
def parse(timetable_html):

    soup = BeautifulSoup(timetable_html, 'html.parser')
    results = soup.find_all('td', attrs={'valign': 'top'})
    days = []
    for day in results:
        days.append(parse_days(day))
    timetable = Timetable(days[0], days[1], days[2], days[3], days[4], days[5])
    return timetable
Example #5
0
def timetable_action(action, uid):
    timetable = Timetable.get(db.session, uid)
    if not timetable:
        raise StandardError("No timetable for id '%s'" % uid)
    if action == "pause":
        Timetable.pause(db.session, timetable)
    elif action == "resume":
        Timetable.resume(db.session, timetable)
    elif action == "cancel":
        Timetable.cancel(db.session, timetable)
    else:
        raise StandardError("Invalid action '%s'" % action)
    return success(timetable.json())
    def __init__(self):
        super().__init__()

        string_buffer = get_routes()

        header_row = string_buffer.readline().lower().split(';')
        _ = string_buffer.readline(), string_buffer.readline(
        )  # throw away unnecessary lines

        fieldnames = [
            field if (field not in self.key_translation) else
            self.key_translation[field] for field in header_row
        ]

        stops = MinibusStops()

        last_route_number = None
        for column_values, timetable in itertools.zip_longest(
                *[string_buffer] * 2):
            timetable = timetable.strip()
            column_values = column_values.split(';')

            route_data = dict(zip(fieldnames, column_values))

            route_number = route_data['route_number']
            route_type = route_data['route_type']
            route_name = route_data['route_name']
            route_stops = [
                route_stop
                for route_stop in route_data['route_stops'].split(',')
                if len(route_stop) > 0
            ]

            if len(route_number) == 0:
                route_number = last_route_number

            route_stops = [stops[route_stop] for route_stop in route_stops]

            route_id = RouteID(route_number=route_number, type=route_type)
            route = MinibusRoute(name=route_name,
                                 stops=route_stops,
                                 timetable=Timetable(timetable))
            last_route_number = route_number
            self[route_id] = route
Example #7
0
    def __init__(self, path, qtable):
        self.timetable = Timetable(json_path=path)
        self.resources = self.timetable.resources
        self.trains = list(self.timetable.trains.values())

        self.events = defaultdict(list)
        self.qtable = qtable

        self.current_time = 0
        self.min_time = 9999999
        self.max_time = 0
        self.wait_time = 10.0
        self.done = False
        self.late_on_node = False

        self.with_connections = True
        self.max_delta = 60 * 30

        self.priorities = {}
        # self.blocked_trains = set()

        self.assign_sections_to_resources()
Example #8
0
    def to_timetable(timetable_html):
        html = BeautifulSoup(timetable_html)

        # Find timetable table
        tables = html.findAll(name='table')
        calendar_table = None
        for table in tables:
            if table.find(name='center', text='Squash Belegungsplan'):
                calendar_table = table
                break
        if not calendar_table:
            raise Exception('Could not find timetable from response ' +
                            html_str)

        # Get all "time" rows
        all_rows = calendar_table.findAll(name='tr')
        time_rows = []
        for row in all_rows:
            found = row.find(name='td', text=' ')
            if found:
                time_rows.append(row)

        # Build availability map
        timetable = {}
        for time_row in time_rows:
            key = time_row.find(name='td', attrs={'align': 'center'}).text
            courts_availability = [False, False, False, False, False]
            spots = []
            for td in time_row.findAll(name='td'):
                if td.text == ' ':
                    spots.append(td)
            for i in range(0, 5):
                if len(spots[i].attrs) == 1:
                    courts_availability[i] = spots[i].attrs[0][1].strip(
                    ) == 'background:#ffffff;'

            timetable[key] = courts_availability

        return Timetable(timetable)
Example #9
0
                                 18 * 3600, 19 * 3600, 3, 3)
    #     # print(u.set_valid_timetables(u.get_valid_combinations()))
    #     # print(len(u.get_valid_combinations()))
    a = u.get_valid_combinations()
    print(len(a[0]), len(a[1]))
    #     # print(len(a[0]) * len(a[1]))
    for h in range(0, 1):
        try:
            # Sampling
            cm = CourseManager()
            for i in cm._break_down_nested_list(a[0][h]):
                print(i.get_code())
                print(i.get_meeting_section())
            # =====Testing Purposes=====
            t = TimetableManager()
            f = Timetable()
            for i in cm._break_down_nested_list(a[0][0]):
                f.add_course([i], u.get_first_semester_filter())
            print(f.get_first_semester_table())
            print(f.get_second_semester_table())
        except (IndexError):
            print("No Solutions Found")
#
# print(len(u._get_combinations()))
# for i in u._get_combinations():
#     for b in i:
#         print(b._get_meeting_section())
#     print("----------------")
# print(u._second_semester_courses)
# print(u._first_semester_courses[0].get_meeting_sections())
# print(u.get_combinations())
Example #10
0
from timetable import Timetable
import argparse
import sys

if __name__ == "__main__":
    parser = argparse.ArgumentParser(
        description='Create html time table from event list')
    parser.add_argument('path1',
                        metavar='timetable path',
                        help='xlsx timetable file path')
    parser.add_argument('path2',
                        metavar='event_id path',
                        help='event_id list file path ')
    parser.add_argument('-o',
                        metavar='output file',
                        help='Output file location.')
    args = parser.parse_args()

    t = Timetable(args.path1)
    with open(args.path2, 'r') as f:
        events = f.read().splitlines()
        t.load_events(events)
        out = t.render_html()

        if args.o:
            with open(args.o, 'w') as f1:
                f1.write(out)
        else:
            print(out)
Example #11
0
class TestTimetable(TestCase):
    def setUp(self):
        #create an empty timetable of 5 days
        classrooms = [
            Classroom('LT ', 45, 'PBOO2'),
            Classroom('PB001', 100, 'Petroleum building'),
            Classroom('Main Library ', 60, 'Admiss'),
            Classroom('Room C', 67, 'N1'),
            Classroom(' A110', 300, 'Libary')
        ]

        timeslots = [
            TimeSlot('8:00', '9:00'),
            TimeSlot('9:00', '10:00'),
            TimeSlot('10:00', '11:00'),
            TimeSlot('11:00', '12:00'),
            TimeSlot('12:00', '13:00'),
            TimeSlot('13:00', '14:00')
        ]

        days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']
        day_tables = []

        self.days = days
        for day in days:
            day_tables.append(DayTimetable(classrooms, timeslots, day))

        self.timetable = Timetable(days, day_tables)

#     @property
#     def test_day_table(self):

#         self.fail()

    def test_add_lecture(self):
        pass
        lecturer = Lecturer('Benjamin Kommey', 4564541, 'Mr')
        course = Course('Embedded Systems', 'COE 361')

        section = Section('ED CoE', 25, 3,
                          'Electrical and Electronics Engineering',
                          'Computer Engineering')
        c_item = CurriculumItem(section, course, lecturer)

        lecture = Lecture(c_item, 60)

        ttslot = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                               TimeSlot('8:00', '9:00'))
        ttslot1 = TimetableSlot('Tuesday', Classroom(' A110', 300, 'Libary'),
                                TimeSlot('9:00', '10:00'))
        ttslot2 = TimetableSlot('Thursday', Classroom('Room C', 67, 'N1'),
                                TimeSlot('10:00', '11:00'))
        ttslot3 = TimetableSlot('Friday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('11:00', '12:00'))
        ttslot4 = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('10:00', '11:00'))
        print(self.timetable)
        self.assertTrue(self.timetable.add_lecture('Monday', lecture, ttslot))
        self.assertTrue(
            self.timetable.timetableslot('Monday', ttslot1.room,
                                         ttslot1.time_slot).is_occupied, True)
        self.assertTrue(self.timetable.add_lecture('Tuesday', lecture,
                                                   ttslot1))
        self.assertTrue(
            self.timetable.add_lecture('Thursday', lecture, ttslot2))
        self.assertTrue(self.timetable.add_lecture('Friday', lecture, ttslot3))
        print(
            '############################### Add Lecture ############################'
        )
        print(self.timetable)
        self.timetable.timetable['Monday'].remove_time_table_slot(
            Classroom('LT ', 45, 'PBOO2'), TimeSlot('9:00', '10:00'))
        print(
            '####################################################################'
        )
        print(self.timetable)
        self.timetable.timetable['Monday'].move_lecture(ttslot, ttslot4)
        print(self.timetable.timetable)

        self.assertNotEqual(self.timetable.timetable['Monday'],
                            self.timetable.timetable['Tuesday'])

    def test_move_lecture(self):
        print(
            '############################################## Testing Move Lecture ######################'
        )
        print(
            '##########################################################################################'
        )
        print(
            '##########################################################################################'
        )
        lecturer = Lecturer('Benjamin Kommey', 4564541, 'Mr')
        course = Course('Embedded Systems', 'COE 361')

        section = Section('ED CoE', 25, 3,
                          'Electrical and Electronics Engineering',
                          'Computer Engineering')
        c_item = CurriculumItem(section, course, lecturer)

        lecture = Lecture(c_item, 60)

        ttslot = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                               TimeSlot('8:00', '9:00'))
        ttslot1 = TimetableSlot('Tuesday', Classroom(' A110', 300, 'Libary'),
                                TimeSlot('9:00', '10:00'))
        ttslot2 = TimetableSlot('Thursday', Classroom('Room C', 67, 'N1'),
                                TimeSlot('10:00', '11:00'))
        ttslot3 = TimetableSlot('Friday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('11:00', '12:00'))
        ttslot4 = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('9:00', '10:00'))
        ttslot5 = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('16:00', '17:00'))
        self.assertTrue(self.timetable.add_lecture('Monday', lecture, ttslot))
        self.assertTrue(self.timetable.add_lecture('Tuesday', lecture,
                                                   ttslot1))
        self.assertTrue(
            self.timetable.add_lecture('Thursday', lecture, ttslot2))
        self.assertTrue(self.timetable.add_lecture('Friday', lecture, ttslot3))
        print(
            '############################ Before Moving lecture to another slot ##########################'
        )
        print(self.timetable)
        #moving lecture to another slot (existing and free) on the same day
        print(
            '############################ Moving lecture to another slot on same day##########################'
        )
        self.timetable.move_lecture(ttslot.day, ttslot, ttslot4.day, ttslot4)
        print(self.timetable)

        # move lecture to another (non existant) slot on the same day
        print(
            '############### Move Lecture to another slot (non existant) on the same day ###############'
        )
        self.assertFalse(
            print(
                self.timetable.move_lecture(ttslot.day, ttslot, ttslot5.day,
                                            ttslot5)))
        print(self.timetable)

        # move lecture to another slot (existing and free) on a different day
        print(
            '################## move lecture to another slot (existing and free) on a different day ##########'
        )
        #self.assertTrue(self.timetable.move_lecture(ttslot.day,ttslot,'Friday',TimetableSlot('Friday', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00'))))
        print(self.timetable)

        # move lecture to another slot (non existant ) on a different day
        print(
            '################## move lecture to another slot (non existant ) on a different day on a different day ##########'
        )
        self.assertFalse(
            self.timetable.move_lecture(
                ttslot.day, ttslot, 'Monday',
                TimetableSlot('Friday', Classroom('LT ', 45, 'PBOO2'),
                              TimeSlot('18:00', '19:00'))))
        print(self.timetable)

        # move lecture to the same slot on the same day
        print(
            '################## move lecture to the same slot on the same day ##########'
        )
        self.assertFalse(
            self.timetable.move_lecture(ttslot.day, ttslot, ttslot.day,
                                        ttslot))
        print(self.timetable)

        # Move lecture to the same slot (existing and free) on a different day
        print(
            '################## Move lecture to the same slot (existing and free) on a different dayy ##########'
        )
        #self.assertTrue(self.timetable.move_lecture(ttslot.day,ttslot,'Friday',TimetableSlot('Friday', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00'))))
        print(self.timetable)

        # move lecture to another slot (existing and occupied) on the same day

        # move lecture to another slot (existing and occpied) on the on a different day

        pass

    def test_swap_lectures(self):
        pass
        #Test later, not called in generator at the moment
        lecturer = Lecturer('Benjamin Kommey', 4564541, 'Mr')
        course = Course('Embedded Systems', 'COE 361')

        section = Section('ED CoE', 25, 3,
                          'Electrical and Electronics Engineering',
                          'Computer Engineering')
        c_item = CurriculumItem(section, course, lecturer)

        lecture = Lecture(c_item, 60)

        ttslot = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                               TimeSlot('8:00', '9:00'))
        ttslot1 = TimetableSlot('Tuesday', Classroom(' A110', 300, 'Libary'),
                                TimeSlot('9:00', '10:00'))
        ttslot2 = TimetableSlot('Thursday', Classroom('Room C', 67, 'N1'),
                                TimeSlot('10:00', '11:00'))
        ttslot3 = TimetableSlot('Friday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('11:00', '12:00'))
        self.assertTrue(self.timetable.add_lecture('Monday', lecture, ttslot))
        self.assertTrue(self.timetable.add_lecture('Tuesday', lecture,
                                                   ttslot1))
        self.assertTrue(
            self.timetable.add_lecture('Thursday', lecture, ttslot2))
        self.assertTrue(self.timetable.add_lecture('Friday', lecture, ttslot3))
        print(self.timetable)

    #test cases

    #swapping with invalid parameters
    ####################Expected results for all cases##########################
    # No lecture should be moved
    # return false
    # No exception should be raised
    ############################################################################
    #invadlid days
    #invalid day1
    #self.assertFalse(self.timetable.swap_lectures('Saturday',ttslot))
    #invalid day2

    #invalid slots
    #invalid slot1
    #invalid slot2

    #swapping with one empty slot
    ####################Expected results for all cases##########################
    # No lecture should be moved
    # return false
    # No exception should be raised
    ############################################################################
    #empty source slot

    #empty desitnation slot

    #swapping with both empty slots
    ####################Expected results for all cases##########################
    # No lecture should be moved
    # return false
    # No exception should be raised
    ############################################################################

    #swapping on the same day
    ####################Expected results for all cases##########################
    # Move lecture in case of same slot
    # Dont move in case of different slots
    # return True if different slots and false in same
    # No exception should be raised
    ############################################################################
    #same slot  @property
    def test_day_table(self):
        pass

    # def test_add_lecture(self):
    #     pass
    #     lecturer = Lecturer('Benjamin Kommey',4564541,'Mr')
    #     course = Course('Embedded Systems','COE 361')

    #     section = Section('ED CoE',25,3,'Electrical and Electronics Engineering','Computer Engineering')
    #     c_item = CurriculumItem(section,course,lecturer)

    #     lecture = Lecture(c_item,60)

    #     ttslot =  TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00'))
    #     ttslot1 =TimetableSlot('Tuesday', Classroom(' A110', 300, 'Libary'),TimeSlot('9:00', '10:00'))
    #     ttslot2 = TimetableSlot('Thursday', Classroom('Room C', 67, 'N1'),TimeSlot('10:00', '11:00'))
    #     ttslot3 = TimetableSlot('Friday', Classroom('LT ', 45, 'PBOO2'),TimeSlot('11:00', '12:00'))
    #     ttslot4 =  TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),TimeSlot('10:00', '11:00'))
    #     print(self.timetable)
    #     self.assertTrue(self.timetable.timetable['Monday'].add_lecture(lecture,ttslot))
    #     self.assertTrue(self.timetable.add_lecture('Tuesday',lecture,ttslot1))
    #     self.assertTrue(self.timetable.add_lecture('Thursday',lecture,ttslot2))
    #     self.assertTrue(self.timetable.add_lecture('Friday',lecture,ttslot3))
    #     print('############################### Add Lecture ############################')
    #     print(self.timetable)
    #     self.timetable.timetable['Monday'].remove_time_table_slot(Classroom('LT ', 45, 'PBOO2'),TimeSlot('9:00','10:00'))
    #     print('####################################################################')
    #     print(self.timetable)
    #     self.timetable.timetable['Monday'].move_lecture(ttslot,ttslot4)
    #     print(self.timetable)

    #     self.assertNotEqual(self.timetable.timetable['Monday'],self.timetable.timetable['Tuesday'])

    # def test_move_lecture(self):
    #     pass
    #     lecturer = Lecturer('Benjamin Kommey',4564541,'Mr')
    #     course = Course('Embedded Systems','COE 361')

    #     section = Section('ED CoE',25,3,'Electrical and Electronics Engineering','Computer Engineering')
    #     c_item = CurriculumItem(section,course,lecturer)

    #     lecture = Lecture(c_item,60)

    #     ttslot =  TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00'))
    #     ttslot1 =TimetableSlot('Tuesday', Classroom(' A110', 300, 'Libary'),TimeSlot('9:00', '10:00'))
    #     ttslot2 = TimetableSlot('Thursday', Classroom('Room C', 67, 'N1'),TimeSlot('10:00', '11:00'))
    #     ttslot3 = TimetableSlot('Friday', Classroom('LT ', 45, 'PBOO2'),TimeSlot('11:00', '12:00'))
    #     ttslot4 =  TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),TimeSlot('9:00', '10:00'))
    #     self.assertTrue(self.timetable.add_lecture('Monday',lecture,ttslot))
    #     self.assertTrue(self.timetable.add_lecture('Tuesday',lecture,ttslot1))
    #     self.assertTrue(self.timetable.add_lecture('Thursday',lecture,ttslot2))
    #     self.assertTrue(self.timetable.add_lecture('Friday',lecture,ttslot3))
    #     print('############################ Before Moving lecture to another slot on same day##########################')
    #     print(self.timetable)
    #     #moving lecture to another slot (existing and free) on the same day
    #     print('############################ Moving lecture to another slot on same day##########################')
    #     self.timetable.move_lecture(ttslot.day,ttslot,ttslot4.day,ttslot4)
    #     print(self.timetable)

    #move lecture to another (non existant) slot on the same day

    #move lecture to another slot (existing and free) on a different day

    #move lecture to another slot (non existant ) on the same day

    #move lecture to the same slot on the same day

    #Move lecture to the same slot (existing and free) on a different day

    #move lecture to another slot (existing and occupied) on the same day

    #move lecture to another slot (existing and occpied) on the on a different day

    # def test_swap_lectures(self):
    #     pass
    #     # #Test later, not called in generator at the moment
    #     # lecturer = Lecturer('Benjamin Kommey',4564541,'Mr')
    #     # course = Course('Embedded Systems','COE 361')

    #     # section = Section('ED CoE',25,3,'Electrical and Electronics Engineering','Computer Engineering')
    #     # c_item = CurriculumItem(section,course,lecturer)

    #     # lecture = Lecture(c_item,60)

    #     # ttslot =  TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00'))
    #     # ttslot1 =TimetableSlot('Tuesday', Classroom(' A110', 300, 'Libary'),TimeSlot('9:00', '10:00'))
    #     # ttslot2 = TimetableSlot('Thursday', Classroom('Room C', 67, 'N1'),TimeSlot('10:00', '11:00'))
    #     # ttslot3 = TimetableSlot('Friday', Classroom('LT ', 45, 'PBOO2'),TimeSlot('11:00', '12:00'))
    #     # self.assertTrue(self.timetable.add_lecture('Monday',lecture,ttslot))
    #     # self.assertTrue(self.timetable.add_lecture('Tuesday',lecture,ttslot1))
    #     # self.assertTrue(self.timetable.add_lecture('Thursday',lecture,ttslot2))
    #     # self.assertTrue(self.timetable.add_lecture('Friday',lecture,ttslot3))
    #     # print(self.timetable)

    #    #test cases

    #    #swapping with invalid parameters
    #             ####################Expected results for all cases##########################
    #             # No lecture should be moved
    #             # return false
    #             # No exception should be raised
    #             ############################################################################
    #         #invadlid days
    #             #invalid day1
    #             #self.assertFalse(self.timetable.swap_lectures('Saturday',ttslot))
    #             #invalid day2

    #         #invalid slots
    #             #invalid slot1
    #             #invalid slot2

    #    #swapping with one empty slot
    #             ####################Expected results for all cases##########################
    #             # No lecture should be moved
    #             # return false
    #             # No exception should be raised
    #             ############################################################################
    #         #empty source slot

    #         #empty desitnation slot

    #    #swapping with both empty slots
    #              ####################Expected results for all cases##########################
    #             # No lecture should be moved
    #             # return false
    #             # No exception should be raised
    #             ############################################################################

    #    #swapping on the same day
    #              ####################Expected results for all cases##########################
    #             # Move lecture in case of same slot
    #             # Dont move in case of different slots
    #             # return True if different slots and false in same
    #             # No exception should be raised
    #             ############################################################################
    #         #same slot

    #         #different slot

    #    #swapping accross days
    #             ####################Expected results for all cases##########################
    #             # Move lecture
    #             # Dont move in case of different slots
    #             # return True
    #             # No exception should be raised
    #             ############################################################################
    #         #same slot

    #         #different slot

    def test_remove_lecture(self):
        print(
            '################################### Test Removing Lectures ###############################'
        )
        lecturer = Lecturer('Benjamin Kommey', 4564541, 'Mr')
        course = Course('Embedded Systems', 'COE 361')

        section = Section('ED CoE', 25, 3,
                          'Electrical and Electronics Engineering',
                          'Computer Engineering')
        c_item = CurriculumItem(section, course, lecturer)

        lecture = Lecture(c_item, 60)

        ttslot = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                               TimeSlot('8:00', '9:00'))
        ttslot1 = TimetableSlot('Tuesday', Classroom(' A110', 300, 'Libary'),
                                TimeSlot('9:00', '10:00'))
        ttslot2 = TimetableSlot('Thursday', Classroom('Room C', 67, 'N1'),
                                TimeSlot('10:00', '11:00'))
        ttslot3 = TimetableSlot('Friday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('11:00', '12:00'))
        ttslot4 = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('10:00', '11:00'))
        print(self.timetable)
        self.assertTrue(self.timetable.add_lecture('Monday', lecture, ttslot))
        self.assertTrue(self.timetable.add_lecture('Tuesday', lecture,
                                                   ttslot1))
        self.assertTrue(
            self.timetable.add_lecture('Thursday', lecture, ttslot2))
        self.assertTrue(self.timetable.add_lecture('Friday', lecture, ttslot3))
        print(self.timetable)
        self.assertTrue(self.timetable.remove_lecture(ttslot.day, ttslot))
        self.assertTrue(self.timetable.remove_lecture(ttslot1.day, ttslot1))
        self.assertTrue(self.timetable.remove_lecture(ttslot2.day, ttslot2))
        self.assertTrue(self.timetable.remove_lecture(ttslot3.day, ttslot3))
        self.assertFalse(self.timetable.remove_lecture(ttslot4.day, ttslot4))
        print(self.timetable)

        print(
            '####################################################################'
        )
        print(self.timetable)
        self.timetable.timetable['Monday'].move_lecture(ttslot, ttslot4)

    def test_remove_all(self):
        print(
            '################################### Test Removing Lectures ###############################'
        )
        lecturer = Lecturer('Benjamin Kommey', 4564541, 'Mr')
        course = Course('Embedded Systems', 'COE 361')

        section = Section('ED CoE', 25, 3,
                          'Electrical and Electronics Engineering',
                          'Computer Engineering')
        c_item = CurriculumItem(section, course, lecturer)

        lecture = Lecture(c_item, 60)

        ttslot = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                               TimeSlot('8:00', '9:00'))
        ttslot1 = TimetableSlot('Tuesday', Classroom(' A110', 300, 'Libary'),
                                TimeSlot('9:00', '10:00'))
        ttslot2 = TimetableSlot('Thursday', Classroom('Room C', 67, 'N1'),
                                TimeSlot('10:00', '11:00'))
        ttslot3 = TimetableSlot('Friday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('11:00', '12:00'))
        ttslot4 = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('10:00', '11:00'))

        #print(self.timetable)
        self.assertTrue(self.timetable.add_lecture('Monday', lecture, ttslot))
        self.assertTrue(self.timetable.add_lecture('Tuesday', lecture,
                                                   ttslot1))
        self.assertTrue(
            self.timetable.add_lecture('Thursday', lecture, ttslot2))
        self.assertTrue(self.timetable.add_lecture('Friday', lecture, ttslot3))
        #print('############################## Before Adding Lecture ###########################')
        #print(self.timetable)
        #print('############################# After Removing Lecture #############################')
        self.assertTrue(self.timetable.remove_all())
        #print(self.timetable)

    def test_occupied_slots(self):
        print(
            '################################### Testing Occupied Slots ###############################'
        )
        lecturer = Lecturer('Benjamin Kommey', 4564541, 'Mr')
        course = Course('Embedded Systems', 'COE 361')

        section = Section('ED CoE', 25, 3,
                          'Electrical and Electronics Engineering',
                          'Computer Engineering')
        c_item = CurriculumItem(section, course, lecturer)

        lecture = Lecture(c_item, 60)

        ttslot = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                               TimeSlot('8:00', '9:00'))
        ttslot1 = TimetableSlot('Tuesday', Classroom(' A110', 300, 'Libary'),
                                TimeSlot('9:00', '10:00'))
        ttslot2 = TimetableSlot('Thursday', Classroom('Room C', 67, 'N1'),
                                TimeSlot('10:00', '11:00'))
        ttslot3 = TimetableSlot('Friday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('11:00', '12:00'))
        ttslot4 = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('10:00', '11:00'))

        #print(self.timetable)
        self.assertTrue(self.timetable.add_lecture('Monday', lecture, ttslot))
        self.assertTrue(self.timetable.add_lecture('Tuesday', lecture,
                                                   ttslot1))
        self.assertTrue(
            self.timetable.add_lecture('Thursday', lecture, ttslot2))
        self.assertTrue(self.timetable.add_lecture('Friday', lecture, ttslot3))

        slots = self.timetable.occupied_slots()

        for slot in slots:
            print(slot.lecture)

    def test_free_slots(self):
        lecturer = Lecturer('Benjamin Kommey', 4564541, 'Mr')
        course = Course('Embedded Systems', 'COE 361')

        section = Section('ED CoE', 25, 3,
                          'Electrical and Electronics Engineering',
                          'Computer Engineering')
        c_item = CurriculumItem(section, course, lecturer)

        lecture = Lecture(c_item, 60)

        ttslot = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                               TimeSlot('8:00', '9:00'))
        ttslot1 = TimetableSlot('Tuesday', Classroom(' A110', 300, 'Libary'),
                                TimeSlot('9:00', '10:00'))
        ttslot2 = TimetableSlot('Thursday', Classroom('Room C', 67, 'N1'),
                                TimeSlot('10:00', '11:00'))
        ttslot3 = TimetableSlot('Friday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('11:00', '12:00'))
        ttslot4 = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('10:00', '11:00'))

        #print(self.timetable)
        self.assertTrue(self.timetable.add_lecture('Monday', lecture, ttslot))
        self.assertTrue(self.timetable.add_lecture('Tuesday', lecture,
                                                   ttslot1))
        self.assertTrue(
            self.timetable.add_lecture('Thursday', lecture, ttslot2))
        self.assertTrue(self.timetable.add_lecture('Friday', lecture, ttslot3))
        print("############ Testing Free Slots##############################")
        slots = self.timetable.free_slots()

        for slot in slots:
            print(slot)

    def test_all_slots(self):
        lecturer = Lecturer('Benjamin Kommey', 4564541, 'Mr')
        course = Course('Embedded Systems', 'COE 361')

        section = Section('ED CoE', 25, 3,
                          'Electrical and Electronics Engineering',
                          'Computer Engineering')
        c_item = CurriculumItem(section, course, lecturer)

        lecture = Lecture(c_item, 60)

        ttslot = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                               TimeSlot('8:00', '9:00'))
        ttslot1 = TimetableSlot('Tuesday', Classroom(' A110', 300, 'Libary'),
                                TimeSlot('9:00', '10:00'))
        ttslot2 = TimetableSlot('Thursday', Classroom('Room C', 67, 'N1'),
                                TimeSlot('10:00', '11:00'))
        ttslot3 = TimetableSlot('Friday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('11:00', '12:00'))
        ttslot4 = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('10:00', '11:00'))

        #print(self.timetable)
        self.assertTrue(self.timetable.add_lecture('Monday', lecture, ttslot))
        self.assertTrue(self.timetable.add_lecture('Tuesday', lecture,
                                                   ttslot1))
        self.assertTrue(
            self.timetable.add_lecture('Thursday', lecture, ttslot2))
        self.assertTrue(self.timetable.add_lecture('Friday', lecture, ttslot3))
        print("############ Testing All Slots##############################")
        slots = self.timetable.all_slots()

        for slot in slots:
            print(slot)

    def test_lecturer_is_free(self):
        lecturer = Lecturer('Benjamin Kommey', 4564541, 'Mr')
        course = Course('Embedded Systems', 'COE 361')

        section = Section('ED CoE', 25, 3,
                          'Electrical and Electronics Engineering',
                          'Computer Engineering')
        c_item = CurriculumItem(section, course, lecturer)

        lecture = Lecture(c_item, 60)

        ttslot = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                               TimeSlot('8:00', '9:00'))
        ttslot1 = TimetableSlot('Tuesday', Classroom(' A110', 300, 'Libary'),
                                TimeSlot('9:00', '10:00'))
        ttslot2 = TimetableSlot('Thursday', Classroom('Room C', 67, 'N1'),
                                TimeSlot('10:00', '11:00'))
        ttslot3 = TimetableSlot('Friday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('11:00', '12:00'))
        ttslot4 = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('10:00', '11:00'))

        #print(self.timetable)
        self.assertTrue(self.timetable.add_lecture('Monday', lecture, ttslot))
        self.assertTrue(self.timetable.add_lecture('Tuesday', lecture,
                                                   ttslot1))
        self.assertTrue(
            self.timetable.add_lecture('Thursday', lecture, ttslot2))
        self.assertTrue(self.timetable.add_lecture('Friday', lecture, ttslot3))
        print("############ Testing All Slots##############################")

        self.assertFalse(
            self.timetable.lecturer_is_free('Monday', lecturer,
                                            TimeSlot('8:00', '9:00')))
        self.assertTrue(
            self.timetable.lecturer_is_free('Monday', lecturer,
                                            TimeSlot('9:00', '10:00')))
        self.assertFalse(
            self.timetable.lecturer_is_free('Tuesday', lecturer,
                                            TimeSlot('9:00', '10:00')))
        self.assertTrue(
            self.timetable.lecturer_is_free('Tuesday', lecturer,
                                            TimeSlot('8:00', '9:00')))
        self.assertFalse(
            self.timetable.lecturer_is_free('Thursday', lecturer,
                                            TimeSlot('10:00', '11:00')))
        self.assertTrue(
            self.timetable.lecturer_is_free('Thursday', lecturer,
                                            TimeSlot('9:00', '10:00')))
        self.assertFalse(
            self.timetable.lecturer_is_free('Friday', lecturer,
                                            TimeSlot('11:00', '12:00')))
        self.assertTrue(
            self.timetable.lecturer_is_free('Friday', lecturer,
                                            TimeSlot('18:00', '19:00')))

    def test_timetableslot(self):
        ttslot = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                               TimeSlot('8:00', '9:00'))
        self.assertEqual(
            self.timetable.timetableslot(ttslot.day, ttslot.room,
                                         ttslot.time_slot), ttslot)

    def test_best_fit(self):
        for day in self.days:
            self.assertTrue(self.timetable.day_is_valid(day))
        self.assertFalse(self.timetable.day_is_valid('Saturday'))

    def test_remove_slot(self):
        print(
            '##################################### TEST_REMOVE_SLOT##############################'
        )
        self.timetable.remove_slot('Monday', Classroom('LT ', 45, 'PBOO2'),
                                   TimeSlot('8:00', '9:00'))
        self.timetable.remove_slot('Monday', Classroom('LT ', 45, 'PBOO2'),
                                   TimeSlot('9:00', '10:00'))
        self.timetable.remove_slot('Wednesday', Classroom('LT ', 45, 'PBOO2'),
                                   TimeSlot('8:00', '9:00'))
        self.timetable.remove_slot('Thursday', Classroom('LT ', 45, 'PBOO2'),
                                   TimeSlot('8:00', '9:00'))
        print(self.timetable)
        print(
            '################################# INSERT SLOT #####################################'
        )
        self.timetable.insert_slot(
            'Monday',
            TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                          TimeSlot('8:00', '10:00')))
        print(self.timetable)

    def test_insert_slot(self):
        #tested in remove_slot()
        pass
Example #12
0
from timetable import Timetable
import argparse
import sys

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='List event_id for modules')
    parser.add_argument('path',
                        metavar='path',
                        help='File path to timetable xlsx spreadsheet.')
    parser.add_argument('modules',
                        metavar='module',
                        nargs='+',
                        help='List of modules.')
    parser.add_argument('-o',
                        metavar='output file',
                        help='Output file location.')
    args = parser.parse_args()

    t = Timetable(args.path)
    events = t.generate_event_list(args.modules)
    if args.o:
        with open(args.o, 'w') as f:
            for event in events:
                f.write(str(event) + '\n')
    else:
        for event in events:
            print(event)
Example #13
0
def timetable_get(uid):
    timetable = Timetable.get(db.session, uid)
    if not timetable:
        raise StandardError("No timetable for id '%s'" % uid)
    return success(timetable.json())
Example #14
0
def timetable_create():
    opts = request.get_json()
    timetable = Timetable.create(db.session, **opts)
    return success(timetable.json())
Example #15
0
File: main.py Project: febifrank/Qi
import re
import datetime
from bs4 import BeautifulSoup
from timetable import Timetable
from holiday import Holiday
from config import config
from auth import Auth
auth = Auth()
timetable = Timetable()
holiday = Holiday()

xnxqid = config.get('core', 'xnxqid')
url = 'https://isea.sztu.edu.cn/jsxsd/xskb/xskb_list.do?xnxq01id=' + xnxqid
r = auth.session.get(url, timeout=2)

soup = BeautifulSoup(r.text, features='html.parser')

tab = soup.findAll('table')[1]

i = 0

schedules = []

for tr in tab.findAll('tr'):
    if '--------' in tr.getText():
        day = 0
        for td in tr.findAll('td'):
            # 过滤掉备注
            if '--------' in td.getText():
                # print(td)
                # 处理多节课占用同一时间段
Example #16
0
            score += 10
        return score

    def daylength(self, events):
        score = 0
        if events[-1].end_time - events[0].start_time < 6 * 60:
            score += 10
        if sum(x.length_time for x in events) < 4 * 60:
            score += 10
        return score


if __name__ == "__main__":

    files = [
        "Room List.xlsx", "Roomequip.xlsx", "Timetable2018-19.xlsx",
        "buildings.csv"
    ]
    paths = [os.path.join("Data", x) for x in files]
    buildings = load_buildings()
    #rooms = load_rooms(paths[0], paths[1], buildings)
    timetable = Timetable(paths[2])
    modules = timetable.list_modules()

    test = sys.argv[1:]
    events = timetable.generate_event_list(test)
    timetable.load_events(events)
    m = TimetableMetrics(timetable, buildings, sys.argv[1])
    a = m.calc_metrics()
    m.get_averages(a)
Example #17
0
from timetable import Timetable
from datetime import datetime
import time

if __name__ == "__main__":
    # actual script of running the timetable
    path = "E:/Textbook/4th Year/CSC148/tokyo trains/"
    weekday ='weekday schedule.csv'
    weekend = 'weekend schedule.csv'
    train = Timetable()

    # determine which version to use
    if datetime.now().isoweekday() < 6:
        train.add_arrival(path + weekday)
    else:
        train.add_arrival(path + weekend)

    while True:
        train.JumpToNow()
        train.display()
        time.sleep(20)
        train.clear_table()
        train.service_unavailable()
from tkinter import *
import random
import time
from Tramwaje import Tram
from timetable import Timetable
from tkinter.ttk import *
from table_times_source import table_times
from table_locations_source import table_locations
"""
Data for testing - basic timetable and Tram

"""
timetable = Timetable(table_times, table_locations, 100)

tram_1 = Tram(1, (0, 20, 40, 60, 80, 100, 120, 140, 160, 180),
              (0, 1, 2, 3, 4, 5, 10, 15, 10, 5))
tram_2 = Tram(1, (5, 15, 25, 35, 45, 55, 65, 70, 80, 90), (4, 5, 6, 7, 8, 9))
tram_3 = Tram(1, (5, 15, 25, 35, 60, 70, 80, 90, 100, 110),
              (11, 12, 13, 14, 15, 16))
tram_4 = Tram(1, (5, 15, 25, 35, 55, 77, 88, 91, 94, 101),
              (21, 22, 23, 47, 63, 83))
tram_5 = Tram(1, (5, 15, 25, 35, 45, 55, 65, 75, 85, 95),
              (60, 61, 41, 42, 22, 21))
tram_6 = Tram(1, (5, 15, 25, 35, 40, 45, 50, 60, 65, 70),
              (33, 34, 54, 55, 54, 44, 43, 33))
tram_7 = Tram(1, (5, 15, 25, 35, 45, 50, 60, 70, 80, 90),
              (81, 82, 62, 41, 20, 0))
tram_8 = Tram(1, (5, 15, 25, 35, 45, 50, 55, 60, 65, 70, 75),
              (55, 56, 57, 58, 59, 60))
tram_9 = Tram(1, (5, 15, 25, 35, 50, 80, 100, 110, 120, 130),
              (72, 71, 70, 49, 28, 9))
Example #19
0
from timetable import Timetable
from building import *
import os

if __name__ == "__main__":
    files = [
        "Room List.xlsx", "Roomequip.xlsx", "Timetable2018-19.xlsx",
        "buildings.csv"
    ]
    paths = [os.path.join("Data", x) for x in files]
    buildings = load_buildings(paths[3])
    _rooms = load_rooms(paths[0], paths[1], buildings)
    timetable = Timetable(paths[2])
    rooms = set()
    for row in timetable.timetable.iter_rows(min_row=2, values_only=True):
        if row[8]:
            rooms.update(row[8].split(','))

    with open('capacitymissing.txt', 'w') as f:
        for room in rooms:
            if room not in _room:
                f.write(str(room) + '\n')
Example #20
0
def timetable_for_uid(uid):
    timetable = Timetable.get(db.session, uid)
    dump = json.dumps(timetable.json()) if timetable else ""
    return render_page("timetable.html", timetable=dump)
Example #21
0
from movie import Movie
from movie_house import MovieHouse
from timetable import Timetable
from tools.yaml_loader import load_yaml

# movie_hall_schema = load_yaml('../data/cronverk.yml')
movie_house = MovieHouse.create_movie_house(load_yaml, '../data/cronverk.yml')
movies_db = Movie.create_movies_db(load_yaml, '../data/movies.yml')
timetable = Timetable.create_movies_timetable(movies_db, movie_house)
for item in timetable:
    movie_duration = item.movie.duration.seconds
    minutes, hours = movie_duration // 60 % 60, movie_duration // 3600
    print(f"{item.movie.movie_title} - {item.movie_hall.number}, start: "
          f"{item.start_time.strftime('%d.%m.%Y, %H:%M:%S')}, "
          f"{hours}:{minutes}")
print()
Example #22
0
def timetable_list():
    status = request.args.get("status")
    resolvedStatus = status.upper() if status and status.upper() != "ALL" else None
    timetables = Timetable.list(db.session, resolvedStatus)
    return success({"data": [x.json() for x in timetables]})
Example #23
0
tutors = args.tutors

eval_func_str = args.optimize

log.debug('config: %d. Test (in lab rooms) starts at %s.' % (args.test, start.strftime('%H:%M')))
log.debug('config: %d groups of students, %d rooms for computertest.' % (args.groups, len(rooms)))
log.debug('config: evaluation function of genetic optimization = %s' % (eval_func_str))


#
# Genetic algorithm
#

# Collects data about timetable.
t = Timetable(start, args.test, rooms, tutors, args.groups)

# Initialize evaluation functions if necessary.
if eval_func_str == 'fuzzy':
   evaluation.fuzzy_init(t)

##
# Apply genome (map tutor to slot).
##
def apply_genome(genome):
   # check if genome has equal size as total number of slots
   if len(genome) != len(t._slots):
      msg = 'Wrong length of genome (%d), must match total number of slots (%d).' % (len(genome), len(slots))
      raise RuntimeError(msg)
   # put tutors into slots
   for s in range(len(t._slots)):
def timetable():
    u = User()
    for course in list_of_courses:
        if course + ".json" in os.listdir(
                "/Users/chris/PycharmProjects/Timetable-Generator/another_one"
        ):
            u.add_course(course)
    # global courses_color
    global courses_color
    courses_color = assign_color_to_courses()
    u.set_first_semester_filter(
        (fall_start_time) * 3600, (fall_end_time) * 3600, days_excluded_fall,
        fall_lunch_start_time, fall_lunch_end_time, first_semester_max_courses,
        first_semester_tutorials_practicals)
    u.set_second_semester_filter(
        (winter_start_time) * 3600, (winter_end_time) * 3600,
        days_excluded_winter, winter_lunch_start_time, winter_lunch_end_time,
        second_semester_max_courses, second_semester_tutorials_practicals)
    possible_timetables = u.get_valid_combinations()
    cm = CourseManager()
    fst = Timetable()
    # print(str(len(possible_timetables[0])) + " timetables generated")
    if len(possible_timetables[0]) != 0:
        fs = random.randint(
            0, (len(possible_timetables[0]) -
                1))  # Can get a -1 error for no possible timetables
    else:
        fs = -1
    if len(possible_timetables[1]) != 0:
        ss = random.randint(0, (len(possible_timetables[1]) - 1))
    else:
        ss = -1
    # print(str(a) + " is the timetable picked")
    if fs != -1:
        fst.add_course(cm._break_down_nested_list(possible_timetables[0][fs]),
                       u.get_first_semester_filter())
    if ss != -1:
        fst.add_course(cm._break_down_nested_list(possible_timetables[1][ss]),
                       u.get_second_semester_filter())
    columns = ['MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY']
    index = [
        '8:00am', '8:30am', '9:00am', '9:30am', '10:00am', '10:30am',
        '11:00am', '11:30am', '12:00pm', '12:30pm', '1:00pm', '1:30pm',
        '2:00pm', '2:30pm', '3:00pm', '3:30pm', '4:00pm', '4:30pm', '5:00pm',
        '5:30pm', '6:00pm', '6:30pm', '7:00pm', '7:30pm', '8:00pm', '8:30pm',
        '9:00pm', '9:30pm'
    ]
    # print(t.get_first_semester_table())
    data_first_semester = fst.get_first_semester_table()
    data_second_semester = fst.get_second_semester_table()
    for i in range(len(data_first_semester)):
        for h in range(len(data_first_semester[i])):
            if data_first_semester[i][h] is None:
                data_first_semester[i][h] = ''
            else:
                data_first_semester[i][h] = str(
                    data_first_semester[i][h].get_code() + " " +
                    data_first_semester[i][h].get_meeting_section_codes())
    for i in range(len(data_second_semester)):
        for h in range(len(data_second_semester[i])):
            if data_second_semester[i][h] is None:
                data_second_semester[i][h] = ''
            else:
                data_second_semester[i][h] = str(
                    data_second_semester[i][h].get_code() + " " +
                    data_second_semester[i][h].get_meeting_section_codes())
    df1 = pd.DataFrame(data_first_semester, columns=columns, index=index)
    th_props = [('text-align', 'center'), ('color', '#6d6d6d'),
                ('background-color', '#f7f7f9')]
    td_props = [('font-size', '20px')]
    styles = [
        dict(selector="tr", props=th_props),
        dict(selector="td", props=td_props)
    ]
    # df1.style.applymap(highlight_courses)
    test = dict(selector="th", props=[('text-align', 'center')])
    df1.style.set_table_styles([test])
    df1.style.set_table_styles(styles).render()
    df2 = pd.DataFrame(data_second_semester, columns=columns, index=index)
    df2.style.set_table_styles([test])
    df2.style.set_table_styles(styles).render()
    # print(df2.style.render())
    # print(df1.style.render())
    for day, content in df1.iteritems():
        for item in content:
            if item != '':
                if item not in temp_dict[day]:
                    temp_dict[day][0][item] = False
    # print(temp_dict)
    # print(type(df1.iteritems()))
    # df1.to_html(border=0, escape=False)
    # print(courses_color)
    return render_template(
        "timetable.html",
        data_frame=df1.style.applymap(highlight_courses_background,
                                      subset=columns).render(),
        data_frame2=df2.style.applymap(highlight_courses_background,
                                       subset=columns).render())
    csvFile.close()

    with open('/home/kumbong/Desktop/Software Engineering/hex-backend/objects/rooms.csv', 'r') as csvFile:
        reader = csv.DictReader(csvFile, dialect='myDialect')
        for row in reader:
            r = (dict(row))
            room = Classroom(r['Name'].strip(),int(r['Capacity'].strip()),r['Building'].strip(),r['Allowance'].strip())
            rooms.append(room)
    csvFile.close()

    days = ['Monday','Tuesday','Wednesday','Thursday','Friday']
    day_tables = []

    for day in days:
        day_tables.append(DayTimetable(rooms,timeslots,day))
    timetable = Timetable(days,day_tables)


    generator = TimeTableGenerator(timetable,lectures)

  
    # #print(generator.unscheduled)
    import time
    start_time = time.time()

    generator.generate_timetable()
    
    print(generator.timetable)
    print(len(generator.scheduled))
    print(len(generator.unscheduled))
    #print(generator.scheduled)
Example #26
0
import datetime
import re

from bs4 import BeautifulSoup

from auth3 import Auth
from holiday import Holiday
from timetable import Timetable

timetable = Timetable()
holiday = Holiday()


def course_handler(cookies, xnxqid, start_date, output_dir='.'):
    auth = Auth(cookies)

    if not auth.ok:
        raise Exception('登录失败,请检查用户名密码')

    url = 'https://jwxt.sztu.edu.cn/jsxsd/xskb/xskb_list.do?xnxq01id=' + xnxqid
    start_date = start_date.split('-')
    r = auth.get(url)

    soup = BeautifulSoup(r.text, features='html.parser')

    tab = soup.findAll('table')[0]

    i = 0

    schedules = []
	def get(self):
		tables = Timetable.query().fetch()
		for table in tables:
			table.isweeka = not table.isweeka
			table.put()