eric6/Plugins/PluginTabnanny.py

Mon, 15 Apr 2019 19:53:29 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 15 Apr 2019 19:53:29 +0200
branch
setup.py
changeset 6949
a5255f1ba3f0
parent 6942
2602857055c5
child 7178
43e994af5ee0
permissions
-rw-r--r--

setup.py: continued implementing support for setup.py.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
3 # Copyright (c) 2007 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the Tabnanny plugin.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3060
diff changeset
10 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: 2407
diff changeset
11
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 import os
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3621
diff changeset
14 from PyQt5.QtCore import QObject, pyqtSignal
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 53
diff changeset
16 from E5Gui.E5Application import e5App
3450
2f7c8fd8e3f5 Added capability to check multiple files from the project sources browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3446
diff changeset
17 from E5Gui.E5Action import E5Action
2f7c8fd8e3f5 Added capability to check multiple files from the project sources browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3446
diff changeset
18 from Project.ProjectBrowserModel import ProjectBrowserFileItem
3515
1b8381afe38f Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3484 3450
diff changeset
19 from Utilities import determinePythonVersion
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
40
c2e5472b112c Changed some code to adjust eric5 to Python3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 28
diff changeset
21 import Preferences
5316
31cbc97d4974 Got rid of the manually set version numbers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
22 import UI.Info
40
c2e5472b112c Changed some code to adjust eric5 to Python3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 28
diff changeset
23
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 # Start-Of-Header
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 name = "Tabnanny Plugin"
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 autoactivate = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 deactivateable = True
5316
31cbc97d4974 Got rid of the manually set version numbers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
29 version = UI.Info.VersionOnly
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 className = "TabnannyPlugin"
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 packageName = "__core__"
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 shortDescription = "Show the Tabnanny dialog."
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 longDescription = """This plugin implements the Tabnanny dialog.""" \
3036
30c81c9e88b8 Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
34 """ Tabnanny is used to check Python source files for correct""" \
30c81c9e88b8 Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
35 """ indentations."""
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 pyqtApi = 2
3523
8df1ab89e261 python2Compatible flags for base plug-ins added.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3515
diff changeset
37 python2Compatible = True
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 # End-Of-Header
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 error = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 805
diff changeset
42
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 class TabnannyPlugin(QObject):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 Class implementing the Tabnanny plugin.
3414
448cfee96f45 Tabnanny ported to use the background service.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
46
4237
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
47 @signal indentChecked(str, bool, str, str) emitted when the indent
3414
448cfee96f45 Tabnanny ported to use the background service.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
48 check was done.
4237
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
49 @signal batchFinished() emitted when a style check batch is done
4503
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4237
diff changeset
50 @signal error(str, str) emitted in case of an error
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 """
3414
448cfee96f45 Tabnanny ported to use the background service.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
52 indentChecked = pyqtSignal(str, bool, str, str)
4237
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
53 batchFinished = pyqtSignal()
4503
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4237
diff changeset
54 error = pyqtSignal(str, str)
3414
448cfee96f45 Tabnanny ported to use the background service.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
55
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 def __init__(self, ui):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 @param ui reference to the user interface object (UI.UserInterface)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2407
diff changeset
62 super(TabnannyPlugin, self).__init__(ui)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 self.__ui = ui
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 self.__initialize()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65
3414
448cfee96f45 Tabnanny ported to use the background service.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
66 self.backgroundService = e5App().getObject("BackgroundService")
448cfee96f45 Tabnanny ported to use the background service.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
67
448cfee96f45 Tabnanny ported to use the background service.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
68 path = os.path.join(
448cfee96f45 Tabnanny ported to use the background service.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
69 os.path.dirname(__file__), 'CheckerPlugins', 'Tabnanny')
3558
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
70 self.backgroundService.serviceConnect(
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
71 'indent', 'Python2', path, 'Tabnanny',
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
72 lambda *args: self.indentChecked.emit(*args),
4237
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
73 onErrorCallback=self.serviceErrorPy2,
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
74 onBatchDone=self.batchJobDone)
3558
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
75 self.backgroundService.serviceConnect(
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
76 'indent', 'Python3', path, 'Tabnanny',
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
77 lambda *args: self.indentChecked.emit(*args),
4237
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
78 onErrorCallback=self.serviceErrorPy3,
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
79 onBatchDone=self.batchJobDone)
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
80
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
81 self.queuedBatches = []
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
82 self.batchesFinished = True
3558
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
83
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
84 def __serviceError(self, fn, msg):
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
85 """
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
86 Private slot handling service errors.
3414
448cfee96f45 Tabnanny ported to use the background service.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
87
3558
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
88 @param fn file name (string)
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
89 @param msg message text (string)
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
90 """
4503
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4237
diff changeset
91 self.error.emit(fn, msg)
3558
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
92
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
93 def serviceErrorPy2(self, fx, lang, fn, msg):
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
94 """
4237
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
95 Public slot handling service errors for Python 2.
3558
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
96
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
97 @param fx service name (string)
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
98 @param lang language (string)
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
99 @param fn file name (string)
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
100 @param msg message text (string)
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
101 """
4237
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
102 if fx in ['indent', 'batch_indent'] and lang == 'Python2':
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
103 if fx == 'indent':
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
104 self.__serviceError(fn, msg)
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
105 else:
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
106 self.__serviceError(self.tr("Python 2 batch check"), msg)
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
107 self.batchJobDone(fx, lang)
3558
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
108
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
109 def serviceErrorPy3(self, fx, lang, fn, msg):
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
110 """
4237
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
111 Public slot handling service errors for Python 2.
3558
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
112
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
113 @param fx service name (string)
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
114 @param lang language (string)
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
115 @param fn file name (string)
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
116 @param msg message text (string)
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
117 """
4237
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
118 if fx in ['indent', 'batch_indent'] and lang == 'Python3':
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
119 if fx == 'indent':
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
120 self.__serviceError(fn, msg)
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
121 else:
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
122 self.__serviceError(self.tr("Python 3 batch check"), msg)
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
123 self.batchJobDone(fx, lang)
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
124
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
125 def batchJobDone(self, fx, lang):
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
126 """
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
127 Public slot handling the completion of a batch job.
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
128
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
129 @param fx service name (string)
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
130 @param lang language (string)
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
131 """
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
132 if fx in ['indent', 'batch_indent']:
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
133 if lang in self.queuedBatches:
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
134 self.queuedBatches.remove(lang)
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
135 # prevent sending the signal multiple times
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
136 if len(self.queuedBatches) == 0 and not self.batchesFinished:
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
137 self.batchFinished.emit()
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
138 self.batchesFinished = True
3558
7f2bc8910d28 Fixed issues in the various checkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
139
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 def __initialize(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 Private slot to (re)initialize the plugin.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 self.__projectAct = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 self.__projectTabnannyDialog = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 self.__projectBrowserAct = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 self.__projectBrowserMenu = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 self.__projectBrowserTabnannyDialog = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 self.__editors = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 self.__editorAct = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 self.__editorTabnannyDialog = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154
3414
448cfee96f45 Tabnanny ported to use the background service.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
155 def indentCheck(self, lang, filename, source):
448cfee96f45 Tabnanny ported to use the background service.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
156 """
4237
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
157 Public method to prepare an indentation check on one Python source
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
158 file.
3414
448cfee96f45 Tabnanny ported to use the background service.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
159
448cfee96f45 Tabnanny ported to use the background service.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
160 @param lang language of the file or None to determine by internal
448cfee96f45 Tabnanny ported to use the background service.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
161 algorithm (str or None)
448cfee96f45 Tabnanny ported to use the background service.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
162 @param filename source filename (string)
448cfee96f45 Tabnanny ported to use the background service.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
163 @param source string containing the code to check (string)
448cfee96f45 Tabnanny ported to use the background service.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
164 """
448cfee96f45 Tabnanny ported to use the background service.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
165 if lang is None:
448cfee96f45 Tabnanny ported to use the background service.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
166 lang = 'Python{0}'.format(determinePythonVersion(filename, source))
448cfee96f45 Tabnanny ported to use the background service.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
167 if lang not in ['Python2', 'Python3']:
448cfee96f45 Tabnanny ported to use the background service.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
168 return
448cfee96f45 Tabnanny ported to use the background service.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
169
448cfee96f45 Tabnanny ported to use the background service.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
170 self.backgroundService.enqueueRequest(
448cfee96f45 Tabnanny ported to use the background service.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
171 'indent', lang, filename, [source])
448cfee96f45 Tabnanny ported to use the background service.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
172
4237
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
173 def indentBatchCheck(self, argumentsList):
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
174 """
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
175 Public method to prepare an indentation check on multiple Python
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
176 source files.
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
177
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
178 @param argumentsList list of arguments tuples with each tuple
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
179 containing filename and source (string, string)
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
180 """
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
181 data = {
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
182 "Python2": [],
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
183 "Python3": [],
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
184 }
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
185 for filename, source in argumentsList:
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
186 lang = 'Python{0}'.format(determinePythonVersion(filename, source))
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
187 if lang not in ['Python2', 'Python3']:
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
188 continue
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
189 else:
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
190 data[lang].append((filename, source))
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
191
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
192 self.queuedBatches = []
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
193 for lang in ['Python2', 'Python3']:
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
194 if data[lang]:
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
195 self.queuedBatches.append(lang)
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
196 self.backgroundService.enqueueRequest('batch_indent', lang, "",
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
197 data[lang])
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
198 self.batchesFinished = False
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
199
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
200 def cancelIndentBatchCheck(self):
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
201 """
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
202 Public method to cancel all batch jobs.
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
203 """
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
204 for lang in ['Python2', 'Python3']:
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
205 self.backgroundService.requestCancel('batch_style', lang)
ff8a3e769fca Added a batch mode to the indentation checker to make use of multiple CPUs/CPU-Cores.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
206
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 def activate(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 Public method to activate this plugin.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 @return tuple of None and activation status (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 """
53
c3eb7cc1ff8b Renamed e5App to e5App.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 40
diff changeset
213 menu = e5App().getObject("Project").getMenu("Checks")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 if menu:
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3004
diff changeset
215 self.__projectAct = E5Action(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3180
diff changeset
216 self.tr('Check Indentations'),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3180
diff changeset
217 self.tr('&Indentations...'), 0, 0,
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3004
diff changeset
218 self, 'project_check_indentations')
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 500
diff changeset
219 self.__projectAct.setStatusTip(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3180
diff changeset
220 self.tr('Check indentations using tabnanny.'))
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3180
diff changeset
221 self.__projectAct.setWhatsThis(self.tr(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 """<b>Check Indentations...</b>"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 """<p>This checks Python files"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 """ for bad indentations using tabnanny.</p>"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 ))
3345
071afe8be2a1 Changed signal/slot usage to not use constructs like 'triggered[()].connect(...)' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
226 self.__projectAct.triggered.connect(self.__projectTabnanny)
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 53
diff changeset
227 e5App().getObject("Project").addE5Actions([self.__projectAct])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 menu.addAction(self.__projectAct)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3004
diff changeset
230 self.__editorAct = E5Action(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3180
diff changeset
231 self.tr('Check Indentations'),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3180
diff changeset
232 self.tr('&Indentations...'), 0, 0,
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3004
diff changeset
233 self, "")
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3180
diff changeset
234 self.__editorAct.setWhatsThis(self.tr(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 """<b>Check Indentations...</b>"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 """<p>This checks Python files"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 """ for bad indentations using tabnanny.</p>"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 ))
3345
071afe8be2a1 Changed signal/slot usage to not use constructs like 'triggered[()].connect(...)' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
239 self.__editorAct.triggered.connect(self.__editorTabnanny)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240
495
b31b0bffa5b0 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 454
diff changeset
241 e5App().getObject("Project").showMenu.connect(self.__projectShowMenu)
b31b0bffa5b0 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 454
diff changeset
242 e5App().getObject("ProjectBrowser").getProjectBrowser("sources")\
b31b0bffa5b0 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 454
diff changeset
243 .showMenu.connect(self.__projectBrowserShowMenu)
3004
c4bf32c791d0 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2712
diff changeset
244 e5App().getObject("ViewManager").editorOpenedEd.connect(
c4bf32c791d0 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2712
diff changeset
245 self.__editorOpened)
c4bf32c791d0 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2712
diff changeset
246 e5App().getObject("ViewManager").editorClosedEd.connect(
c4bf32c791d0 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2712
diff changeset
247 self.__editorClosed)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248
53
c3eb7cc1ff8b Renamed e5App to e5App.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 40
diff changeset
249 for editor in e5App().getObject("ViewManager").getOpenEditors():
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 self.__editorOpened(editor)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 return None, True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 def deactivate(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 Public method to deactivate this plugin.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 """
3004
c4bf32c791d0 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2712
diff changeset
258 e5App().getObject("Project").showMenu.disconnect(
c4bf32c791d0 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2712
diff changeset
259 self.__projectShowMenu)
495
b31b0bffa5b0 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 454
diff changeset
260 e5App().getObject("ProjectBrowser").getProjectBrowser("sources")\
b31b0bffa5b0 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 454
diff changeset
261 .showMenu.disconnect(self.__projectBrowserShowMenu)
3004
c4bf32c791d0 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2712
diff changeset
262 e5App().getObject("ViewManager").editorOpenedEd.disconnect(
c4bf32c791d0 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2712
diff changeset
263 self.__editorOpened)
c4bf32c791d0 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2712
diff changeset
264 e5App().getObject("ViewManager").editorClosedEd.disconnect(
c4bf32c791d0 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2712
diff changeset
265 self.__editorClosed)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266
53
c3eb7cc1ff8b Renamed e5App to e5App.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 40
diff changeset
267 menu = e5App().getObject("Project").getMenu("Checks")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 if menu:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 menu.removeAction(self.__projectAct)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 if self.__projectBrowserMenu:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 if self.__projectBrowserAct:
3004
c4bf32c791d0 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2712
diff changeset
273 self.__projectBrowserMenu.removeAction(
c4bf32c791d0 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2712
diff changeset
274 self.__projectBrowserAct)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 for editor in self.__editors:
495
b31b0bffa5b0 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 454
diff changeset
277 editor.showMenu.disconnect(self.__editorShowMenu)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 menu = editor.getMenu("Checks")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 if menu is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 menu.removeAction(self.__editorAct)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 self.__initialize()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 def __projectShowMenu(self, menuName, menu):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 805
diff changeset
286 Private slot called, when the the project menu or a submenu is
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 about to be shown.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 @param menuName name of the menu to be shown (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 @param menu reference to the menu (QMenu)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292 if menuName == "Checks" and self.__projectAct is not None:
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 500
diff changeset
293 self.__projectAct.setEnabled(
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
294 e5App().getObject("Project").getProjectLanguage() in
3036
30c81c9e88b8 Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
295 ["Python3", "Python2", "Python"])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297 def __projectBrowserShowMenu(self, menuName, menu):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 """
3004
c4bf32c791d0 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2712
diff changeset
299 Private slot called, when the the project browser context menu or a
c4bf32c791d0 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2712
diff changeset
300 submenu is about to be shown.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 @param menuName name of the menu to be shown (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 @param menu reference to the menu (QMenu)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305 if menuName == "Checks" and \
805
83ca4d1ff648 Added a tabnanny checker function for Python 2 files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
306 e5App().getObject("Project").getProjectLanguage() in \
83ca4d1ff648 Added a tabnanny checker function for Python 2 files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
307 ["Python3", "Python2", "Python"]:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 self.__projectBrowserMenu = menu
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 if self.__projectBrowserAct is None:
3004
c4bf32c791d0 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2712
diff changeset
310 self.__projectBrowserAct = E5Action(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3180
diff changeset
311 self.tr('Check Indentations'),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3180
diff changeset
312 self.tr('&Indentations...'), 0, 0,
3004
c4bf32c791d0 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2712
diff changeset
313 self, "")
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3180
diff changeset
314 self.__projectBrowserAct.setWhatsThis(self.tr(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 """<b>Check Indentations...</b>"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 """<p>This checks Python files"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317 """ for bad indentations using tabnanny.</p>"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 ))
3345
071afe8be2a1 Changed signal/slot usage to not use constructs like 'triggered[()].connect(...)' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
319 self.__projectBrowserAct.triggered.connect(
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
320 self.__projectBrowserTabnanny)
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
321 if self.__projectBrowserAct not in menu.actions():
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 menu.addAction(self.__projectBrowserAct)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 def __projectTabnanny(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3558
diff changeset
326 Private slot used to check the project files for bad indentations.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327 """
53
c3eb7cc1ff8b Renamed e5App to e5App.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 40
diff changeset
328 project = e5App().getObject("Project")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329 project.saveAllScripts()
571
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
330 ppath = project.getProjectPath()
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
331 files = [os.path.join(ppath, file)
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
332 for file in project.pdata["SOURCES"]
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3004
diff changeset
333 if file.endswith(
3036
30c81c9e88b8 Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
334 tuple(Preferences.getPython("Python3Extensions")) +
30c81c9e88b8 Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
335 tuple(Preferences.getPython("PythonExtensions")))]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336
2407
b98cc8ee1142 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
337 from CheckerPlugins.Tabnanny.TabnannyDialog import TabnannyDialog
3414
448cfee96f45 Tabnanny ported to use the background service.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
338 self.__projectTabnannyDialog = TabnannyDialog(self)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
339 self.__projectTabnannyDialog.show()
571
1a4101cb87eb Added filename filters to the syntax checker and tabnanny dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
340 self.__projectTabnannyDialog.prepare(files, project)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
341
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342 def __projectBrowserTabnanny(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343 """
3004
c4bf32c791d0 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2712
diff changeset
344 Private method to handle the tabnanny context menu action of the
c4bf32c791d0 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2712
diff changeset
345 project sources browser.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346 """
3004
c4bf32c791d0 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2712
diff changeset
347 browser = e5App().getObject("ProjectBrowser").getProjectBrowser(
c4bf32c791d0 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2712
diff changeset
348 "sources")
3450
2f7c8fd8e3f5 Added capability to check multiple files from the project sources browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3446
diff changeset
349 if browser.getSelectedItemsCount([ProjectBrowserFileItem]) > 1:
2f7c8fd8e3f5 Added capability to check multiple files from the project sources browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3446
diff changeset
350 fn = []
2f7c8fd8e3f5 Added capability to check multiple files from the project sources browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3446
diff changeset
351 for itm in browser.getSelectedItems([ProjectBrowserFileItem]):
2f7c8fd8e3f5 Added capability to check multiple files from the project sources browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3446
diff changeset
352 fn.append(itm.fileName())
2f7c8fd8e3f5 Added capability to check multiple files from the project sources browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3446
diff changeset
353 else:
2f7c8fd8e3f5 Added capability to check multiple files from the project sources browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3446
diff changeset
354 itm = browser.model().item(browser.currentIndex())
2f7c8fd8e3f5 Added capability to check multiple files from the project sources browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3446
diff changeset
355 try:
2f7c8fd8e3f5 Added capability to check multiple files from the project sources browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3446
diff changeset
356 fn = itm.fileName()
2f7c8fd8e3f5 Added capability to check multiple files from the project sources browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3446
diff changeset
357 except AttributeError:
2f7c8fd8e3f5 Added capability to check multiple files from the project sources browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3446
diff changeset
358 fn = itm.dirName()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359
2407
b98cc8ee1142 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
360 from CheckerPlugins.Tabnanny.TabnannyDialog import TabnannyDialog
3414
448cfee96f45 Tabnanny ported to use the background service.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
361 self.__projectBrowserTabnannyDialog = TabnannyDialog(self)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
362 self.__projectBrowserTabnannyDialog.show()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
363 self.__projectBrowserTabnannyDialog.start(fn)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365 def __editorOpened(self, editor):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367 Private slot called, when a new editor was opened.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369 @param editor reference to the new editor (QScintilla.Editor)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371 menu = editor.getMenu("Checks")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
372 if menu is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
373 menu.addAction(self.__editorAct)
495
b31b0bffa5b0 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 454
diff changeset
374 editor.showMenu.connect(self.__editorShowMenu)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
375 self.__editors.append(editor)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
376
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
377 def __editorClosed(self, editor):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
378 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
379 Private slot called, when an editor was closed.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
380
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381 @param editor reference to the editor (QScintilla.Editor)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
383 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384 self.__editors.remove(editor)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
385 except ValueError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
386 pass
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388 def __editorShowMenu(self, menuName, menu, editor):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 805
diff changeset
390 Private slot called, when the the editor context menu or a submenu is
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391 about to be shown.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
392
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 @param menuName name of the menu to be shown (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394 @param menu reference to the menu (QMenu)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395 @param editor reference to the editor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 if menuName == "Checks":
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
398 if self.__editorAct not in menu.actions():
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
399 menu.addAction(self.__editorAct)
3446
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3345
diff changeset
400 self.__editorAct.setEnabled(editor.isPyFile())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
401
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
402 def __editorTabnanny(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
403 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
404 Private slot to handle the tabnanny context menu action of the editors.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
405 """
53
c3eb7cc1ff8b Renamed e5App to e5App.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 40
diff changeset
406 editor = e5App().getObject("ViewManager").activeWindow()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
407 if editor is not None:
954
a096fdc38f71 Fixed a few issues with the various checkers related to checking an unsaved file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
408 if editor.checkDirty() and editor.getFileName() is not None:
3004
c4bf32c791d0 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2712
diff changeset
409 from CheckerPlugins.Tabnanny.TabnannyDialog import \
c4bf32c791d0 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2712
diff changeset
410 TabnannyDialog
3414
448cfee96f45 Tabnanny ported to use the background service.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
411 self.__editorTabnannyDialog = TabnannyDialog(self)
954
a096fdc38f71 Fixed a few issues with the various checkers related to checking an unsaved file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
412 self.__editorTabnannyDialog.show()
a096fdc38f71 Fixed a few issues with the various checkers related to checking an unsaved file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
413 self.__editorTabnannyDialog.start(editor.getFileName())

eric ide

mercurial