def __init__(self, booking: 'Booking', code: str) -> None:
super().__init__(booking)
- self.date = '#'
- self.target = ''
if code[0].isspace():
self.errors += ['intro line indented']
toks = code.lstrip().split(maxsplit=1)
- if len(toks) != 2:
+ self.date = toks[0]
+ self.target = toks[1] if len(toks) > 1 else ''
+ if len(toks) == 1:
self.errors += ['illegal number of tokens']
- elif len(toks) < 1:
- return
- else:
- self.target = toks[1]
try:
- dt_date.fromisoformat(toks[0])
+ dt_date.fromisoformat(self.date)
except ValueError:
- self.errors += [f'not properly formatted legal date: {toks[0]}']
- else:
- self.date = toks[0]
+ self.errors += [f'not properly formatted legal date: {self.date}']
@property
def as_dict(self) -> dict: