Tue, 28 Mar 2017 19:17:26 +0200
Fixed an issue with the code style checker dialog not showing tooltips for the complexity spin boxes because the text was entered as status text instead of tool tip.
847
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
5389
9b1c800daff3
Updated copyright for 2017.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
3 | # Copyright (c) 2011 - 2017 Detlev Offenbach <detlev@die-offenbachs.de> |
847
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
2912
9ff696796092
Changed some display and source docu strings in the code style checker to make them more universal because the scope goes beyond PEP-8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2909
diff
changeset
|
7 | Module implementing a dialog showing statistical data for the last code |
9ff696796092
Changed some display and source docu strings in the code style checker to make them more universal because the scope goes beyond PEP-8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2909
diff
changeset
|
8 | style checker run. |
847
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | """ |
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | |
3145
a9de05d4a22f
# __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3057
diff
changeset
|
11 | from __future__ import unicode_literals |
2525
8b507a9a2d40
Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2302
diff
changeset
|
12 | |
3656
441956d8fce5
Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3515
diff
changeset
|
13 | from PyQt5.QtCore import Qt |
441956d8fce5
Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3515
diff
changeset
|
14 | from PyQt5.QtWidgets import QDialog, QTreeWidgetItem |
847
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | |
3443
7d919fd299f6
Bugfix for statistics dialog of the code style checker.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3145
diff
changeset
|
16 | from .translations import _messages, _messages_sample_args |
847
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | |
2972
ae58d4b2562e
Continued changing the names of the various code style checkers to make them more appropriate to the broadened scope.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2971
diff
changeset
|
18 | from .Ui_CodeStyleStatisticsDialog import Ui_CodeStyleStatisticsDialog |
847
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | |
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | import UI.PixmapCache |
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
857
diff
changeset
|
22 | |
2972
ae58d4b2562e
Continued changing the names of the various code style checkers to make them more appropriate to the broadened scope.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2971
diff
changeset
|
23 | class CodeStyleStatisticsDialog(QDialog, Ui_CodeStyleStatisticsDialog): |
847
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | """ |
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | Class implementing a dialog showing statistical data for the last |
2912
9ff696796092
Changed some display and source docu strings in the code style checker to make them more universal because the scope goes beyond PEP-8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2909
diff
changeset
|
26 | code style checker run. |
847
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | """ |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
857
diff
changeset
|
28 | def __init__(self, statistics, parent=None): |
847
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | """ |
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | Constructor |
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | |
2962
d6c9d1ca2da4
Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2915
diff
changeset
|
32 | @param statistics dictionary with the statistical data |
847
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | @param parent reference to the parent widget (QWidget) |
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | """ |
3057
10516539f238
Merge with default branch after shorten the code lines to max. 79 characters.
T.Rzepka <Tobias.Rzepka@gmail.com>
diff
changeset
|
35 | super(CodeStyleStatisticsDialog, self).__init__(parent) |
847
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | self.setupUi(self) |
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | |
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | stats = statistics.copy() |
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | filesCount = stats["_FilesCount"] |
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | filesIssues = stats["_FilesIssues"] |
853
ec7dd115e26b
Continued implementing a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
847
diff
changeset
|
41 | fixesCount = stats["_IssuesFixed"] |
3489
9c5af34205c9
Improved the code style checker to show statistics about ignored issues and to show ignored issues in the result list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3190
diff
changeset
|
42 | ignoresCount = stats["_IgnoredErrors"] |
847
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | del stats["_FilesCount"] |
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | del stats["_FilesIssues"] |
853
ec7dd115e26b
Continued implementing a fixer for PEP 8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
847
diff
changeset
|
45 | del stats["_IssuesFixed"] |
3489
9c5af34205c9
Improved the code style checker to show statistics about ignored issues and to show ignored issues in the result list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3190
diff
changeset
|
46 | del stats["_IgnoredErrors"] |
847
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | |
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | totalIssues = 0 |
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | |
2895
4a44d92757f9
Implemented some fixers for wrong naming conventions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2894
diff
changeset
|
50 | for code in sorted(stats.keys()): |
3443
7d919fd299f6
Bugfix for statistics dialog of the code style checker.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3145
diff
changeset
|
51 | message = _messages.get(code) |
7d919fd299f6
Bugfix for statistics dialog of the code style checker.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3145
diff
changeset
|
52 | if message is None: |
2862
a1448560d7dc
Started upgrading the pep8 checker to the latest release.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
53 | continue |
3443
7d919fd299f6
Bugfix for statistics dialog of the code style checker.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3145
diff
changeset
|
54 | |
7d919fd299f6
Bugfix for statistics dialog of the code style checker.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3145
diff
changeset
|
55 | if code in _messages_sample_args: |
7d919fd299f6
Bugfix for statistics dialog of the code style checker.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3145
diff
changeset
|
56 | message = message.format(*_messages_sample_args[code]) |
7d919fd299f6
Bugfix for statistics dialog of the code style checker.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3145
diff
changeset
|
57 | |
847
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | self.__createItem(stats[code], code, message) |
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | totalIssues += stats[code] |
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | |
857
613ded9c3b69
Fixed an issue with the extended PEP 8 statistics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
853
diff
changeset
|
61 | self.totalIssues.setText( |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
62 | self.tr("%n issue(s) found", "", totalIssues)) |
3489
9c5af34205c9
Improved the code style checker to show statistics about ignored issues and to show ignored issues in the result list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3190
diff
changeset
|
63 | self.ignoredIssues.setText( |
9c5af34205c9
Improved the code style checker to show statistics about ignored issues and to show ignored issues in the result list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3190
diff
changeset
|
64 | self.tr("%n issue(s) ignored", "", ignoresCount)) |
857
613ded9c3b69
Fixed an issue with the extended PEP 8 statistics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
853
diff
changeset
|
65 | self.fixedIssues.setText( |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
66 | self.tr("%n issue(s) fixed", "", fixesCount)) |
847
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | self.filesChecked.setText( |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
68 | self.tr("%n file(s) checked", "", filesCount)) |
847
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | self.filesIssues.setText( |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
70 | self.tr("%n file(s) with issues found", "", filesIssues)) |
847
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | |
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | self.statisticsList.resizeColumnToContents(0) |
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
73 | self.statisticsList.resizeColumnToContents(1) |
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
74 | |
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | def __createItem(self, count, code, message): |
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | """ |
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | Private method to create an entry in the result list. |
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | |
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | @param count occurrences of the issue (integer) |
2980
2cb4e3c50b37
Continued changing the names of the various code style checkers to make them more appropriate to the broadened scope.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2979
diff
changeset
|
80 | @param code of a code style issue message (string) |
2cb4e3c50b37
Continued changing the names of the various code style checkers to make them more appropriate to the broadened scope.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2979
diff
changeset
|
81 | @param message code style issue message to be shown (string) |
847
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
82 | """ |
1640
1699d46026cd
Fixed a compatibility issue with Qt 4.8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
83 | itm = QTreeWidgetItem(self.statisticsList) |
1699d46026cd
Fixed a compatibility issue with Qt 4.8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
84 | itm.setData(0, Qt.DisplayRole, count) |
1699d46026cd
Fixed a compatibility issue with Qt 4.8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
85 | itm.setData(1, Qt.DisplayRole, code) |
1699d46026cd
Fixed a compatibility issue with Qt 4.8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
86 | itm.setData(2, Qt.DisplayRole, message) |
4506
57666e501a42
Started to add more code style checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4423
diff
changeset
|
87 | if code.startswith(("W", "C", "M")): |
847
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
88 | itm.setIcon(1, UI.PixmapCache.getIcon("warning.png")) |
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
89 | elif code.startswith("E"): |
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
90 | itm.setIcon(1, UI.PixmapCache.getIcon("syntaxError.png")) |
2909
c3fb85fe41f9
Added the forgotten icon to the PEP-8 statistics dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2895
diff
changeset
|
91 | elif code.startswith("N"): |
c3fb85fe41f9
Added the forgotten icon to the PEP-8 statistics dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2895
diff
changeset
|
92 | itm.setIcon(1, UI.PixmapCache.getIcon("namingError.png")) |
2915
9da653363d07
Started implementing a checker for PEP-257 docstring conventions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2912
diff
changeset
|
93 | elif code.startswith("D"): |
9da653363d07
Started implementing a checker for PEP-257 docstring conventions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2912
diff
changeset
|
94 | itm.setIcon(1, UI.PixmapCache.getIcon("docstringError.png")) |
847
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
95 | |
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
96 | itm.setTextAlignment(0, Qt.AlignRight) |
cc18fbcde9fc
Added a dialog to show some statistics for the last PEP 8 check to the PEP 8 dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
97 | itm.setTextAlignment(1, Qt.AlignHCenter) |