AssistantEric/APIsManager.py

changeset 136
5cfe53b474a9
parent 135
08cb4f36ad47
child 140
a0ea7418d433
equal deleted inserted replaced
135:08cb4f36ad47 136:5cfe53b474a9
190 classNameStr = "{0}{1}.".format(moduleName, className) 190 classNameStr = "{0}{1}.".format(moduleName, className)
191 for variable in sorted(_class.attributes.keys()): 191 for variable in sorted(_class.attributes.keys()):
192 if not _class.attributes[variable].isPrivate(): 192 if not _class.attributes[variable].isPrivate():
193 from QScintilla.Editor import Editor 193 from QScintilla.Editor import Editor
194 if _class.attributes[variable].isPublic(): 194 if _class.attributes[variable].isPublic():
195 id = Editor.AttributeID 195 iconId = Editor.AttributeID
196 elif _class.attributes[variable].isProtected(): 196 elif _class.attributes[variable].isProtected():
197 id = Editor.AttributeProtectedID 197 iconId = Editor.AttributeProtectedID
198 else: 198 else:
199 id = Editor.AttributePrivateID 199 iconId = Editor.AttributePrivateID
200 api.append('{0}{1}?{2:d}'.format(classNameStr, variable, 200 api.append('{0}{1}?{2:d}'.format(classNameStr, variable,
201 id)) 201 iconId))
202 return api 202 return api
203 203
204 def __loadApiFile(self, apiFile): 204 def __loadApiFile(self, apiFile):
205 """ 205 """
206 Private method to read a raw API file into the database. 206 Private method to read a raw API file into the database.
313 query.bindValue(":file", apiFile) 313 query.bindValue(":file", apiFile)
314 if not query.exec_(): 314 if not query.exec_():
315 return 315 return
316 if not query.next(): 316 if not query.next():
317 return 317 return
318 id = int(query.value(0)) 318 fileId = int(query.value(0))
319 319
320 # step 2: delete all entries belonging to this file 320 # step 2: delete all entries belonging to this file
321 query.prepare(self.populate_del_api_stmt) 321 query.prepare(self.populate_del_api_stmt)
322 query.bindValue(":fileId", id) 322 query.bindValue(":fileId", fileId)
323 query.exec_() 323 query.exec_()
324 324
325 query.prepare(self.populate_del_bases_stmt) 325 query.prepare(self.populate_del_bases_stmt)
326 query.bindValue(":fileId", id) 326 query.bindValue(":fileId", fileId)
327 query.exec_() 327 query.exec_()
328 328
329 # step 3: load the given API info 329 # step 3: load the given API info
330 query.prepare(self.populate_api_stmt) 330 query.prepare(self.populate_api_stmt)
331 for api in apis: 331 for api in apis:
381 381
382 query.bindValue(":acWord", acWord) 382 query.bindValue(":acWord", acWord)
383 query.bindValue(":context", context) 383 query.bindValue(":context", context)
384 query.bindValue(":fullContext", fullContext) 384 query.bindValue(":fullContext", fullContext)
385 query.bindValue(":signature", sig) 385 query.bindValue(":signature", sig)
386 query.bindValue(":fileId", id) 386 query.bindValue(":fileId", fileId)
387 query.bindValue(":pictureId", pictureId) 387 query.bindValue(":pictureId", pictureId)
388 query.exec_() 388 query.exec_()
389 389
390 sig = "" 390 sig = ""
391 391
400 continue 400 continue
401 401
402 class_, baseClasses = base.split(" ", 1) 402 class_, baseClasses = base.split(" ", 1)
403 query.bindValue(":class", class_) 403 query.bindValue(":class", class_)
404 query.bindValue(":baseClasses", baseClasses) 404 query.bindValue(":baseClasses", baseClasses)
405 query.bindValue(":fileId", id) 405 query.bindValue(":fileId", fileId)
406 query.exec_() 406 query.exec_()
407 407
408 if not self.__aborted: 408 if not self.__aborted:
409 # step 5: update the file entry 409 # step 5: update the file entry
410 query.prepare(self.update_file_stmt) 410 query.prepare(self.update_file_stmt)
432 # step 1: get the ID belonging to the api file 432 # step 1: get the ID belonging to the api file
433 query.prepare(self.file_id_stmt) 433 query.prepare(self.file_id_stmt)
434 query.bindValue(":file", apiFile) 434 query.bindValue(":file", apiFile)
435 query.exec_() 435 query.exec_()
436 query.next() 436 query.next()
437 id = int(query.value(0)) 437 fileId = int(query.value(0))
438 438
439 # step 2: delete all API entries belonging to this file 439 # step 2: delete all API entries belonging to this file
440 query.prepare(self.populate_del_api_stmt) 440 query.prepare(self.populate_del_api_stmt)
441 query.bindValue(":fileId", id) 441 query.bindValue(":fileId", fileId)
442 query.exec_() 442 query.exec_()
443 443
444 # step 3: delete all base classes entries belonging to this file 444 # step 3: delete all base classes entries belonging to this file
445 query.prepare(self.populate_del_bases_stmt) 445 query.prepare(self.populate_del_bases_stmt)
446 query.bindValue(":fileId", id) 446 query.bindValue(":fileId", fileId)
447 query.exec_() 447 query.exec_()
448 448
449 # step 4: delete the file entry 449 # step 4: delete the file entry
450 query.prepare(self.file_delete_id_stmt) 450 query.prepare(self.file_delete_id_stmt)
451 query.bindValue(":id", id) 451 query.bindValue(":id", fileId)
452 query.exec_() 452 query.exec_()
453 finally: 453 finally:
454 del query 454 del query
455 db.commit() 455 db.commit()
456 456
795 try: 795 try:
796 query = QSqlQuery(db) 796 query = QSqlQuery(db)
797 ok = query.exec_(self.format_select_stmt) 797 ok = query.exec_(self.format_select_stmt)
798 if ok: 798 if ok:
799 query.next() 799 query.next()
800 format = int(query.value(0)) 800 formatVersion = int(query.value(0))
801 if format >= self.DB_VERSION: 801 if formatVersion >= self.DB_VERSION:
802 prepared = True 802 prepared = True
803 finally: 803 finally:
804 del query 804 del query
805 db.commit() 805 db.commit()
806 return prepared 806 return prepared

eric ide

mercurial