def remove_program(self, index): if 0 <= index < len(self._programs): del self._programs[index] for i in range(index, len(self._programs)): options.save(self._programs[i], i) # Save programs using new indices options.erase(_Program, len(self._programs)) # Remove info in last index
def __setattr__(self, key, value): try: super(_Station, self).__setattr__(key, value) if not key.startswith('_') and key not in self.SAVE_EXCLUDE: options.save(self, self.index) except ValueError: # No index available yet pass if key == 'usage' and value > options.max_usage: logging.warning('The usage of %s is more than the maximum allowed usage, ' 'scheduling it will be impossible.', self.name)
def __setattr__(self, key, value): if key == 'modulo': self._modulo = value if not self._loading: self.schedule = self._schedule # Convert to custom sequence elif key == 'manual': self._manual = value if not self._loading and value: self.schedule = self._schedule # Convert to custom sequence elif key == 'start': if self._loading: # Update start date to most recent possible while value <= datetime.datetime.today(): value += datetime.timedelta(minutes=self._modulo) self._start = value else: self._start = value self.schedule = self._schedule # Convert to custom sequence else: super(_Program, self).__setattr__(key, value) if key not in self.SAVE_EXCLUDE: if not self._loading and self.index >= 0: options.save(self, self.index)
def __setattr__(self, key, value): super(_BaseStations, self).__setattr__(key, value) if not key.startswith('_') and not self._loading: options.save(self)
def add_program(self, program=None): if program is None: program = _Program(self, len(self._programs)) self._programs.append(program) options.save(program, program.index)