From: Christian Heller Date: Fri, 26 Sep 2025 12:31:12 +0000 (+0200) Subject: For testing, allow nesting of repeat ranges. X-Git-Url: https://plomlompom.com/repos/?a=commitdiff_plain;h=11fa5f9bbd768aea4bc62e1ddb3c1511af993d25;p=ircplom For testing, allow nesting of repeat ranges. --- diff --git a/src/ircplom/testing.py b/src/ircplom/testing.py index 23062e5..b97e09f 100644 --- a/src/ircplom/testing.py +++ b/src/ircplom/testing.py @@ -103,9 +103,28 @@ class TestingClientTui(ClientTui): with self._path_test.open('r', encoding='utf8') as f: self._playbook = tuple(line[:-1] for line in f.readlines()) self._playbook_anchors: dict[str, int] = {} - for idx, line in enumerate(self._playbook): - if line[:1] == '|': - self._playbook_anchors[line[1:]] = idx + 1 + while True: + self._playbook_anchors.clear() + for idx, line in enumerate(self._playbook): + if line[:1] == '|': + self._playbook_anchors[line[1:]] = idx + found_repeat = False + for idx, line in enumerate(self._playbook): + if line[:1] in '#|' or not line.strip(): + continue + context, msg = line.split(' ', maxsplit=1) + if context == 'repeat': + found_repeat = True + start_key, end_key = msg.split(' ') + start = self._playbook_anchors[start_key] + 1 + end = self._playbook_anchors[end_key] + self._playbook = (self._playbook[:idx] + + self._playbook[int(start):int(end)] + + self._playbook[idx + 1:]) + break + if found_repeat: + continue + break self._playbook_idx = -1 self._play_till_next_log() @@ -147,14 +166,6 @@ class TestingClientTui(ClientTui): if line[:1] in '#|' or not line.strip(): continue context, msg = line.split(' ', maxsplit=1) - if context == 'repeat': - start_key, end_key = msg.split(' ') - start = self._playbook_anchors[start_key] - end = self._playbook_anchors[end_key] - self._playbook = (self._playbook[:self._playbook_idx + 1] - + self._playbook[int(start):int(end)] - + self._playbook[self._playbook_idx + 1:]) - continue if context == '>': for c in msg: self._q_keypresses.put(c)