scheduler.html


001| """Scheduler. (Dedicated to my ex-wife the Registrar.)"""
002| ####################################################################################################
003| from sys import stdout, argv, exc_info
004| from traceback import extract_tb
005| from os import path, environ
006| from datetime import datetime
007| from time import time
008| ####################################################################################################
009| BasePath = r'C:\CJS\prj\Python\ws\@sandbox'
010| print()
011| 
012| 
013| class Building (dict):
014|     def __init__ (self, bldg_id, bldg_name, **kwargs):
015|         super().__init__()
016|         self['bldg_id'] = bldg_id
017|         self['bldg_name'] = bldg_name
018|         self['location'] = kwargs['location'] if 'location' in kwargs else ''
019|         self['time_open'] = kwargs['time_open'] if 'time_open' in kwargs else '6:30'
020|         self['time_close'] = kwargs['time_close'] if 'time_close' in kwargs else '19:30'
021|     def __str__ (self):
022|         return ('%s (%s)' % (self['bldg_name'], self['bldg_id']))
023| 
024| class Room (dict):
025|     def __init__ (self, room_id, bldg_id, **kwargs):
026|         super().__init__()
027|         self['room_id'] = room_id
028|         self['bldg_id'] = bldg_id
029|         self['size'] = kwargs['size'] if 'size' in kwargs else 0
030|         self['mode'] = kwargs['mode'] if 'mode' in kwargs else 'standard'
031|         self['open'] = kwargs['open'] if 'open' in kwargs else 'yes'
032|         self['lock'] = kwargs['lock'] if 'lock' in kwargs else 'yes'
033|         self['props'] = kwargs['props'] if 'props' in kwargs else {}
034|     def __str__ (self):
035|         return ('%s Room %s' % (self['bldg_id'], self['room_id']))
036| 
037| class Course (dict):
038|     def __init__ (self, course_id, course_name, **kwargs):
039|         super().__init__()
040|         self['course_id'] = course_id
041|         self['course_name'] = course_name
042|         self['days_per_week'] = kwargs['days_per_week'] if 'days_per_week' in kwargs else 3
043|         self['mins_per_session'] = kwargs['mins_per_session'] if 'mins_per_session' in kwargs else 60
044|         self['min_size'] = kwargs['min_size'] if 'min_size' in kwargs else 1
045|         self['max_size'] = kwargs['max_size'] if 'max_size' in kwargs else 100
046|     def __str__ (self):
047|         return ('%-8s "%s"' % (self['course_id'], self['course_name']))
048| 
049| class Teacher (dict):
050|     def __init__ (self, teacher_id, firstname, lastname, **kwargs):
051|         super().__init__()
052|         self['teacher_id'] = teacher_id
053|         self['title'] = kwargs['title'] if 'title' in kwargs else ''
054|         self['prefix'] = kwargs['prefix'] if 'prefix' in kwargs else ''
055|         self['firstname'] = firstname
056|         self['midname'] = kwargs['midname'] if 'midname' in kwargs else ''
057|         self['lastname'] = lastname
058|         self['suffix'] = kwargs['suffix'] if 'suffix' in kwargs else ''
059|         self['nickname'] = kwargs['nickname'] if 'nickname' in kwargs else ''
060|         self['phone'] = kwargs['phone'] if 'phone' in kwargs else ''
061|         self['email'] = kwargs['email'] if 'email' in kwargs else ''
062|         self['days_per_week'] = kwargs['days_per_week'] if 'days_per_week' in kwargs else 4
063|     def __str__ (self):
064|         s1 = ('%s ' % self['title']) if self['title'] else ''
065|         s2 = ('%s ' % self['prefix']) if self['prefix'] else ''
066|         s3 = ('%s ' % self['suffix']) if self['suffix'] else ''
067|         return ('%s%s%s %s%s' % (s1,s2, self['firstname'],self['lastname'], s3))
068| 
069| class Session (dict):
070|     def __init__ (self, date_id, room_id, course_id, teacher_id):
071|         super().__init__()
072|         self['date_id'] = date_id
073|         self['room_id'] = room_id
074|         self['course_id'] = course_id
075|         self['teacher_id'] = teacher_id
076|     def __str__ (self):
077|         return ('%s %s %s' % (self['date_id'],self['room_id'],self['course_id']))
078| 
079| 
080| ListOfBuildings = [
081|     Building('00', 'Campus'),
082|     Building('AH', 'Albert Hall'),
083|     Building('BH', 'Bentley Hall'),
084|     Building('CH', 'Carson Hall'),
085| ]
086| for building in ListOfBuildings:
087|     print(building)
088| print()
089| 
090| ListOfRooms = [
091|     Room('101', 'BH', size=12, lock='no'),
092|     Room('102', 'BH', size=12, lock='no'),
093|     Room('103', 'BH', size=12, lock='no'),
094|     Room('104', 'BH', size=20, lock='no'),
095|     Room('105', 'BH', size=20, lock='no'),
096|     Room('106', 'BH', size=20, lock='no'),
097|     Room('201', 'BH', size=12),
098|     Room('202', 'BH', size=12),
099|     Room('203', 'BH', size=12),
100|     Room('204', 'BH', size=20),
101|     Room('205', 'BH', size=20),
102|     Room('206', 'BH', size=20),
103| ]
104| for room in ListOfRooms:
105|     print(room)
106| print()
107| 
108| ListOfCourses = [
109|     Course('NB 101', 'Intro to Surfing, A'),
110|     Course('NB 102', 'Intro to Surfing, B'),
111|     Course('NB 202', 'Advanced Surfing'),
112|     Course('NB 301', 'Way Advanced Surfing'),
113|     Course('NB 302', 'Nuances of Gnarliness'),
114|     Course('CK 101', 'Basic Muffins'),
115|     Course('CK 102', 'Special Muffins'),
116|     Course('CK 103', 'Exotic Muffins'),
117|     Course('CK 200', 'Bagels and Donuts'),
118| ]
119| for course in ListOfCourses:
120|     print(course)
121| print()
122| 
123| ListOfTeachers = [
124|     Teacher(55102, 'Fred', 'Flintstone', phone='555-3228', email='fflintman@bedrock.com'),
125|     Teacher(55115, 'Barney', 'Rubble'),
126|     Teacher(55338, 'Linda', 'Carter'),
127| ]
128| for teacher in ListOfTeachers:
129|     print(teacher)
130| print()
131| 
132| 
133| 
134| 
135| 
136| 
137| print()
138| ####################################################################################################
139| '''eof'''
140|