From ad784fdb8bfdd435b6033a9bfa5a79ff66510afd Mon Sep 17 00:00:00 2001 From: Ted Lazaros Date: Fri, 9 Feb 2018 13:13:32 +0200 Subject: [PATCH] minor --- sofos/database.py | 9 ++++++++- sofos/qt.py | 6 ++---- sofos/templates/main.py | 5 ++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/sofos/database.py b/sofos/database.py index 0432f19..98c795f 100644 --- a/sofos/database.py +++ b/sofos/database.py @@ -10,8 +10,13 @@ class Database(): """Database Class""" def __init__(self, models, dbf=None): + """Initialize + + :param models: user models module + :param dbf: database file + """ self.models = models - self.dbf = dbf + self.dbf = dbf if self.set_database(dbf) else None def set_database(self, dbf): """Set database if compatible @@ -20,6 +25,8 @@ def set_database(self, dbf): :return: True or False. """ + if not dbf: + return False if self.is_database_compatible(dbf): self.dbf = dbf return True diff --git a/sofos/qt.py b/sofos/qt.py index be29b51..d414afa 100644 --- a/sofos/qt.py +++ b/sofos/qt.py @@ -515,8 +515,8 @@ def _save(self): else: Qw.QMessageBox.information(self, "Save", lid) - def userFriendlyCurrentFile(self): - return self.table + # def userFriendlyCurrentFile(self): + # return self.table class FindForm(AutoForm): @@ -787,8 +787,6 @@ def _find(self, text): text, self) if ffind.exec_() == Qw.QDialog.Accepted: self.set(ffind.id) - else: - self._set_state(1 if self.txt == self.text.text() else 0) else: self.valNotFound.emit(self.text.text()) diff --git a/sofos/templates/main.py b/sofos/templates/main.py index 8d675a3..eea70af 100644 --- a/sofos/templates/main.py +++ b/sofos/templates/main.py @@ -8,12 +8,11 @@ import main_rc from sofos import qt from sofos import database -from sofos import dbf from settings import setup import models as md qt.CONFIRMATIONS = setup['confirmations'] BDIR = os.path.dirname(md.__file__) -INIT_DB_DATA = os.path.join(BDIR, 'init_db.sql') +INIT_DB = os.path.join(BDIR, 'init_db.sql') class MainWindow(Qw.QMainWindow): @@ -56,7 +55,7 @@ def newFile(self): if filename: if not filename.endswith('.%s' % setup['db_suffix']): filename = '%s.%s' % (filename, setup['db_suffix']) - success, msg = self.database.create_database(filename, INIT_DB_DATA) + success, msg = self.database.create_database(filename, INIT_DB) if success: self.update_dbf(self.database.dbf) Qw.QMessageBox.information(