python-filewrap 0.0.7__tar.gz → 0.0.7.2__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.0.7 → python_filewrap-0.0.7.2}/PKG-INFO +1 -1
- {python_filewrap-0.0.7 → python_filewrap-0.0.7.2}/filewrap/__init__.py +14 -7
- {python_filewrap-0.0.7 → python_filewrap-0.0.7.2}/pyproject.toml +1 -1
- {python_filewrap-0.0.7 → python_filewrap-0.0.7.2}/LICENSE +0 -0
- {python_filewrap-0.0.7 → python_filewrap-0.0.7.2}/filewrap/py.typed +0 -0
- {python_filewrap-0.0.7 → python_filewrap-0.0.7.2}/readme.md +0 -0
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
__author__ = "ChenyangGao <https://chenyanggao.github.io>"
|
|
5
5
|
__version__ = (0, 0, 7)
|
|
6
6
|
__all__ = [
|
|
7
|
-
"SupportsRead", "SupportsWrite",
|
|
7
|
+
"SupportsRead", "SupportsWrite", "SupportsSeek",
|
|
8
8
|
"bio_chunk_iter", "bio_chunk_async_iter",
|
|
9
9
|
"bio_skip_iter", "bio_skip_async_iter",
|
|
10
10
|
"bytes_iter_skip", "bytes_async_iter_skip",
|
|
@@ -14,14 +14,13 @@ __all__ = [
|
|
|
14
14
|
]
|
|
15
15
|
|
|
16
16
|
from asyncio import to_thread, Lock as AsyncLock
|
|
17
|
-
from collections.abc import Awaitable, AsyncIterable, Iterable
|
|
17
|
+
from collections.abc import Awaitable, AsyncIterable, AsyncIterator, Callable, Iterable, Iterator
|
|
18
18
|
from functools import update_wrapper
|
|
19
19
|
from inspect import isawaitable, iscoroutinefunction
|
|
20
20
|
from itertools import chain
|
|
21
|
-
from collections.abc import AsyncIterator, Callable, Iterator
|
|
22
21
|
from shutil import COPY_BUFSIZE # type: ignore
|
|
23
22
|
from threading import Lock
|
|
24
|
-
from typing import Any, Protocol, TypeVar
|
|
23
|
+
from typing import runtime_checkable, Any, Protocol, TypeVar
|
|
25
24
|
|
|
26
25
|
try:
|
|
27
26
|
from collections.abc import Buffer # type: ignore
|
|
@@ -35,12 +34,19 @@ _T_co = TypeVar("_T_co", covariant=True)
|
|
|
35
34
|
_T_contra = TypeVar("_T_contra", contravariant=True)
|
|
36
35
|
|
|
37
36
|
|
|
37
|
+
@runtime_checkable
|
|
38
38
|
class SupportsRead(Protocol[_T_co]):
|
|
39
|
-
def read(self, __length: int = ...) -> _T_co: ...
|
|
39
|
+
def read(self, /, __length: int = ...) -> _T_co: ...
|
|
40
40
|
|
|
41
41
|
|
|
42
|
+
@runtime_checkable
|
|
42
43
|
class SupportsWrite(Protocol[_T_contra]):
|
|
43
|
-
def write(self, __s: _T_contra) -> object: ...
|
|
44
|
+
def write(self, /, __s: _T_contra) -> object: ...
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@runtime_checkable
|
|
48
|
+
class SupportsSeek(Protocol[_T_contra]):
|
|
49
|
+
def seek(self, /, __offset: int, __whence: int = 0) -> int: ...
|
|
44
50
|
|
|
45
51
|
|
|
46
52
|
def bio_chunk_iter(
|
|
@@ -185,6 +191,7 @@ async def bio_skip_async_iter(
|
|
|
185
191
|
if size == 0:
|
|
186
192
|
return
|
|
187
193
|
callback = ensure_async(callback) if callable(callback) else None
|
|
194
|
+
length: int
|
|
188
195
|
try:
|
|
189
196
|
seek = ensure_async(getattr(bio, "seek"))
|
|
190
197
|
curpos = await seek(0, 1)
|
|
@@ -269,7 +276,7 @@ def bytes_iter_skip(
|
|
|
269
276
|
|
|
270
277
|
|
|
271
278
|
async def bytes_async_iter_skip(
|
|
272
|
-
it: Iterable[Buffer] |
|
|
279
|
+
it: Iterable[Buffer] | AsyncIterable[Buffer],
|
|
273
280
|
/,
|
|
274
281
|
size: int = -1,
|
|
275
282
|
callback: None | Callable[[int], Any] = None,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|