6 """ |
6 """ |
7 Module implementing a dialog to manage the QtHelp documentation database. |
7 Module implementing a dialog to manage the QtHelp documentation database. |
8 """ |
8 """ |
9 |
9 |
10 import sqlite3 |
10 import sqlite3 |
|
11 import contextlib |
11 |
12 |
12 from PyQt5.QtCore import pyqtSlot, Qt, QItemSelectionModel |
13 from PyQt5.QtCore import pyqtSlot, Qt, QItemSelectionModel |
13 from PyQt5.QtWidgets import ( |
14 from PyQt5.QtWidgets import ( |
14 QDialog, QTreeWidgetItem, QListWidgetItem, QInputDialog, QLineEdit |
15 QDialog, QTreeWidgetItem, QListWidgetItem, QInputDialog, QLineEdit |
15 ) |
16 ) |
475 |
476 |
476 def __removeAttributes(self): |
477 def __removeAttributes(self): |
477 """ |
478 """ |
478 Private method to remove attributes from the Qt Help database. |
479 Private method to remove attributes from the Qt Help database. |
479 """ |
480 """ |
480 try: |
481 with contextlib.suppress(sqlite3.DatabaseError): |
481 self.__db = sqlite3.connect(self.__engine.collectionFile()) |
482 self.__db = sqlite3.connect(self.__engine.collectionFile()) |
482 except sqlite3.DatabaseError: |
|
483 pass # ignore database errors |
|
484 |
483 |
485 for attr in self.__removedAttributes: |
484 for attr in self.__removedAttributes: |
486 self.__db.execute( |
485 self.__db.execute( |
487 "DELETE FROM FilterAttributeTable WHERE Name = '{0}'" # secok |
486 "DELETE FROM FilterAttributeTable WHERE Name = '{0}'" # secok |
488 .format(attr)) |
487 .format(attr)) |