Skip to content

Commit

Permalink
Se recupera da abertura de um arquivo .nbook inválido
Browse files Browse the repository at this point in the history
  • Loading branch information
ehcelino committed Mar 21, 2023
1 parent 35f6050 commit 82e6d22
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions nbooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1896,6 +1896,27 @@ def create_database(self):
conexao.close()
self.read_database()


def clear_error(self):
"""
Recupera o programa de um erro no arquivo .nbook
:return:
"""
msg = QMessageBox()
msg.setIcon(QMessageBox.Warning)
msg.setText("Arquivo inválido.")
msg.setWindowTitle("Atenção")
msg.setStandardButtons(QMessageBox.Ok)
retval = msg.exec_()
self.notebook_delete()
self.notebook_click()
# self.db_file = os.path.join('db', 'database.nbook')
# settings.setValue('database', self.db_file)
# self.setWindowTitle(f'NBooks ({self.db_file})')
# self.lblNbook.setText(self.listWidget.currentItem().data(2))
# self.read_database()
# self.listWidget.setCurrentItem()

def read_database(self):
"""
Lê o banco de dados qtext atual e popula a árvore.
Expand All @@ -1921,8 +1942,11 @@ def read_database(self):
print('read_database - listando de:', self.db_file)
conexao = sqlite3.connect(os.path.join(basedir, self.db_file))
c = conexao.cursor()
comando = """SELECT idx, icon, desc FROM parent"""
c.execute(comando)
try:
comando = """SELECT idx, icon, desc FROM parent"""
c.execute(comando)
except:
return self.clear_error()
parents = c.fetchall()
comando = """SELECT idx, icon, desc, rel_parent, keywords FROM child"""
c.execute(comando)
Expand Down
Binary file modified notebooks.db
Binary file not shown.

0 comments on commit 82e6d22

Please sign in to comment.