102 if report_it: |
102 if report_it: |
103 self.writeout(self.fmt_err % (fr.relative_filename(), typ.__name__, msg)) |
103 self.writeout(self.fmt_err % (fr.relative_filename(), typ.__name__, msg)) |
104 |
104 |
105 # Sort the lines and write them out. |
105 # Sort the lines and write them out. |
106 if getattr(self.config, 'sort', None): |
106 if getattr(self.config, 'sort', None): |
107 position = column_order.get(self.config.sort.lower()) |
107 sort_option = self.config.sort.lower() |
|
108 reverse = False |
|
109 if sort_option[0] == '-': |
|
110 reverse = True |
|
111 sort_option = sort_option[1:] |
|
112 elif sort_option[0] == '+': |
|
113 sort_option = sort_option[1:] |
|
114 |
|
115 position = column_order.get(sort_option) |
108 if position is None: |
116 if position is None: |
109 raise CoverageException("Invalid sorting option: {!r}".format(self.config.sort)) |
117 raise CoverageException("Invalid sorting option: {!r}".format(self.config.sort)) |
110 lines.sort(key=lambda l: (l[1][position], l[0])) |
118 lines.sort(key=lambda l: (l[1][position], l[0]), reverse=reverse) |
111 |
119 |
112 for line in lines: |
120 for line in lines: |
113 self.writeout(line[0]) |
121 self.writeout(line[0]) |
114 |
122 |
115 # Write a TOTAl line if we had more than one file. |
123 # Write a TOTAl line if we had more than one file. |