AssistantEric/APIsManager.py

changeset 20
3338ae0c05a9
parent 19
7eb775bb326b
child 21
0e54b870314c
equal deleted inserted replaced
19:7eb775bb326b 20:3338ae0c05a9
271 """ 271 """
272 Private method to delete all references to an api file. 272 Private method to delete all references to an api file.
273 273
274 @param apiFile filename of the raw API file (string) 274 @param apiFile filename of the raw API file (string)
275 """ 275 """
276 print("__deleteApiFile", apiFile)
276 db = QSqlDatabase.database(self.__language) 277 db = QSqlDatabase.database(self.__language)
277 db.transaction() 278 db.transaction()
278 try: 279 try:
279 query = QSqlQuery(db) 280 query = QSqlQuery(db)
280 281
300 301
301 def run(self): 302 def run(self):
302 """ 303 """
303 Public method to perform the threads work. 304 Public method to perform the threads work.
304 """ 305 """
306 print(sorted(self.__apiFiles))
305 QCoreApplication.postEvent(self.__proxy, QEvent(QEvent.Type(WorkerStarted))) 307 QCoreApplication.postEvent(self.__proxy, QEvent(QEvent.Type(WorkerStarted)))
306 308
307 db = QSqlDatabase.database(self.__language) 309 db = QSqlDatabase.database(self.__language)
308 if db.isValid() and db.isOpen(): 310 if db.isValid() and db.isOpen():
309 # step 1: remove API files not wanted any longer 311 # step 1: remove API files not wanted any longer
310 loadedApiFiles = self.__proxy.getApiFiles() 312 loadedApiFiles = self.__proxy.getApiFiles()
313 print(sorted(loadedApiFiles))
311 for apiFile in loadedApiFiles: 314 for apiFile in loadedApiFiles:
312 if not self.__aborted and apiFile not in self.__apiFiles: 315 if not self.__aborted and apiFile not in self.__apiFiles:
313 self.__deleteApiFile(apiFile) 316 self.__deleteApiFile(apiFile)
314 317
315 # step 2: (re-)load api files 318 # step 2: (re-)load api files
376 379
377 create_file_idx = """CREATE INDEX file_idx on file (file)""" 380 create_file_idx = """CREATE INDEX file_idx on file (file)"""
378 drop_file_idx = """DROP INDEX IF EXISTS file_idx""" 381 drop_file_idx = """DROP INDEX IF EXISTS file_idx"""
379 382
380 api_files_stmt = """ 383 api_files_stmt = """
381 SELECT file FROM file WHERE file LIKE '%.api' 384 SELECT file FROM file
382 """ 385 """
383 386
384 ac_stmt = """ 387 ac_stmt = """
385 SELECT DISTINCT acWord, fullContext, pictureId FROM api 388 SELECT DISTINCT acWord, fullContext, pictureId FROM api
386 WHERE acWord GLOB :acWord 389 WHERE acWord GLOB :acWord
810 813
811 def __projectOpened(self): 814 def __projectOpened(self):
812 """ 815 """
813 Private slot to perform actions after a project has been opened. 816 Private slot to perform actions after a project has been opened.
814 """ 817 """
818 print("__projectOpened")
815 if self.__project.getProjectLanguage() in ["Python", "Python3"]: 819 if self.__project.getProjectLanguage() in ["Python", "Python3"]:
816 self.__discardFirst = "self" 820 self.__discardFirst = "self"
817 else: 821 else:
818 self.__discardFirst = "" 822 self.__discardFirst = ""
819 self.__lexer = QScintilla.Lexers.getLexer(self.__project.getProjectLanguage()) 823 self.__lexer = QScintilla.Lexers.getLexer(self.__project.getProjectLanguage())

eric ide

mercurial