bier 0.0.1__tar.gz

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.
Files changed (46) hide show
  1. bier-0.0.1/LICENSE +21 -0
  2. bier-0.0.1/MANIFEST.in +4 -0
  3. bier-0.0.1/PKG-INFO +87 -0
  4. bier-0.0.1/README.md +69 -0
  5. bier-0.0.1/bier/EndianedBinaryIO/C/EndianedBytesIO.pyi +3 -0
  6. bier-0.0.1/bier/EndianedBinaryIO/C/EndianedIOBase.pyi +3 -0
  7. bier-0.0.1/bier/EndianedBinaryIO/C/EndianedStreamIO.pyi +3 -0
  8. bier-0.0.1/bier/EndianedBinaryIO/C/__init__.py +4 -0
  9. bier-0.0.1/bier/EndianedBinaryIO/EndianedBufferedReader.py +14 -0
  10. bier-0.0.1/bier/EndianedBinaryIO/EndianedBufferedWriter.py +14 -0
  11. bier-0.0.1/bier/EndianedBinaryIO/EndianedBytesIO.py +14 -0
  12. bier-0.0.1/bier/EndianedBinaryIO/EndianedFileIO.py +25 -0
  13. bier-0.0.1/bier/EndianedBinaryIO/EndianedIOBase.py +825 -0
  14. bier-0.0.1/bier/EndianedBinaryIO/EndianedStreamIO.py +55 -0
  15. bier-0.0.1/bier/EndianedBinaryIO/__init__.py +11 -0
  16. bier-0.0.1/bier/EndianedBinaryIO/_structs.py +39 -0
  17. bier-0.0.1/bier/__init__.py +10 -0
  18. bier-0.0.1/bier/serialization/BinarySerializable.py +214 -0
  19. bier-0.0.1/bier/serialization/Serializable.py +60 -0
  20. bier-0.0.1/bier/serialization/TypeNode.py +350 -0
  21. bier-0.0.1/bier/serialization/__init__.py +38 -0
  22. bier-0.0.1/bier/serialization/_typing_helpers.py +44 -0
  23. bier-0.0.1/bier/serialization/builtin_aliases.py +23 -0
  24. bier-0.0.1/bier/serialization/builtins.py +50 -0
  25. bier-0.0.1/bier/serialization/options.py +108 -0
  26. bier-0.0.1/bier.egg-info/PKG-INFO +87 -0
  27. bier-0.0.1/bier.egg-info/SOURCES.txt +44 -0
  28. bier-0.0.1/bier.egg-info/dependency_links.txt +1 -0
  29. bier-0.0.1/bier.egg-info/requires.txt +8 -0
  30. bier-0.0.1/bier.egg-info/top_level.txt +2 -0
  31. bier-0.0.1/pyproject.toml +44 -0
  32. bier-0.0.1/setup.cfg +4 -0
  33. bier-0.0.1/setup.py +55 -0
  34. bier-0.0.1/src/EndianedBinaryIO/EndianedBytesIO.cpp +1129 -0
  35. bier-0.0.1/src/EndianedBinaryIO/EndianedIOBase.cpp +284 -0
  36. bier-0.0.1/src/EndianedBinaryIO/EndianedIOBase.hpp +169 -0
  37. bier-0.0.1/src/EndianedBinaryIO/EndianedStreamIO.cpp +968 -0
  38. bier-0.0.1/src/EndianedBinaryIO/PyConverter.hpp +223 -0
  39. bier-0.0.1/src/EndianedBinaryIO/PyFloat_Half.cpp +176 -0
  40. bier-0.0.1/src/EndianedBinaryIO/PyFloat_Half.hpp +77 -0
  41. bier-0.0.1/tests/EndianedBinaryIO/EndianedIOTestHelper.py +279 -0
  42. bier-0.0.1/tests/EndianedBinaryIO/EndianedIO_test.py +92 -0
  43. bier-0.0.1/tests/EndianedBinaryIO/__init__.py +0 -0
  44. bier-0.0.1/tests/__init__.py +0 -0
  45. bier-0.0.1/tests/serialization/TypeNode_test.py +255 -0
  46. bier-0.0.1/tests/serialization/__init__.py +0 -0
