eric6/QScintilla/APIsManager.py

Tue, 10 Sep 2019 19:30:07 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 10 Sep 2019 19:30:07 +0200
changeset 7229
53054eb5b15a
parent 6942
2602857055c5
child 7267
aedc309827c7
permissions
-rw-r--r--

Removed obsolete "from __future__ import ..." statements.

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 APIsManager.
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
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
10
290
1e0ab7fcff96 Fixed another issue when using the PyQt4 windows installer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
11 import os
1e0ab7fcff96 Fixed another issue when using the PyQt4 windows installer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
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 QDir, QFileInfo, pyqtSignal, QObject
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3515
diff changeset
14 from PyQt5.Qsci import QsciAPIs
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
16 from . import Lexers
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 import Preferences
2614
9c49b4419ea7 Changed the logic for detecting and using the PyQt4 module directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2608
diff changeset
18 import Globals
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
20
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 class APIs(QObject):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 Class implementing an API storage entity.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
25 @signal apiPreparationFinished() emitted after the API preparation has
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
26 finished
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
27 @signal apiPreparationCancelled() emitted after the API preparation has
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
28 been cancelled
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
29 @signal apiPreparationStarted() emitted after the API preparation has
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
30 started
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 """
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 428
diff changeset
32 apiPreparationFinished = pyqtSignal()
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 428
diff changeset
33 apiPreparationCancelled = pyqtSignal()
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 428
diff changeset
34 apiPreparationStarted = pyqtSignal()
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 428
diff changeset
35
5349
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
36 def __init__(self, language, projectType="", forPreparation=False,
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
37 parent=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40
5349
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
41 @param language language of the APIs object
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
42 @type str
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
43 @param projectType type of the project
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
44 @type str
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 @param forPreparation flag indicating this object is just needed
5349
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
46 for a preparation process
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
47 @type bool
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
48 @param parent reference to the parent object
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
49 @type QObject
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 """
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
51 super(APIs, self).__init__(parent)
5349
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
52 if projectType:
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
53 self.setObjectName("APIs_{0}_{1}".format(language, projectType))
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
54 else:
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
55 self.setObjectName("APIs_{0}".format(language))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 self.__inPreparation = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 self.__language = language
5349
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
59 self.__projectType = projectType
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 self.__forPreparation = forPreparation
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 self.__lexer = Lexers.getLexer(self.__language)
5349
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
62 self.__apifiles = Preferences.getEditorAPI(self.__language,
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
63 self.__projectType)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 self.__apifiles.sort()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 if self.__lexer is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 self.__apis = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 self.__apis = QsciAPIs(self.__lexer)
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
69 self.__apis.apiPreparationFinished.connect(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
70 self.__apiPreparationFinished)
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
71 self.__apis.apiPreparationCancelled.connect(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
72 self.__apiPreparationCancelled)
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
73 self.__apis.apiPreparationStarted.connect(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
74 self.__apiPreparationStarted)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 self.__loadAPIs()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 def __loadAPIs(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 Private method to load the APIs.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 if self.__apis.isPrepared():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 # load a prepared API file
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
83 if not self.__forPreparation and \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
84 Preferences.getEditor("AutoPrepareAPIs"):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 self.prepareAPIs()
5349
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
86 self.__apis.loadPrepared(self.__preparedName())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 # load the raw files and prepare the API file
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
89 if not self.__forPreparation and \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
90 Preferences.getEditor("AutoPrepareAPIs"):
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
91 self.prepareAPIs(ondemand=True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 def reloadAPIs(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 Public method to reload the API information.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
97 if not self.__forPreparation and \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
98 Preferences.getEditor("AutoPrepareAPIs"):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 self.prepareAPIs()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 self.__loadAPIs()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 def getQsciAPIs(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 Public method to get a reference to QsciAPIs object.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 @return reference to the QsciAPIs object (QsciAPIs)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
108 if not self.__forPreparation and \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
109 Preferences.getEditor("AutoPrepareAPIs"):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 self.prepareAPIs()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 return self.__apis
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112
4133
3d868439dddc Improved the handling of the various auto-completion actions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
113 def isEmpty(self):
3d868439dddc Improved the handling of the various auto-completion actions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
114 """
3d868439dddc Improved the handling of the various auto-completion actions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
115 Public method to check, if the object has API files configured.
3d868439dddc Improved the handling of the various auto-completion actions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
116
3d868439dddc Improved the handling of the various auto-completion actions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
117 @return flag indicating no API files have been configured (boolean)
3d868439dddc Improved the handling of the various auto-completion actions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
118 """
3d868439dddc Improved the handling of the various auto-completion actions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
119 return len(self.__apifiles) == 0
3d868439dddc Improved the handling of the various auto-completion actions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
120
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 def __apiPreparationFinished(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 Private method called to save an API, after it has been prepared.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 """
5349
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
125 self.__apis.savePrepared(self.__preparedName())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 self.__inPreparation = False
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 428
diff changeset
127 self.apiPreparationFinished.emit()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 def __apiPreparationCancelled(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
131 Private method called, after the API preparation process has been
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
132 cancelled.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 self.__inPreparation = False
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 428
diff changeset
135 self.apiPreparationCancelled.emit()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 def __apiPreparationStarted(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 Private method called, when the API preparation process started.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 self.__inPreparation = True
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 428
diff changeset
142 self.apiPreparationStarted.emit()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
144 def prepareAPIs(self, ondemand=False, rawList=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 Public method to prepare the APIs if necessary.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 @keyparam ondemand flag indicating a requested preparation (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 @keyparam rawList list of raw API files (list of strings)
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 if self.__apis is None or self.__inPreparation:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 needsPreparation = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 if ondemand:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 needsPreparation = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 # check, if a new preparation is necessary
5349
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
159 preparedAPIs = self.__preparedName()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 if preparedAPIs:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 preparedAPIsInfo = QFileInfo(preparedAPIs)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 if not preparedAPIsInfo.exists():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 needsPreparation = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 preparedAPIsTime = preparedAPIsInfo.lastModified()
5349
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
166 apifiles = sorted(Preferences.getEditorAPI(
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
167 self.__language, self.__projectType))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 if self.__apifiles != apifiles:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 needsPreparation = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 for apifile in apifiles:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
171 if QFileInfo(apifile).lastModified() > \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
172 preparedAPIsTime:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 needsPreparation = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 break
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 if needsPreparation:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 # do the preparation
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 self.__apis.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 if rawList:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 apifiles = rawList
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 else:
5349
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
182 apifiles = Preferences.getEditorAPI(
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
183 self.__language, self.__projectType)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 for apifile in apifiles:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 self.__apis.load(apifile)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 self.__apis.prepare()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 self.__apifiles = apifiles
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 def cancelPreparation(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 Public slot to cancel the APIs preparation.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 self.__apis and self.__apis.cancelPreparation()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 def installedAPIFiles(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 Public method to get a list of installed API files.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 @return list of installed API files (list of strings)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 if self.__apis is not None:
2614
9c49b4419ea7 Changed the logic for detecting and using the PyQt4 module directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2608
diff changeset
202 if Globals.isWindowsPlatform():
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
203 qsciPath = os.path.join(
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3515
diff changeset
204 Globals.getPyQt5ModulesDirectory(), "qsci")
290
1e0ab7fcff96 Fixed another issue when using the PyQt4 windows installer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
205 if os.path.exists(qsciPath):
1e0ab7fcff96 Fixed another issue when using the PyQt4 windows installer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
206 # it's the installer
3468
869d0b6e1e16 Added an API file for QSS and corrected an issue in the APIs manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
207 if self.__lexer.lexerName() is not None:
3096
23856c207f81 Fixed an issue on Windows in the APIs manager when a lexer return None.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
208 apidir = os.path.join(qsciPath, "api",
3468
869d0b6e1e16 Added an API file for QSS and corrected an issue in the APIs manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
209 self.__lexer.lexerName())
3096
23856c207f81 Fixed an issue on Windows in the APIs manager when a lexer return None.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
210 fnames = []
23856c207f81 Fixed an issue on Windows in the APIs manager when a lexer return None.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
211 filist = QDir(apidir).entryInfoList(
23856c207f81 Fixed an issue on Windows in the APIs manager when a lexer return None.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
212 ["*.api"], QDir.Files, QDir.IgnoreCase)
23856c207f81 Fixed an issue on Windows in the APIs manager when a lexer return None.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
213 for fi in filist:
23856c207f81 Fixed an issue on Windows in the APIs manager when a lexer return None.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
214 fnames.append(fi.absoluteFilePath())
23856c207f81 Fixed an issue on Windows in the APIs manager when a lexer return None.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
215 return fnames
23856c207f81 Fixed an issue on Windows in the APIs manager when a lexer return None.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
216 else:
23856c207f81 Fixed an issue on Windows in the APIs manager when a lexer return None.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
217 return []
290
1e0ab7fcff96 Fixed another issue when using the PyQt4 windows installer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
218
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 return self.__apis.installedAPIFiles()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 return []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222
5349
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
223 def __preparedName(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 Private method returning the default name of a prepared API file.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 @return complete filename for the Prepared APIs file (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 """
5349
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
229 apisDir = os.path.join(Globals.getConfigDir(), "APIs")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 if self.__apis is not None:
5349
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
231 if self.__projectType:
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
232 filename = "{0}_{1}.pap".format(self.__language,
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
233 self.__projectType)
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
234 else:
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
235 filename = "{0}.pap".format(self.__language)
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
236 return os.path.join(apisDir, filename)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 return ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
240
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 class APIsManager(QObject):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 Class implementing the APIsManager class, which is the central store for
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 API information used by autocompletion and calltips.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
246 def __init__(self, parent=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 @param parent reference to the parent object (QObject)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 """
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
252 super(APIsManager, self).__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 self.setObjectName("APIsManager")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 self.__apis = {}
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 def reloadAPIs(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 Public slot to reload the api information.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 """
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
261 for api in list(self.__apis.values()):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 api and api.reloadAPIs()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263
5349
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
264 def getAPIs(self, language, projectType="", forPreparation=False):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 """
5349
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
266 Public method to get an APIs object for autocompletion/calltips.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
268 This method creates and loads an APIs object dynamically upon request.
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
269 This saves memory for languages, that might not be needed at the
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2614
diff changeset
270 moment.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271
5349
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
272 @param language language of the requested APIs object
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
273 @type str
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
274 @param projectType type of the project
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
275 @type str
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
276 @param forPreparation flag indicating the requested APIs object is just
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
277 needed for a preparation process
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
278 @type bool
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
279 @return reference to the APIs object
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
280 @rtype APIs
0
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 if forPreparation:
5349
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
283 return APIs(language, projectType=projectType,
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
284 forPreparation=forPreparation)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286 try:
5349
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
287 return self.__apis[(language, projectType)]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 except KeyError:
5358
2584d0a08bf4 Finished the project specific API code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5349
diff changeset
289 if language in Lexers.getSupportedApiLanguages():
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 # create the api object
5349
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
291 self.__apis[(language, projectType)] = \
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
292 APIs(language, projectType=projectType)
bccda3b5920a Started implementing project type specific APIs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
293 return self.__apis[(language, projectType)]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 return None

eric ide

mercurial