usawa

Signed, immutable accounting.
Log | Files | Refs | Submodules | LICENSE

commit c1319b7331c50f433684b266a4912cc93198ef10
parent 98cff8e039832040fa3fd55730724ada01312e05
Author: lash <dev@holbrook.no>
Date:   Sun, 24 May 2026 10:30:37 -0600

Factor out linkstore part, bump version

Diffstat:
Mdummy/setup.cfg | 2+-
Mdummy/usawa/store.py | 47+++++++++++++++++++++++++----------------------
2 files changed, 26 insertions(+), 23 deletions(-)

diff --git a/dummy/setup.cfg b/dummy/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = usawa -version = 0.3.1 +version = 0.3.2 description = Signed, immutable accounting. author = Louis Holbrook author_email = dev@holbrook.no diff --git a/dummy/usawa/store.py b/dummy/usawa/store.py @@ -273,8 +273,32 @@ class AssetStore(BaseStore): return Asset.deserialize(v, k[1:]) -class EntryStore(KeyStore): +class LinkStore(BaseStore): + + def put_link(self, link, refs=None): + if refs == None: + refs = link.refs() + elif isinstance(refs, str): + refs = [refs] + for ref in refs: + v = link.serialize_for(ref) + k = pfx_entry_link(ref) + self.db.put(k, v, exist_ok=True) + + + def get_link(self, link, refs=None): + if isinstance(refs, str): + refs = [refs] + elif refs == None: + raise NotImplementedError('load all links not implemented yet') + for ref in refs: + k = pfx_entry_link(ref) + v = self.db.get(k) + link.deserialize_for(ref, v) + + +class EntryStore(KeyStore, LinkStore): # TODO: this will overwrite the draft when the entry has a serial, but on check is being performed that the ledger entry was actually added. def put_draft(self, entry): @@ -346,27 +370,6 @@ class EntryStore(KeyStore): return entry - def put_link(self, link, refs=None): - if refs == None: - refs = link.refs() - elif isinstance(refs, str): - refs = [refs] - for ref in refs: - v = link.serialize_for(ref) - k = pfx_entry_link(ref) - self.db.put(k, v, exist_ok=True) - - - def get_link(self, link, refs=None): - if isinstance(refs, str): - refs = [refs] - elif link == None or refs == None: - raise NotImplementedError('load all links not implemented yet') - for ref in refs: - k = pfx_entry_link(ref) - v = self.db.get(k) - link.deserialize_for(ref, v) - #class LedgerStore(EntryStore, AssetStore, KeyStore):