Convert range to the "ed" format
(start, stop)
| 1166 | ######################################################################## |
| 1167 | |
| 1168 | def _format_range_context(start, stop): |
| 1169 | 'Convert range to the "ed" format' |
| 1170 | # Per the diff spec at http://www.unix.org/single_unix_specification/ |
| 1171 | beginning = start + 1 # lines start numbering with one |
| 1172 | length = stop - start |
| 1173 | if not length: |
| 1174 | beginning -= 1 # empty ranges begin at line just before the range |
| 1175 | if length <= 1: |
| 1176 | return '{}'.format(beginning) |
| 1177 | return '{},{}'.format(beginning, beginning + length - 1) |
| 1178 | |
| 1179 | # See http://www.unix.org/single_unix_specification/ |
| 1180 | def context_diff(a, b, fromfile='', tofile='', |