diff options
author | Matthias Baumgartner <dev@igsor.net> | 2023-01-13 09:49:10 +0100 |
---|---|---|
committer | Matthias Baumgartner <dev@igsor.net> | 2023-01-13 09:49:10 +0100 |
commit | 9c366758665d9cfee7796ee45a8167a5412ae9ae (patch) | |
tree | b42e0a1fd4b1bd59fc31fad6267b83c2dc9a3a3b /tagit/utils | |
parent | 8f2f697f7ed52b7e1c7a17411b2de526b6490691 (diff) | |
download | tagit-9c366758665d9cfee7796ee45a8167a5412ae9ae.tar.gz tagit-9c366758665d9cfee7796ee45a8167a5412ae9ae.tar.bz2 tagit-9c366758665d9cfee7796ee45a8167a5412ae9ae.zip |
filter early port, parsing adaptions
Diffstat (limited to 'tagit/utils')
-rw-r--r-- | tagit/utils/__init__.py | 1 | ||||
-rw-r--r-- | tagit/utils/bsfs.py | 10 | ||||
-rw-r--r-- | tagit/utils/namespaces.py | 30 | ||||
-rw-r--r-- | tagit/utils/shared.py | 12 |
4 files changed, 52 insertions, 1 deletions
diff --git a/tagit/utils/__init__.py b/tagit/utils/__init__.py index 3f09078..16dcd4d 100644 --- a/tagit/utils/__init__.py +++ b/tagit/utils/__init__.py @@ -9,6 +9,7 @@ import typing # inner-module imports from . import bsfs +from . import namespaces as ns from . import time as ttime from .frame import Frame from .shared import * # FIXME: port properly diff --git a/tagit/utils/bsfs.py b/tagit/utils/bsfs.py index 0ab90a9..d80efe0 100644 --- a/tagit/utils/bsfs.py +++ b/tagit/utils/bsfs.py @@ -8,8 +8,16 @@ Author: Matthias Baumgartner, 2022 import typing # bsfs imports +from bsfs import schema, Open +from bsfs.query import ast +from bsfs.namespace import Namespace # exports -__all__: typing.Sequence[str] = [] +__all__: typing.Sequence[str] = ( + 'Namespace', + 'Open', + 'ast', + 'schema', + ) ## EOF ## diff --git a/tagit/utils/namespaces.py b/tagit/utils/namespaces.py new file mode 100644 index 0000000..dd26eef --- /dev/null +++ b/tagit/utils/namespaces.py @@ -0,0 +1,30 @@ +"""Default namespaces used throughout tagit. + +Part of the tagit module. +A copy of the license is provided with the project. +Author: Matthias Baumgartner, 2022 +""" +# standard imports +import typing + +# inner-module imports +from . import bsfs as _bsfs + +# constants +bse = _bsfs.Namespace('http://bsfs.ai/schema/Entity') +bsfs = _bsfs.Namespace('http://bsfs.ai/schema', fsep='/') +bsm = _bsfs.Namespace('http://bsfs.ai/schema/Meta') +bst = _bsfs.Namespace('http://bsfs.ai/schema/Tag') +xsd = _bsfs.Namespace('http://www.w3.org/2001/XMLSchema') + +# export +__all__: typing.Sequence[str] = ( + 'bse', + 'bsfs', + 'bsm', + 'xsd', + ) + +## EOF ## + + diff --git a/tagit/utils/shared.py b/tagit/utils/shared.py index 0d496ed..b5ab421 100644 --- a/tagit/utils/shared.py +++ b/tagit/utils/shared.py @@ -28,6 +28,7 @@ __all__: typing.Sequence[str] = ( 'is_list', 'magnitude_fmt', 'truncate_dir', + 'get_root', ) @@ -140,4 +141,15 @@ def fileopen(pth): except KeyError: warnings.warn('Unknown platform {}'.format(platform.system())) + +def get_root(obj): + """Traverse the widget tree upwards until the root is found.""" + while obj.parent is not None and obj.parent != obj.parent.parent: + if hasattr(obj, 'root') and obj.root is not None: + return obj.root + + obj = obj.parent + + return obj + ## EOF ## |