eric6/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleStatisticsDialog.py

changeset 7613
382f89c11e27
parent 7611
d546c4e72f52
child 7615
ca2949b1a29a
equal deleted inserted replaced
7612:ca1ce1e0fcff 7613:382f89c11e27
6 """ 6 """
7 Module implementing a dialog showing statistical data for the last code 7 Module implementing a dialog showing statistical data for the last code
8 style checker run. 8 style checker run.
9 """ 9 """
10 10
11 import textwrap
11 12
12 from PyQt5.QtCore import Qt 13 from PyQt5.QtCore import Qt
13 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem 14 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem
14 15
15 from .translations import _messages, _messages_sample_args 16 from .translations import getTranslatedMessage
16 from .Security import translations as s_translations
17 17
18 from .Ui_CodeStyleStatisticsDialog import Ui_CodeStyleStatisticsDialog 18 from .Ui_CodeStyleStatisticsDialog import Ui_CodeStyleStatisticsDialog
19 19
20 import UI.PixmapCache 20 import UI.PixmapCache
21 21
45 del stats["_IssuesFixed"] 45 del stats["_IssuesFixed"]
46 del stats["_IgnoredErrors"] 46 del stats["_IgnoredErrors"]
47 47
48 totalIssues = 0 48 totalIssues = 0
49 49
50 textWrapper = textwrap.TextWrapper(width=80)
51
50 for code in sorted(stats.keys()): 52 for code in sorted(stats.keys()):
51 message = _messages.get(code) or s_translations._messages.get(code) 53 message = getTranslatedMessage(code, [], example=True)
52 if message is None: 54 if message is None:
53 continue 55 continue
54 56
55 if code in _messages_sample_args: 57 self.__createItem(stats[code], code,
56 message = message.format(*_messages_sample_args[code]) 58 "\n".join(textWrapper.wrap(message)))
57 elif code in s_translations._messages_sample_args:
58 message = message.format(
59 *s_translations._messages_sample_args[code])
60
61 self.__createItem(stats[code], code, message)
62 totalIssues += stats[code] 59 totalIssues += stats[code]
63 60
64 self.totalIssues.setText( 61 self.totalIssues.setText(
65 self.tr("%n issue(s) found", "", totalIssues)) 62 self.tr("%n issue(s) found", "", totalIssues))
66 self.ignoredIssues.setText( 63 self.ignoredIssues.setText(
81 78
82 @param count occurrences of the issue (integer) 79 @param count occurrences of the issue (integer)
83 @param code of a code style issue message (string) 80 @param code of a code style issue message (string)
84 @param message code style issue message to be shown (string) 81 @param message code style issue message to be shown (string)
85 """ 82 """
86 itm = QTreeWidgetItem(self.statisticsList) 83 itm = QTreeWidgetItem(self.statisticsList, [
87 itm.setData(0, Qt.DisplayRole, count) 84 "{0:6d}".format(count), code, message])
88 itm.setData(1, Qt.DisplayRole, code)
89 itm.setData(2, Qt.DisplayRole, message)
90 if code.startswith(("W", "C", "M")): 85 if code.startswith(("W", "C", "M")):
91 itm.setIcon(1, UI.PixmapCache.getIcon("warning")) 86 itm.setIcon(1, UI.PixmapCache.getIcon("warning"))
92 elif code.startswith("E"): 87 elif code.startswith("E"):
93 itm.setIcon(1, UI.PixmapCache.getIcon("syntaxError")) 88 itm.setIcon(1, UI.PixmapCache.getIcon("syntaxError"))
94 elif code.startswith("N"): 89 elif code.startswith("N"):

eric ide

mercurial