bier-0.0.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Rudolf Kolbe (K0lb3)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
bier-0.0.1/MANIFEST.in ADDED
@@ -0,0 +1,4 @@
1
+ recursive-include src *.cpp
2
+ recursive-include src *.hpp
3
+ recursive-include src *.c
4
+ recursive-include src *.h
bier-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,87 @@
1
+ Metadata-Version: 2.4
2
+ Name: bier
3
+ Version: 0.0.1
4
+ Author-email: Rudolf Kolbe <rkolbe96@gmail.com>
5
+ License: MIT
6
+ Project-URL: Homepage, https://github.com/K0lb3/bier
7
+ Project-URL: Bug Tracker, https://github.com/K0lb3/bier/issues
8
+ Requires-Python: >=3.8
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Provides-Extra: tests
12
+ Requires-Dist: pytest; extra == "tests"
13
+ Provides-Extra: dev
14
+ Requires-Dist: ruff; extra == "dev"
15
+ Requires-Dist: pre-commit; extra == "dev"
16
+ Requires-Dist: bier[tests]; extra == "dev"
17
+ Dynamic: license-file
18
+
19
+ # BInaryhelpER
20
+
21
+ A small python package to make binary serialization faster and easier.
22
+
23
+ modules:
24
+
25
+ - EndianedBinaryIO - for parsing and writing streamed binary data.
26
+ - ComplexStreams (TODO)
27
+ - BlockStream - for more performant handling of e.g. streams consisting of compressed and/or encrypted blocks
28
+ - MultiStream - for handling concatent streams as single streams
29
+ - struct (TODO) - extrend struct module with additional features
30
+ - c - null terminated string
31
+ - v - varint
32
+ - () - tuples (groups)
33
+ - x\*y - read an x, then read x times y (e.g. i*s for strings with their lengths described with a prior int)
34
+ - serialization - annotation based class serialization
35
+
36
+ ## Serialization
37
+
38
+ ### BinarySerializable
39
+
40
+ __Annotation Types__
41
+ - ints:
42
+ - u8
43
+ - u16
44
+ - u32
45
+ - u64
46
+ - i8
47
+ - i16
48
+ - i32
49
+ - i64
50
+ - floats:
51
+ - f16
52
+ - f32
53
+ - f64
54
+ - strings:
55
+ - cstr (null terminated string)
56
+ - str (default delimited length)
57
+ - str_d[T] (delimited length of type T)
58
+ - lists:
59
+ - list[S] (default delimited length)
60
+ - list_d[S, T] (delimited length of type T)
61
+ - tuples:
62
+ - tuple[T1, T2, ...]
63
+ - objects
64
+ - class (has to inherit from BinarySerializible as well)
65
+ - bytes:
66
+ - bytes (default delimited length)
67
+ - bytes_d[T] (delimited length of type T)
68
+
69
+ __Example__
70
+ ```py
71
+ class MyStruct(BinarySerializable):
72
+ field1: u8
73
+ field2: cstr
74
+ field3: str_d[u16]
75
+ field4: list_d[f32, u8]
76
+ field5: list_d[list_d[u16, u8], u8]
77
+ field6: tuple[u8, u16]
78
+
79
+ class MyStruct2(BinarySerializable):
80
+ field1: MyStruct
81
+ field2: list_d["MyStruct2", u8]
82
+
83
+
84
+ class MyStruct3(BinarySerializable[u32]):
85
+ field: str
86
+ field2: list[tuple[f16, f16, f16]]
87
+ ```
bier-0.0.1/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # BInaryhelpER
2
+
3
+ A small python package to make binary serialization faster and easier.
4
+
5
+ modules:
6
+
7
+ - EndianedBinaryIO - for parsing and writing streamed binary data.
8
+ - ComplexStreams (TODO)
9
+ - BlockStream - for more performant handling of e.g. streams consisting of compressed and/or encrypted blocks
10
+ - MultiStream - for handling concatent streams as single streams
11
+ - struct (TODO) - extrend struct module with additional features
12
+ - c - null terminated string
13
+ - v - varint
14
+ - () - tuples (groups)
15
+ - x\*y - read an x, then read x times y (e.g. i*s for strings with their lengths described with a prior int)
16
+ - serialization - annotation based class serialization
17
+
18
+ ## Serialization
19
+
20
+ ### BinarySerializable
21
+
22
+ __Annotation Types__
23
+ - ints:
24
+ - u8
25
+ - u16
26
+ - u32
27
+ - u64
28
+ - i8
29
+ - i16
30
+ - i32
31
+ - i64
32
+ - floats:
33
+ - f16
34
+ - f32
35
+ - f64
36
+ - strings:
37
+ - cstr (null terminated string)
38
+ - str (default delimited length)
39
+ - str_d[T] (delimited length of type T)
40
+ - lists:
41
+ - list[S] (default delimited length)
42
+ - list_d[S, T] (delimited length of type T)
43
+ - tuples:
44
+ - tuple[T1, T2, ...]
45
+ - objects
46
+ - class (has to inherit from BinarySerializible as well)
47
+ - bytes:
48
+ - bytes (default delimited length)
49
+ - bytes_d[T] (delimited length of type T)
50
+
51
+ __Example__
52
+ ```py
53
+ class MyStruct(BinarySerializable):
54
+ field1: u8
55
+ field2: cstr
56
+ field3: str_d[u16]
57
+ field4: list_d[f32, u8]
58
+ field5: list_d[list_d[u16, u8], u8]
59
+ field6: tuple[u8, u16]
60
+
61
+ class MyStruct2(BinarySerializable):
62
+ field1: MyStruct
63
+ field2: list_d["MyStruct2", u8]
64
+
65
+
66
+ class MyStruct3(BinarySerializable[u32]):
67
+ field: str
68
+ field2: list[tuple[f16, f16, f16]]
69
+ ```
@@ -0,0 +1,3 @@
1
+ from ..EndianedBytesIO import EndianedBytesIO
2
+
3
+ __all__ = ["EndianedBytesIO"]
@@ -0,0 +1,3 @@
1
+ from ..EndianedIOBase import EndianedIOBase
2
+
3
+ __all__ = ["EndianedIOBase"]
@@ -0,0 +1,3 @@
1
+ from ..EndianedStreamIO import EndianedStreamIO
2
+
3
+ __all__ = ["EndianedStreamIO"]
@@ -0,0 +1,4 @@
1
+ from .EndianedBytesIO import EndianedBytesIO as EndianedBytesIO
2
+ from .EndianedStreamIO import EndianedStreamIO as EndianedStreamIO
3
+ # disabled for now, because it is slower than the pure python version
4
+ # from .EndianedIOBase import EndianedIOBase as EndianedIOBase
@@ -0,0 +1,14 @@
1
+ from io import BufferedReader, RawIOBase
2
+
3
+ from .EndianedIOBase import EndianedIOBase, Endianess
4
+
5
+
6
+ class EndianedBufferedReader(BufferedReader, EndianedIOBase):
7
+ def __init__(
8
+ self, raw: RawIOBase, buffer_size: int = 8192, endian: Endianess = "<"
9
+ ) -> None:
10
+ BufferedReader.__init__(self, raw, buffer_size)
11
+ self.endian = endian
12
+
13
+
14
+ __all__ = ("EndianedBufferedReader",)
@@ -0,0 +1,14 @@
1
+ from io import BufferedWriter, RawIOBase
2
+
3
+ from .EndianedIOBase import EndianedIOBase, Endianess
4
+
5
+
6
+ class EndianedBufferedWriter(BufferedWriter, EndianedIOBase):
7
+ def __init__(
8
+ self, raw: RawIOBase, buffer_size: int = 8192, endian: Endianess = "<"
9
+ ) -> None:
10
+ BufferedWriter.__init__(self, raw, buffer_size)
11
+ self.endian = endian
12
+
13
+
14
+ __all__ = ("EndianedBufferedWriter",)
@@ -0,0 +1,14 @@
1
+ from io import BytesIO
2
+
3
+ from collections.abc import Buffer
4
+
5
+ from .EndianedIOBase import EndianedIOBase, Endianess
6
+
7
+
8
+ class EndianedBytesIO(BytesIO, EndianedIOBase):
9
+ def __init__(self, initial_bytes: Buffer = b"", endian: Endianess = "<") -> None:
10
+ BytesIO.__init__(self, initial_bytes)
11
+ self.endian = endian
12
+
13
+
14
+ __all__ = ("EndianedBytesIO",)
@@ -0,0 +1,25 @@
1
+ from io import FileIO
2
+ from os import PathLike
3
+ from typing import Callable, Optional, Union
4
+
5
+ from .EndianedIOBase import EndianedIOBase, Endianess
6
+
7
+ StrOrBytesPath = Union[str, bytes, PathLike[str], PathLike[bytes]]
8
+ FileDescriptorOrPath = Union[int, StrOrBytesPath]
9
+ _Opener = Callable[[str, int], int]
10
+
11
+
12
+ class EndianedFileIO(FileIO, EndianedIOBase):
13
+ def __init__(
14
+ self,
15
+ file: FileDescriptorOrPath,
16
+ mode: str = "r",
17
+ closefd: bool = True,
18
+ opener: Optional[_Opener] = None,
19
+ endian: Endianess = "<",
20
+ ) -> None:
21
+ FileIO.__init__(self, file, mode, closefd, opener)
22
+ self.endian = endian
23
+
24
+
25
+ __all__ = ("EndianedFileIO",)