+ def insert_at_date(self, lines, date):
+ start_at = len(self.real_lines)
+ for b in self.bookings:
+ if b.date_string == date:
+ start_at = b.start_line
+ break
+ elif b.date_string > date:
+ break
+ if start_at == len(self.real_lines):
+ lines = [''] + lines
+ return self.write_lines_in_total_lines_at(self.real_lines, start_at, lines)
+
+ def update(self, start, end, lines, date):
+ total_lines = self.real_lines[:start] + self.real_lines[end:]
+ n_original_lines = end - start
+ start_at = len(total_lines)
+ for b in self.bookings:
+ if b.date_string == date:
+ if start_at == len(total_lines) or b.start_line == start:
+ start_at = b.start_line
+ if b.start_line > start:
+ start_at -= n_original_lines
+ elif b.date_string > date:
+ break
+ if start_at == len(total_lines):
+ lines = [''] + lines
+ return self.write_lines_in_total_lines_at(total_lines, start_at, lines)
+
+ def write_lines_in_total_lines_at(self, total_lines, start_at, lines):
+ total_lines = total_lines[:start_at] + lines + [''] + total_lines[start_at:]
+ _, _ = parse_lines(lines)