This method will erase the previously printed text on screen by going up as many new lines as the old text had and overwriting it with whitespace. Afterwards, the new text will be printed.
(self, data)
| 207 | sys.stderr.write(self.last_clean_text) |
| 208 | |
| 209 | def write(self, data): |
| 210 | """This method will erase the previously printed text on screen by going |
| 211 | up as many new lines as the old text had and overwriting it with whitespace. |
| 212 | Afterwards, the new text will be printed.""" |
| 213 | self._clean_before() |
| 214 | new_line_count = data.count("\n") |
| 215 | sys.stderr.write(self.UP * min(new_line_count, self.last_line_count)) |
| 216 | sys.stderr.write(data) |
| 217 | |
| 218 | # Cache the line count and the old text where all text was replaced by |
| 219 | # whitespace. |
| 220 | self.last_line_count = new_line_count |
| 221 | self.last_clean_text = re.sub(r"[^\s]", " ", data) |
| 222 | |
| 223 | def clear(self): |
| 224 | sys.stderr.write(self.UP * self.last_line_count) |
nothing calls this directly
no test coverage detected