master.databases: style (NFC)

This commit is contained in:
Sébastien Bourdeauducq 2024-02-27 11:21:19 +08:00
parent a21805598a
commit 5e01661443
1 changed files with 7 additions and 4 deletions

View File

@ -2,7 +2,8 @@ import asyncio
import lmdb import lmdb
from sipyco.sync_struct import Notifier, process_mod, ModAction, update_from_dict from sipyco.sync_struct import (Notifier, process_mod, ModAction,
update_from_dict)
from sipyco import pyon from sipyco import pyon
from sipyco.asyncio_tools import TaskObject from sipyco.asyncio_tools import TaskObject
@ -60,7 +61,8 @@ class DatasetDB(TaskObject):
def save(self): def save(self):
with self.lmdb.begin(write=True) as txn: with self.lmdb.begin(write=True) as txn:
for key in self.pending_keys: for key in self.pending_keys:
if key not in self.data.raw_view or not self.data.raw_view[key][0]: if (key not in self.data.raw_view
or not self.data.raw_view[key][0]):
txn.delete(key.encode()) txn.delete(key.encode())
else: else:
value_and_metadata = (self.data.raw_view[key][1], value_and_metadata = (self.data.raw_view[key][1],
@ -87,7 +89,8 @@ class DatasetDB(TaskObject):
if mod["path"]: if mod["path"]:
key = mod["path"][0] key = mod["path"][0]
else: else:
assert(mod["action"] == ModAction.setitem.value or mod["action"] == ModAction.delitem.value) assert (mod["action"] == ModAction.setitem.value
or mod["action"] == ModAction.delitem.value)
key = mod["key"] key = mod["key"]
self.pending_keys.add(key) self.pending_keys.add(key)
process_mod(self.data, mod) process_mod(self.data, mod)