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