-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVocabularyModel.py
53 lines (39 loc) · 1.52 KB
/
VocabularyModel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import sqlite_backend
import ingles_exceptions as ingles_exc
class VocabularyModel(object):
def __init__(self):
self._table_name = 'diccionary'
self._connection = sqlite_backend.connect_to_db(sqlite_backend.DB_name)
self._ids = sqlite_backend.restartIds(self._connection, self._table_name)
self._idsFails = list()
@property
def connection(self):
return self._connection
@property
def table_name(self):
return self._table_name
@property
def ids(self):
return self._ids
def idsFails(self):
return self._idsFails
def updateIds(self):
self._ids.clear()
self._ids = self._idsFails[:]
self._idsFails.clear()
def setAddIdsFails(self, addId):
print("addidsFails",addId)
self._idsFails.append(addId)
print("idsFails: ", self._idsFails)
def createWord(self, word, translation):
sqlite_backend.insert(self.connection, word, translation, table_name = self._table_name)
self.restartIds()
def restartIds(self):
self._ids.clear()
self._idsFails.clear()
self._ids = sqlite_backend.restartIds(self.connection, self.table_name)
def readWord(self, id_word):
self.ids.remove(id_word)
return sqlite_backend.select(self.connection, id_word, table_name = self._table_name)
def getSize(self):
return sqlite_backend.selectSize(self.connection, table_name = self._table_name)