Return new Source object with trailing and leading blank lines removed.
(self)
| 70 | return len(self.lines) |
| 71 | |
| 72 | def strip(self) -> "Source": |
| 73 | """Return new Source object with trailing and leading blank lines removed.""" |
| 74 | start, end = 0, len(self) |
| 75 | while start < end and not self.lines[start].strip(): |
| 76 | start += 1 |
| 77 | while end > start and not self.lines[end - 1].strip(): |
| 78 | end -= 1 |
| 79 | source = Source() |
| 80 | source.lines[:] = self.lines[start:end] |
| 81 | return source |
| 82 | |
| 83 | def indent(self, indent: str = " " * 4) -> "Source": |
| 84 | """Return a copy of the source object with all lines indented by the |