26 """ |
27 """ |
27 apiPreparationFinished = pyqtSignal() |
28 apiPreparationFinished = pyqtSignal() |
28 apiPreparationCancelled = pyqtSignal() |
29 apiPreparationCancelled = pyqtSignal() |
29 apiPreparationStarted = pyqtSignal() |
30 apiPreparationStarted = pyqtSignal() |
30 |
31 |
31 def __init__(self, language, forPreparation = False, parent = None): |
32 def __init__(self, language, forPreparation=False, parent=None): |
32 """ |
33 """ |
33 Constructor |
34 Constructor |
34 |
35 |
35 @param language language of the APIs object (string) |
36 @param language language of the APIs object (string) |
36 @param forPreparation flag indicating this object is just needed |
37 @param forPreparation flag indicating this object is just needed |
65 self.prepareAPIs() |
66 self.prepareAPIs() |
66 self.__apis.loadPrepared() |
67 self.__apis.loadPrepared() |
67 else: |
68 else: |
68 # load the raw files and prepare the API file |
69 # load the raw files and prepare the API file |
69 if not self.__forPreparation and Preferences.getEditor("AutoPrepareAPIs"): |
70 if not self.__forPreparation and Preferences.getEditor("AutoPrepareAPIs"): |
70 self.prepareAPIs(ondemand = True) |
71 self.prepareAPIs(ondemand=True) |
71 |
72 |
72 def reloadAPIs(self): |
73 def reloadAPIs(self): |
73 """ |
74 """ |
74 Public method to reload the API information. |
75 Public method to reload the API information. |
75 """ |
76 """ |
107 Private method called, when the API preparation process started. |
108 Private method called, when the API preparation process started. |
108 """ |
109 """ |
109 self.__inPreparation = True |
110 self.__inPreparation = True |
110 self.apiPreparationStarted.emit() |
111 self.apiPreparationStarted.emit() |
111 |
112 |
112 def prepareAPIs(self, ondemand = False, rawList = None): |
113 def prepareAPIs(self, ondemand=False, rawList=None): |
113 """ |
114 """ |
114 Public method to prepare the APIs if necessary. |
115 Public method to prepare the APIs if necessary. |
115 |
116 |
116 @keyparam ondemand flag indicating a requested preparation (boolean) |
117 @keyparam ondemand flag indicating a requested preparation (boolean) |
117 @keyparam rawList list of raw API files (list of strings) |
118 @keyparam rawList list of raw API files (list of strings) |
169 qsciPath = os.path.join(pyqtconfig._pkg_config["pyqt_mod_dir"], "qsci") |
170 qsciPath = os.path.join(pyqtconfig._pkg_config["pyqt_mod_dir"], "qsci") |
170 if os.path.exists(qsciPath): |
171 if os.path.exists(qsciPath): |
171 # it's the installer |
172 # it's the installer |
172 apidir = os.path.join(qsciPath, "api", self.__lexer.lexer()) |
173 apidir = os.path.join(qsciPath, "api", self.__lexer.lexer()) |
173 fnames = [] |
174 fnames = [] |
174 filist = QDir(apidir).entryInfoList(["*.api"], QDir.Files, |
175 filist = QDir(apidir).entryInfoList(["*.api"], QDir.Files, |
175 QDir.IgnoreCase) |
176 QDir.IgnoreCase) |
176 for fi in filist: |
177 for fi in filist: |
177 fnames.append(fi.absoluteFilePath()) |
178 fnames.append(fi.absoluteFilePath()) |
178 return fnames |
179 return fnames |
179 |
180 |
190 if self.__apis is not None: |
191 if self.__apis is not None: |
191 return self.__apis.defaultPreparedName() |
192 return self.__apis.defaultPreparedName() |
192 else: |
193 else: |
193 return "" |
194 return "" |
194 |
195 |
|
196 |
195 class APIsManager(QObject): |
197 class APIsManager(QObject): |
196 """ |
198 """ |
197 Class implementing the APIsManager class, which is the central store for |
199 Class implementing the APIsManager class, which is the central store for |
198 API information used by autocompletion and calltips. |
200 API information used by autocompletion and calltips. |
199 """ |
201 """ |
200 def __init__(self, parent = None): |
202 def __init__(self, parent=None): |
201 """ |
203 """ |
202 Constructor |
204 Constructor |
203 |
205 |
204 @param parent reference to the parent object (QObject) |
206 @param parent reference to the parent object (QObject) |
205 """ |
207 """ |
213 Public slot to reload the api information. |
215 Public slot to reload the api information. |
214 """ |
216 """ |
215 for api in list(self.__apis.values()): |
217 for api in list(self.__apis.values()): |
216 api and api.reloadAPIs() |
218 api and api.reloadAPIs() |
217 |
219 |
218 def getAPIs(self, language, forPreparation = False): |
220 def getAPIs(self, language, forPreparation=False): |
219 """ |
221 """ |
220 Public method to get an apis object for autocompletion/calltips. |
222 Public method to get an apis object for autocompletion/calltips. |
221 |
223 |
222 This method creates and loads an APIs object dynamically upon request. |
224 This method creates and loads an APIs object dynamically upon request. |
223 This saves memory for languages, that might not be needed at the moment. |
225 This saves memory for languages, that might not be needed at the moment. |
224 |
226 |
225 @param language the language of the requested api object (string) |
227 @param language the language of the requested api object (string) |
226 @param forPreparation flag indicating the requested api object is just needed |
228 @param forPreparation flag indicating the requested api object is just needed |
227 for a preparation process (boolean) |
229 for a preparation process (boolean) |
228 @return the apis object (APIs) |
230 @return the apis object (APIs) |
229 """ |
231 """ |
230 if forPreparation: |
232 if forPreparation: |
231 return APIs(language, forPreparation = forPreparation) |
233 return APIs(language, forPreparation=forPreparation) |
232 else: |
234 else: |
233 try: |
235 try: |
234 return self.__apis[language] |
236 return self.__apis[language] |
235 except KeyError: |
237 except KeyError: |
236 if language in Lexers.getSupportedLanguages(): |
238 if language in Lexers.getSupportedLanguages(): |