def initUI( self ): """ in: nothing returns nothing """ # superclass openwindow ListWindow.initUI( self ) # add stepperlist self.theClassList = ClassList( self, self['ClassListFrame'] ) # add stepperpropertylist self.theClassPropertyList = ClassEditor( self, self['ClassPropertyFrame'] ) # add signal handlers # self.addHandlers({ }) self.theClassList.update() classList = self.theModelEditor.getModel().getStepperList() if len(classList) == 0: aClassList = [] else: aClassList = [ classList[0] ] self.selectStepper( aClassList )
import re import copy from Class import Class from ClassList import ClassList from Session import Session from EquivalenceClassList import EquivalenceClassList import csv pattern1_str = "\s*(?P<crn>\d{5})\s+(?P<dept>[A-Z]{4})\s+(?P<course_number>\d{4}[A-Z]*)\s+(?P<section>\d+[A-Z]*)" pattern1 = re.compile(pattern1_str) pattern2_str = "\s+(?P<start_date>\d{2}\-[A-Z]{3})-\d{4}\s+(?P<end_date>\d{2}-[A-Z]{3}-\d{4})\s+(?P<days>[MTWRF]+)\s+(?P<start_time>\d{2}:\d{2}[ap]m)-(?P<end_time>\d{2}:\d{2}[ap]m)\D+\d{4}[A-z]*" pattern2 = re.compile(pattern2_str) class_list = ClassList() current_class = None #with open('banner_course_schedule.py') as f: with open('html_classes_content2.txt') as f: for line in f: results1 = pattern1.match(line) results2 = pattern2.match(line) if results1 != None: if current_class != None: class_list.add_class(current_class) current_crn = results1.group('crn') current_dept = results1.group('dept')
class ClassEditorWindow(ListWindow): def __init__( self, aModelEditor, aRoot = 'top_frame' ): """ in: ModelEditor theModelEditor returns nothing """ ListWindow.__init__( self, aModelEditor ) self.initUI() def initUI( self ): """ in: nothing returns nothing """ # superclass openwindow ListWindow.initUI( self ) # add stepperlist self.theClassList = ClassList( self, self['ClassListFrame'] ) # add stepperpropertylist self.theClassPropertyList = ClassEditor( self, self['ClassPropertyFrame'] ) # add signal handlers # self.addHandlers({ }) self.theClassList.update() classList = self.theModelEditor.getModel().getStepperList() if len(classList) == 0: aClassList = [] else: aClassList = [ classList[0] ] self.selectStepper( aClassList ) def updateEntityList ( self ): if not self.exists(): return self.theClassList.update( ) self.updatePropertyList( ) def updatePropertyList ( self, anID = None ): """ in: anID ( system or stepper ) where changes happened """ if not self.exists(): return oldDisplayedID = self.theClassPropertyList.getDisplayedStepper() selectedIDs = self.theClassList.getSelectedIDs() if len( selectedIDs) != 1: newDisplayedID = None else: newDisplayedID = selectedIDs[0] if oldDisplayedID != newDisplayedID or newDisplayedID == anID or anID == None: self.theClassPropertyList.setDisplayedStepper( newDisplayedID ) def setLastActiveComponent( self, aComponent ): pass def update( self, aType = None, anID = None ): # anID None means all for steppers if aType == DM_STEPPER_TYPE: if anID == None: # update all self.updateEntityList() else: self.updatePropertyList( anID ) elif aType in [ DM_SYSTEM_TYPE, DM_PROCESS_TYPE, None]: self.updatePropertyList() elif aType == DM_PROPERTY_TYPE: self.updatePropertyList( anID ) def selectStepper( self, aStepperList ): self.theClassList.changeSelection( aStepperList ) self.theClassList.selectByUser() ############################# # SIGNAL HANDLERS # ############################# def deleted( self, *args ): ListWindow.deleted( self, *args ) self.theClassList.close() self.theClassPropertyList.close() self.theModelEditor.theClassEditor = None self.theModelEditor.theMainWindow.update() return True
from Class import Class from ClassList import ClassList from Session import Session from EquivalenceClassList import EquivalenceClassList #Patterns to match using regex. These patterns are likely to be school specific. Dalton # State College uses banner. pattern1_str = "(?P<crn>\d{5})\s+(?P<dept>[A-Z]{4})\s+(?P<course_number>\d{4}[A-Z]*)\s+(?P<section>\d+[A-Z]*)" pattern1 = re.compile(pattern1_str) #More patterns to match using regex. These look for the start and end dates/times # that appear for the classes. pattern2_str = "\s+(?P<start_date>\d{2}\-[A-Z]{3})-\d{4}\s+(?P<end_date>\d{2}-[A-Z]{3}-\d{4})\s+(?P<days>[MTWRF]+)\s+(?P<start_time>\d{2}:\d{2}[ap]m)-(?P<end_time>\d{2}:\d{2}[ap]m)\D+\d{4}[A-z]*" pattern2 = re.compile(pattern2_str) class_list = ClassList() current_class = None #banner_course_schedule is where you would copy past all of the code for the # courses so that this program can peek inside and grab the patterns that # represent the classes. Be sure to copy paste all classes you want to # build a final exam schedule into one file. with open('banner_course_schedule.py') as f: for line in f: #Grab the lines that match the pattern. They patterns come in pairs. results1 = pattern1.match(line) results2 = pattern2.match(line) #If results1 has something, continue.