Consume the current line if it starts with *prefix* and return the text **after** the prefix. Raises if prefix is empty.
(self, prefix: str)
| 112 | return self._norm(self._cur_line()).startswith(prefix) |
| 113 | |
| 114 | def read_str(self, prefix: str) -> str: |
| 115 | """ |
| 116 | Consume the current line if it starts with *prefix* and return the text |
| 117 | **after** the prefix. Raises if prefix is empty. |
| 118 | """ |
| 119 | if prefix == "": |
| 120 | raise ValueError("read_str() requires a non-empty prefix") |
| 121 | if self._norm(self._cur_line()).startswith(prefix): |
| 122 | text = self._cur_line()[len(prefix) :] |
| 123 | self.index += 1 |
| 124 | return text |
| 125 | return "" |
| 126 | |
| 127 | def read_line(self) -> str: |
| 128 | """Return the current raw line and advance.""" |
no test coverage detected