Return a short excerpt of text[start:end], from the tail or head.
(text: str, start: int, end: int, tail: bool = False, maxlen: int = 60)
| 164 | |
| 165 | |
| 166 | def snippet(text: str, start: int, end: int, tail: bool = False, maxlen: int = 60) -> str: |
| 167 | """Return a short excerpt of text[start:end], from the tail or head.""" |
| 168 | s = text[start:end].strip() |
| 169 | if tail: |
| 170 | return ("..." + s[-maxlen:]) if len(s) > maxlen else ("..." + s) |
| 171 | return (s[:maxlen] + "...") if len(s) > maxlen else (s + "...") |
| 172 | |
| 173 | |
| 174 | def show_gaps(boltpath: str, bolt_num: int, si: int, |