"""Represents lines of individual booking."""
# pylint: disable=too-few-public-methods
- def __init__(self, id_: int, idx_start_end: tuple[int, int]) -> None:
+ def __init__(self, id_: int, idx_start: int, b_lines: list[str]) -> None:
self.id_ = id_
- self.idx_start, self.idx_end = idx_start_end
+ self.idx_start = idx_start
+ self.b_lines = b_lines
+ self.idx_end = self.idx_start + len(self.b_lines)
class Handler(PlomHttpHandler):
for line in path_dat.read_text(encoding='utf8').splitlines()]
self.bookings: list[Booking] = []
code_lines = [dl.code for dl in self.dat_lines]
- in_booking = False
last_booking_start = -1
+ b_lines: list[str] = []
for idx, code in enumerate(code_lines + ['']):
- if in_booking and not code:
- in_booking = False
+ if code:
+ if not b_lines:
+ last_booking_start = idx
+ b_lines += [code]
+ elif b_lines:
self.bookings += [Booking(len(self.bookings),
- (last_booking_start, idx))]
+ last_booking_start, b_lines)]
+ b_lines.clear()
self.dat_lines[last_booking_start].booking = self.bookings[-1]
- elif code and not in_booking:
- in_booking = True
- last_booking_start = idx
@property
def dat_lines_sans_empty(self) -> list[DatLine]: