python-filewrap 0.3.0__tar.gz → 0.3.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.
- {python_filewrap-0.3.0 → python_filewrap-0.3.1}/PKG-INFO +1 -1
- {python_filewrap-0.3.0 → python_filewrap-0.3.1}/filewrap/__init__.py +23 -8
- {python_filewrap-0.3.0 → python_filewrap-0.3.1}/pyproject.toml +1 -1
- {python_filewrap-0.3.0 → python_filewrap-0.3.1}/LICENSE +0 -0
- {python_filewrap-0.3.0 → python_filewrap-0.3.1}/filewrap/py.typed +0 -0
- {python_filewrap-0.3.0 → python_filewrap-0.3.1}/readme.md +0 -0
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
# encoding: utf-8
|
|
3
3
|
|
|
4
4
|
__author__ = "ChenyangGao <https://chenyanggao.github.io>"
|
|
5
|
-
__version__ = (0, 3,
|
|
5
|
+
__version__ = (0, 3, 1)
|
|
6
6
|
__all__ = [
|
|
7
7
|
"SupportsRead", "SupportsReadinto", "SupportsWrite", "SupportsSeek",
|
|
8
8
|
"AsyncBufferedReader", "AsyncTextIOWrapper", "buffer_length", "to_string_buffer",
|
|
9
|
-
"to_bytes_buffer", "
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
9
|
+
"to_bytes_buffer", "to_bytes_view", "bio_chunk_iter", "bio_chunk_async_iter",
|
|
10
|
+
"bio_skip_iter", "bio_skip_async_iter", "bytes_iter", "bytes_async_iter",
|
|
11
|
+
"bytes_iter_skip", "bytes_async_iter_skip", "bytes_iter_to_reader",
|
|
12
|
+
"bytes_iter_to_async_reader", "bytes_to_chunk_iter", "bytes_to_chunk_async_iter",
|
|
13
|
+
"bytes_ensure_part_iter", "bytes_ensure_part_async_iter", "progress_bytes_iter",
|
|
14
|
+
"progress_bytes_async_iter", "copyfileobj", "copyfileobj_async", "bound_bytes_reader",
|
|
15
|
+
"bound_async_bytes_reader",
|
|
15
16
|
]
|
|
16
17
|
|
|
17
18
|
from array import array
|
|
@@ -839,7 +840,21 @@ def to_string_buffer(s: str, /) -> array:
|
|
|
839
840
|
def to_bytes_buffer(b: Buffer, /) -> bytes | bytearray | memoryview:
|
|
840
841
|
if isinstance(b, (bytes, bytearray)):
|
|
841
842
|
return b
|
|
842
|
-
|
|
843
|
+
view = memoryview(b)
|
|
844
|
+
if view.format == "B":
|
|
845
|
+
return view
|
|
846
|
+
if view.c_contiguous:
|
|
847
|
+
return view.cast("B")
|
|
848
|
+
return view.tobytes()
|
|
849
|
+
|
|
850
|
+
|
|
851
|
+
def to_bytes_view(b: Buffer, /) -> memoryview:
|
|
852
|
+
view = memoryview(b)
|
|
853
|
+
if view.format == "B":
|
|
854
|
+
return view
|
|
855
|
+
if view.c_contiguous:
|
|
856
|
+
return view.cast("B")
|
|
857
|
+
return memoryview(view.tobytes())
|
|
843
858
|
|
|
844
859
|
|
|
845
860
|
def bio_chunk_iter(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|