- ret = parse_lines(f.readlines())
- self.bookings += ret[0]
- self.comments += ret[1]
+ self.real_lines += f.readlines()
+ ret = parse_lines(self.real_lines)
+ self.bookings += ret[0]
+ self.comments += ret[1]
+
+ def replace(self, start, end, lines):
+ import shutil
+ if os.path.exists(self.lock_file):
+ raise HandledException('Sorry, lock file!')
+ if os.path.exists(self.db_file):
+ shutil.copy(self.db_file, self.db_file + ".bak")
+ f = open(self.lock_file, 'w+')
+ f.close()
+ text = ''.join(self.real_lines[:start]) + '\n'.join(lines) + ''.join(self.real_lines[end:])
+ with open(self.db_file, 'w') as f:
+ f.write(text);
+ os.remove(self.lock_file)