Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
tedlaz committed Feb 9, 2018
1 parent 2655133 commit ad784fd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
9 changes: 8 additions & 1 deletion sofos/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 2 additions & 4 deletions sofos/qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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())

Expand Down
5 changes: 2 additions & 3 deletions sofos/templates/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit ad784fd

Please sign in to comment.