yoki5 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- yoki5/__init__.py +10 -0
- yoki5/_version.py +16 -0
- yoki5/attrs.py +48 -0
- yoki5/base.py +777 -0
- yoki5/mixins.py +49 -0
- yoki5/multi.py +67 -0
- yoki5/py.typed +0 -0
- yoki5/repack.py +45 -0
- yoki5/types.py +103 -0
- yoki5/utilities.py +301 -0
- yoki5-0.1.0.dist-info/LICENSE +21 -0
- yoki5-0.1.0.dist-info/METADATA +94 -0
- yoki5-0.1.0.dist-info/RECORD +15 -0
- yoki5-0.1.0.dist-info/WHEEL +5 -0
- yoki5-0.1.0.dist-info/top_level.txt +1 -0
yoki5/__init__.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""Wrapper around h5py to give easier interface around complex files."""
|
|
2
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
3
|
+
|
|
4
|
+
try:
|
|
5
|
+
__version__ = version("yoki5")
|
|
6
|
+
except PackageNotFoundError:
|
|
7
|
+
__version__ = "uninstalled"
|
|
8
|
+
|
|
9
|
+
__author__ = "Lukasz G. Migas"
|
|
10
|
+
__email__ = "lukas.migas@yahoo.com"
|
yoki5/_version.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# file generated by setuptools_scm
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
TYPE_CHECKING = False
|
|
4
|
+
if TYPE_CHECKING:
|
|
5
|
+
from typing import Tuple, Union
|
|
6
|
+
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
|
7
|
+
else:
|
|
8
|
+
VERSION_TUPLE = object
|
|
9
|
+
|
|
10
|
+
version: str
|
|
11
|
+
__version__: str
|
|
12
|
+
__version_tuple__: VERSION_TUPLE
|
|
13
|
+
version_tuple: VERSION_TUPLE
|
|
14
|
+
|
|
15
|
+
__version__ = version = '0.1.0'
|
|
16
|
+
__version_tuple__ = version_tuple = (0, 1, 0)
|
yoki5/attrs.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""Attributes."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import typing as ty
|
|
6
|
+
from contextlib import suppress
|
|
7
|
+
|
|
8
|
+
if ty.TYPE_CHECKING:
|
|
9
|
+
from yoki5.base import Store
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Attributes:
|
|
13
|
+
"""Attributes"""
|
|
14
|
+
|
|
15
|
+
def __init__(self, parent: Store):
|
|
16
|
+
self.parent = parent
|
|
17
|
+
|
|
18
|
+
def __getitem__(self, item: str) -> ty.Any:
|
|
19
|
+
"""Get attribute."""
|
|
20
|
+
with self.parent.open() as h5:
|
|
21
|
+
return h5.attrs[item]
|
|
22
|
+
|
|
23
|
+
def __contains__(self, key: str) -> bool:
|
|
24
|
+
"""Check attribute."""
|
|
25
|
+
with self.parent.open() as h5:
|
|
26
|
+
return key in h5.attrs
|
|
27
|
+
|
|
28
|
+
def __setitem__(self, key: str, value: ty.Any) -> None:
|
|
29
|
+
"""Set attribute."""
|
|
30
|
+
self.parent.check_can_write()
|
|
31
|
+
with self.parent.open() as h5:
|
|
32
|
+
h5.attrs[key] = value
|
|
33
|
+
h5.flush()
|
|
34
|
+
|
|
35
|
+
def to_dict(self) -> dict[str, ty.Any]:
|
|
36
|
+
"""Return all attributes."""
|
|
37
|
+
attrs = {}
|
|
38
|
+
with self.parent.open() as h5:
|
|
39
|
+
keys = list(h5.attrs.keys())
|
|
40
|
+
for key in keys:
|
|
41
|
+
attrs[key] = h5.attrs[key]
|
|
42
|
+
return attrs
|
|
43
|
+
|
|
44
|
+
def get(self, key: str, default: ty.Any = None) -> ty.Any:
|
|
45
|
+
"""Get attribute if it exists."""
|
|
46
|
+
with suppress(KeyError):
|
|
47
|
+
return self[key]
|
|
48
|
+
return default
|