8 style checker run. |
8 style checker run. |
9 """ |
9 """ |
10 |
10 |
11 from __future__ import unicode_literals |
11 from __future__ import unicode_literals |
12 |
12 |
13 from PyQt4.QtCore import Qt, QCoreApplication |
13 from PyQt4.QtCore import Qt |
14 from PyQt4.QtGui import QDialog, QTreeWidgetItem |
14 from PyQt4.QtGui import QDialog, QTreeWidgetItem |
15 |
15 |
16 from . import pep8 |
16 from .translations import _messages, _messages_sample_args |
17 from .NamingStyleChecker import NamingStyleChecker |
|
18 from .DocStyleChecker import DocStyleChecker |
|
19 |
17 |
20 from .Ui_CodeStyleStatisticsDialog import Ui_CodeStyleStatisticsDialog |
18 from .Ui_CodeStyleStatisticsDialog import Ui_CodeStyleStatisticsDialog |
21 |
19 |
22 import UI.PixmapCache |
20 import UI.PixmapCache |
23 |
21 |
25 class CodeStyleStatisticsDialog(QDialog, Ui_CodeStyleStatisticsDialog): |
23 class CodeStyleStatisticsDialog(QDialog, Ui_CodeStyleStatisticsDialog): |
26 """ |
24 """ |
27 Class implementing a dialog showing statistical data for the last |
25 Class implementing a dialog showing statistical data for the last |
28 code style checker run. |
26 code style checker run. |
29 """ |
27 """ |
30 def __init__(self, statistics, parent=None): |
28 def __init__ (self, statistics, parent=None): |
31 """ |
29 """ |
32 Constructor |
30 Constructor |
33 |
31 |
34 @param statistics dictionary with the statistical data |
32 @param statistics dictionary with the statistical data |
35 @param parent reference to the parent widget (QWidget) |
33 @param parent reference to the parent widget (QWidget) |
46 del stats["_IssuesFixed"] |
44 del stats["_IssuesFixed"] |
47 |
45 |
48 totalIssues = 0 |
46 totalIssues = 0 |
49 |
47 |
50 for code in sorted(stats.keys()): |
48 for code in sorted(stats.keys()): |
51 if code in pep8.pep8_messages_sample_args: |
49 message = _messages.get(code) |
52 message = QCoreApplication.translate( |
50 if message is None: |
53 "pep8", pep8.pep8_messages[code]).format( |
|
54 *pep8.pep8_messages_sample_args[code]) |
|
55 elif code in pep8.pep8_messages: |
|
56 message = QCoreApplication.translate( |
|
57 "pep8", pep8.pep8_messages[code]) |
|
58 elif code in NamingStyleChecker.Messages: |
|
59 message = QCoreApplication.translate( |
|
60 "NamingStyleChecker", NamingStyleChecker.Messages[code]) |
|
61 elif code in DocStyleChecker.Messages: |
|
62 message = QCoreApplication.translate( |
|
63 "DocStyleChecker", DocStyleChecker.Messages[code]) |
|
64 else: |
|
65 continue |
51 continue |
|
52 |
|
53 if code in _messages_sample_args: |
|
54 message = message.format(*_messages_sample_args[code]) |
|
55 |
66 self.__createItem(stats[code], code, message) |
56 self.__createItem(stats[code], code, message) |
67 totalIssues += stats[code] |
57 totalIssues += stats[code] |
68 |
58 |
69 self.totalIssues.setText( |
59 self.totalIssues.setText( |
70 self.trUtf8("%n issue(s) found", "", totalIssues)) |
60 self.trUtf8("%n issue(s) found", "", totalIssues)) |