python-filewrap 0.0.7.1__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.1 → python_filewrap-0.0.7.2}/PKG-INFO +1 -1
- {python_filewrap-0.0.7.1 → python_filewrap-0.0.7.2}/filewrap/__init__.py +11 -6
- {python_filewrap-0.0.7.1 → python_filewrap-0.0.7.2}/pyproject.toml +1 -1
- {python_filewrap-0.0.7.1 → python_filewrap-0.0.7.2}/LICENSE +0 -0
- {python_filewrap-0.0.7.1 → python_filewrap-0.0.7.2}/filewrap/py.typed +0 -0
- {python_filewrap-0.0.7.1 → 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,11 +14,10 @@ __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
23
|
from typing import runtime_checkable, Any, Protocol, TypeVar
|
|
@@ -37,12 +36,17 @@ _T_contra = TypeVar("_T_contra", contravariant=True)
|
|
|
37
36
|
|
|
38
37
|
@runtime_checkable
|
|
39
38
|
class SupportsRead(Protocol[_T_co]):
|
|
40
|
-
def read(self, __length: int = ...) -> _T_co: ...
|
|
39
|
+
def read(self, /, __length: int = ...) -> _T_co: ...
|
|
41
40
|
|
|
42
41
|
|
|
43
42
|
@runtime_checkable
|
|
44
43
|
class SupportsWrite(Protocol[_T_contra]):
|
|
45
|
-
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: ...
|
|
46
50
|
|
|
47
51
|
|
|
48
52
|
def bio_chunk_iter(
|
|
@@ -187,6 +191,7 @@ async def bio_skip_async_iter(
|
|
|
187
191
|
if size == 0:
|
|
188
192
|
return
|
|
189
193
|
callback = ensure_async(callback) if callable(callback) else None
|
|
194
|
+
length: int
|
|
190
195
|
try:
|
|
191
196
|
seek = ensure_async(getattr(bio, "seek"))
|
|
192
197
|
curpos = await seek(0, 1)
|
|
@@ -271,7 +276,7 @@ def bytes_iter_skip(
|
|
|
271
276
|
|
|
272
277
|
|
|
273
278
|
async def bytes_async_iter_skip(
|
|
274
|
-
it: Iterable[Buffer] |
|
|
279
|
+
it: Iterable[Buffer] | AsyncIterable[Buffer],
|
|
275
280
|
/,
|
|
276
281
|
size: int = -1,
|
|
277
282
|
callback: None | Callable[[int], Any] = None,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|