src/eric7/QScintilla/APIsManager.py

branch
eric7
changeset 9361
718bc86e1c3f
parent 9221
bf71ee032bb4
child 9401
38514063ecee
equal deleted inserted replaced
9360:8b46571d9cc9 9361:718bc86e1c3f
5 5
6 """ 6 """
7 Module implementing the APIsManager. 7 Module implementing the APIsManager.
8 """ 8 """
9 9
10 import glob
10 import os 11 import os
11 import pathlib 12 import pathlib
12 13
13 from PyQt6.QtCore import QDir, pyqtSignal, QObject 14 from PyQt6.QtCore import pyqtSignal, QLibraryInfo, QObject
14 from PyQt6.Qsci import QsciAPIs 15 from PyQt6.Qsci import QsciAPIs
15 16
16 from . import Lexers 17 from . import Lexers
17 import Preferences 18 import Preferences
18 import Globals 19 import Globals
192 Public method to get a list of installed API files. 193 Public method to get a list of installed API files.
193 194
194 @return list of installed API files (list of strings) 195 @return list of installed API files (list of strings)
195 """ 196 """
196 if self.__apis is not None: 197 if self.__apis is not None:
197 if Globals.isWindowsPlatform(): 198 qtDataDir = QLibraryInfo.path(QLibraryInfo.LibraryPath.DataPath)
198 qsciPath = os.path.join(Globals.getPyQt6ModulesDirectory(), "qsci") 199 apisDir = os.path.join(qtDataDir, "qsci", "api")
199 if os.path.exists(qsciPath): 200 if os.path.exists(apisDir):
200 # it's the installer 201 if self.__lexer.language():
201 if self.__lexer.lexerName() is not None: 202 apiDir = os.path.join(apisDir, self.__lexer.language())
202 apidir = os.path.join(qsciPath, "api", self.__lexer.lexerName()) 203 if not os.path.exists(apiDir):
203 fnames = [] 204 # use lower case language
204 filist = QDir(apidir).entryInfoList( 205 apiDir = os.path.join(apisDir, self.__lexer.language().lower())
205 ["*.api"], QDir.Filter.Files, QDir.SortFlag.IgnoreCase 206 fnames = {
207 os.path.join(apiDir, f)
208 for f in glob.glob("*.api", root_dir=apiDir)
209 }
210 # combine with the QScintilla standard behavior
211 fnames |= {
212 os.path.join(apiDir, f)
213 for f in glob.glob(
214 "*.api",
215 root_dir=os.path.join(apisDir, self.__lexer.lexer()),
206 ) 216 )
207 for fi in filist: 217 }
208 fnames.append(fi.absoluteFilePath()) 218 return sorted(fnames)
209 return fnames 219 else:
210 else: 220 return []
211 return []
212
213 return self.__apis.installedAPIFiles()
214 else: 221 else:
215 return [] 222 return []
216 223
217 def __preparedName(self): 224 def __preparedName(self):
218 """ 225 """

eric ide

mercurial