master.databases: style (NFC)

This commit is contained in:
Sébastien Bourdeauducq 2024-02-27 11:21:19 +08:00
parent a21805598a
commit 5e01661443

View File

@ -2,7 +2,8 @@ import asyncio
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.asyncio_tools import TaskObject
@ -60,7 +61,8 @@ class DatasetDB(TaskObject):
def save(self):
with self.lmdb.begin(write=True) as txn:
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())
else:
value_and_metadata = (self.data.raw_view[key][1],
@ -87,7 +89,8 @@ class DatasetDB(TaskObject):
if mod["path"]:
key = mod["path"][0]
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"]
self.pending_keys.add(key)
process_mod(self.data, mod)