AssistantEric/APIsManager.py

changeset 17
8f33c2f5bfbd
parent 4
eb4cc276920c
child 19
7eb775bb326b
equal deleted inserted replaced
16:91e8b7cc6935 17:8f33c2f5bfbd
403 """ 403 """
404 format_select_stmt = """ 404 format_select_stmt = """
405 SELECT format FROM mgmt 405 SELECT format FROM mgmt
406 """ 406 """
407 mgmt_insert_stmt = """ 407 mgmt_insert_stmt = """
408 INSERT INTO mgmt (format) VALUES (%d) 408 INSERT INTO mgmt (format) VALUES ({0:d})
409 """ % DB_VERSION 409 """.format(DB_VERSION)
410 410
411 def __init__(self, language, parent = None): 411 def __init__(self, language, parent = None):
412 """ 412 """
413 Constructor 413 Constructor
414 414
415 @param language language of the APIs object (string) 415 @param language language of the APIs object (string)
416 @param parent reference to the parent object (QObject) 416 @param parent reference to the parent object (QObject)
417 """ 417 """
418 QObject.__init__(self, parent) 418 QObject.__init__(self, parent)
419 self.setObjectName("DbAPIs_%s" % language) 419 self.setObjectName("DbAPIs_{0}".format(language))
420 420
421 self.__inPreparation = False 421 self.__inPreparation = False
422 self.__worker = None 422 self.__worker = None
423 self.__workerQueue = [] 423 self.__workerQueue = []
424 424
466 "project-apis.db") 466 "project-apis.db")
467 else: 467 else:
468 apiDir = os.path.join(Utilities.getConfigDir(), "APIs") 468 apiDir = os.path.join(Utilities.getConfigDir(), "APIs")
469 if not os.path.exists(apiDir): 469 if not os.path.exists(apiDir):
470 os.makedirs(apiDir) 470 os.makedirs(apiDir)
471 return os.path.join(apiDir, "%s-api.db" % self.__language) 471 return os.path.join(apiDir, "{0}-api.db".format(self.__language))
472 472
473 def close(self): 473 def close(self):
474 """ 474 """
475 Public method to close the database. 475 Public method to close the database.
476 """ 476 """
654 word = query.value(0) 654 word = query.value(0)
655 sig = query.value(1) 655 sig = query.value(1)
656 fullCtx = query.value(2) 656 fullCtx = query.value(2)
657 if sig: 657 if sig:
658 if self.__discardFirst: 658 if self.__discardFirst:
659 sig = "(%s" % sig[1:]\ 659 sig = "({0}".format(sig[1:])\
660 .replace(self.__discardFirst, "", 1)\ 660 .replace(self.__discardFirst, "", 1)\
661 .strip(", \t\r\n") 661 .strip(", \t\r\n")
662 if self.__enoughCommas(sig, commas): 662 if self.__enoughCommas(sig, commas):
663 if showContext: 663 if showContext:
664 calltips.append("%s%s%s%s" % \ 664 calltips.append("{0}{1}{2}{3}".format(
665 (fullCtx, contextSeparator, word, sig)) 665 fullCtx, contextSeparator, word, sig))
666 else: 666 else:
667 calltips.append("%s%s" % (word, sig)) 667 calltips.append("{0}{1}".format(word, sig))
668 del query 668 del query
669 finally: 669 finally:
670 db.commit() 670 db.commit()
671 671
672 if context and len(calltips) == 0: 672 if context and len(calltips) == 0:

eric ide

mercurial