Convert range to the "ed" format
(start, stop)
| 1083 | ######################################################################## |
| 1084 | |
| 1085 | def _format_range_unified(start, stop): |
| 1086 | 'Convert range to the "ed" format' |
| 1087 | # Per the diff spec at http://www.unix.org/single_unix_specification/ |
| 1088 | beginning = start + 1 # lines start numbering with one |
| 1089 | length = stop - start |
| 1090 | if length == 1: |
| 1091 | return '{}'.format(beginning) |
| 1092 | if not length: |
| 1093 | beginning -= 1 # empty ranges begin at line just before the range |
| 1094 | return '{},{}'.format(beginning, length) |
| 1095 | |
| 1096 | def unified_diff(a, b, fromfile='', tofile='', fromfiledate='', |
| 1097 | tofiledate='', n=3, lineterm='\n'): |