anchors[line[1:]] = idx
if not expand_parsed(_TOK_REPEAT, repeat, anchors=anchors):
break
- self._lines = [ln for ln in self._lines if ln[:1] != _CHAR_ANCHOR]
+ self._lines = [ln for ln in self._lines
+ if ln and ln[:1] not in {_CHAR_ANCHOR, _CHAR_COMMENT}]
self._idx = 0
@property
def ensure_has_started(self) -> None:
'Check if still at beginning, and if so, play till at next log line.'
if self._idx == 0:
- self._play_till_next_log()
+ self._play_till_log()
def next_log(self) -> tuple[int, tuple[int, ...], str]:
'Return index, win IDs, and context of next expected log line.'
expected_win_ids = tuple(
int(idx) for idx in context.split(_CHAR_WIN_ID_SEP) if idx)
used_idx = self._idx
- self._play_till_next_log()
+ self._idx += 1
+ self._play_till_log()
return used_idx, expected_win_ids, msg
- def _play_till_next_log(self) -> None:
+ def _play_till_log(self) -> None:
while True:
- self._idx += 1
if (result := self._split_active_line(self._current_line)):
context, msg = result
if context == _CHAR_PROMPT:
client.conn.put_server_msg(msg)
else:
break
+ self._idx += 1
@staticmethod
def _split_active_line(line: str) -> Optional[tuple[str, ...]]:
'Return 2-items tuple of split line, or None if empty/comment/anchor.'
- if line[:1] == _CHAR_COMMENT or _CHAR_CONTEXT_SEP not in line:
+ if _CHAR_CONTEXT_SEP not in line:
return None
return tuple(line.split(_CHAR_CONTEXT_SEP, maxsplit=1))