| 865 | _NO_LINENO = ' --' |
| 866 | |
| 867 | def _get_lineno_width(linestarts): |
| 868 | if linestarts is None: |
| 869 | return 0 |
| 870 | maxlineno = max(filter(None, linestarts.values()), default=-1) |
| 871 | if maxlineno == -1: |
| 872 | # Omit the line number column entirely if we have no line number info |
| 873 | return 0 |
| 874 | lineno_width = max(3, len(str(maxlineno))) |
| 875 | if lineno_width < len(_NO_LINENO) and None in linestarts.values(): |
| 876 | lineno_width = len(_NO_LINENO) |
| 877 | return lineno_width |
| 878 | |
| 879 | def _get_positions_width(code): |
| 880 | # Positions are formatted as 'LINE:COL-ENDLINE:ENDCOL ' (note trailing space). |