def load(self, file, info = False): ''' Loads employee data @param file: a file pointer open in "rb" mode @params info: T/F whether to print additional info while loading. @return True if load was successful, False if any error occured ''' try: self.name = pickle.load(file) print(" Loading data for %s..."%self.name) self.priority = pickle.load(file) if info: print(" Read priority: %d"%self.priority) self.curShifts = pickle.load(file) if info: print(" Read number of shifts: %d"%self.curShifts) self.shiftsPerWeek = pickle.load(file) if info: print(" Read shifts per week: %s"%self.shiftsPerWeek) numRules = pickle.load(file) if info: print(" Read number of rules: %d"%numRules) print(" %d rules to load"%numRules) self.rules = [] num = 0 for i in range(0,numRules): r = Rule() if not r.load(file, num, info): print("\nError (%s): Loaded invalid rule, aborting..."%self.name) return False self.setRule(r) num += 1 except Exception as e: print("\nError: %s while loading %s"%(str(e), self.name)) return False if info: print(" Finished loading data for %s"%self.name) return True