From 4d0ce7fb62eaad3a1f705ec3c77744e3ebc96a9e Mon Sep 17 00:00:00 2001 From: Matthias Baumgartner Date: Sun, 29 Jan 2023 11:31:16 +0100 Subject: session actions port --- tagit/widgets/session.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'tagit/widgets') diff --git a/tagit/widgets/session.py b/tagit/widgets/session.py index f45ab35..e97a688 100644 --- a/tagit/widgets/session.py +++ b/tagit/widgets/session.py @@ -5,7 +5,7 @@ A copy of the license is provided with the project. Author: Matthias Baumgartner, 2022 """ # standard imports -from threading import current_thread +import os import typing # kivy imports @@ -16,8 +16,7 @@ import kivy.properties as kp # tagit imports from tagit import parsing from tagit.config.loader import load_settings -#from tagit.storage.broker import Broker # FIXME: mb/port -#from tagit.storage.loader import load_broker, load_log # FIXME: mb/port +from tagit.utils import bsfs # exports __all__: typing.Sequence[str] = ( @@ -63,10 +62,20 @@ class Session(Widget): def load(self, cfg): """Load the session from configuration *cfg*.""" - self.cfg = cfg + #self.log = load_log(cfg) # FIXME: mb/port # initialize storages from config - self.log = load_log(cfg) - self.storage = load_broker(cfg) + # open BSFS storage + store = bsfs.Open(cfg('session', 'bsfs')) + # check storage schema + # FIXME: how to properly load the required schema? + with open(os.path.join(os.path.dirname(__file__), '..', 'apps', 'port-schema.nt'), 'rt') as ifile: + required_schema = bsfs.schema.from_string(ifile.read()) + # FIXME: Since the store isn't persistent, we migrate to the required one here. + #if not required_schema <= store.schema: + # raise Exception('') + store.migrate(required_schema) + # replace current with new storage + self.storage = store def update_settings_key(self, key, value): # change setting -- cgit v1.2.3