mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-02 06:13:56 +02:00
...
This commit is contained in:
parent
12271efe3d
commit
bbbcc7774e
1 changed files with 9 additions and 4 deletions
|
|
@ -106,10 +106,15 @@ def __delitem__(self, key):
|
|||
self.db.execute('DELETE FROM preferences WHERE key=?', (key,))
|
||||
|
||||
def __setitem__(self, key, val):
|
||||
if not self.disable_setting and val != self[key]:
|
||||
raw = self.to_raw(val)
|
||||
self.db.execute('INSERT OR REPLACE INTO preferences (key,val) VALUES (?,?)', (key, raw))
|
||||
dict.__setitem__(self, key, val)
|
||||
if not self.disable_setting:
|
||||
try:
|
||||
current_val = self[key]
|
||||
except KeyError:
|
||||
current_val = object()
|
||||
if val != current_val:
|
||||
raw = self.to_raw(val)
|
||||
self.db.execute('INSERT OR REPLACE INTO preferences (key,val) VALUES (?,?)', (key, raw))
|
||||
dict.__setitem__(self, key, val)
|
||||
|
||||
def set(self, key, val):
|
||||
self.__setitem__(key, val)
|
||||
|
|
|
|||
Loading…
Reference in a new issue