python-filewrap 0.2.8.1__tar.gz → 0.2.8.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.2.8.1 → python_filewrap-0.2.8.2}/PKG-INFO +4 -4
- {python_filewrap-0.2.8.1 → python_filewrap-0.2.8.2}/filewrap/__init__.py +19 -21
- {python_filewrap-0.2.8.1 → python_filewrap-0.2.8.2}/pyproject.toml +4 -4
- {python_filewrap-0.2.8.1 → python_filewrap-0.2.8.2}/LICENSE +0 -0
- {python_filewrap-0.2.8.1 → python_filewrap-0.2.8.2}/filewrap/py.typed +0 -0
- {python_filewrap-0.2.8.1 → python_filewrap-0.2.8.2}/readme.md +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: python-filewrap
|
|
3
|
-
Version: 0.2.8.
|
|
3
|
+
Version: 0.2.8.2
|
|
4
4
|
Summary: Python file wrappers.
|
|
5
|
-
Home-page: https://github.com/ChenyangGao/
|
|
5
|
+
Home-page: https://github.com/ChenyangGao/python-modules/tree/main/python-filewrap
|
|
6
6
|
License: MIT
|
|
7
7
|
Keywords: file,wrapper
|
|
8
8
|
Author: ChenyangGao
|
|
@@ -20,9 +20,9 @@ Classifier: Programming Language :: Python :: 3 :: Only
|
|
|
20
20
|
Classifier: Topic :: Software Development
|
|
21
21
|
Classifier: Topic :: Software Development :: Libraries
|
|
22
22
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
-
Requires-Dist: python-asynctools (>=0.1)
|
|
23
|
+
Requires-Dist: python-asynctools (>=0.1.3)
|
|
24
24
|
Requires-Dist: python-property (>=0.0.3)
|
|
25
|
-
Project-URL: Repository, https://github.com/ChenyangGao/
|
|
25
|
+
Project-URL: Repository, https://github.com/ChenyangGao/python-modules/tree/main/python-filewrap
|
|
26
26
|
Description-Content-Type: text/markdown
|
|
27
27
|
|
|
28
28
|
# Python file wrappers.
|
|
@@ -31,8 +31,7 @@ from asynctools import async_chain, ensure_async, ensure_aiter, run_async
|
|
|
31
31
|
from property import funcproperty
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
READ_BUFSIZE = 1 <<
|
|
35
|
-
WRITE_BUFSIZE = 1 << 16
|
|
34
|
+
READ_BUFSIZE = 1 << 16
|
|
36
35
|
CRE_NOT_UNIX_NEWLINES: Final = re_compile("\r\n|\r")
|
|
37
36
|
|
|
38
37
|
|
|
@@ -46,7 +45,7 @@ class VirtualBufferedReader:
|
|
|
46
45
|
|
|
47
46
|
@runtime_checkable
|
|
48
47
|
class SupportsRead[T](Protocol):
|
|
49
|
-
def read(self, /, size: int) -> T: ...
|
|
48
|
+
def read(self, /, size: int = -1) -> T: ...
|
|
50
49
|
|
|
51
50
|
|
|
52
51
|
@runtime_checkable
|
|
@@ -827,17 +826,16 @@ def get_bom(encoding: str, /) -> bytes:
|
|
|
827
826
|
|
|
828
827
|
|
|
829
828
|
def buffer_length(b: Buffer, /) -> int:
|
|
830
|
-
|
|
831
|
-
return len(b)
|
|
832
|
-
|
|
833
|
-
return len(memoryview(b))
|
|
829
|
+
if isinstance(b, (bytes, bytearray, memoryview)):
|
|
830
|
+
return len(b)
|
|
831
|
+
return len(memoryview(b))
|
|
834
832
|
|
|
835
833
|
|
|
836
834
|
def bio_chunk_iter(
|
|
837
835
|
bio: SupportsRead[Buffer] | SupportsReadinto | Callable[[int], Buffer],
|
|
838
836
|
/,
|
|
839
837
|
size: int = -1,
|
|
840
|
-
chunksize: int =
|
|
838
|
+
chunksize: int = READ_BUFSIZE,
|
|
841
839
|
can_buffer: bool = False,
|
|
842
840
|
callback: None | Callable[[int], Any] = None,
|
|
843
841
|
) -> Iterator[Buffer]:
|
|
@@ -906,7 +904,7 @@ async def bio_chunk_async_iter(
|
|
|
906
904
|
bio: SupportsRead[Buffer] | SupportsRead[Awaitable[Buffer]] | SupportsReadinto | Callable[[int], Buffer] | Callable[[int], Awaitable[Buffer]],
|
|
907
905
|
/,
|
|
908
906
|
size: int = -1,
|
|
909
|
-
chunksize: int =
|
|
907
|
+
chunksize: int = READ_BUFSIZE,
|
|
910
908
|
can_buffer: bool = False,
|
|
911
909
|
callback: None | Callable[[int], Any] = None,
|
|
912
910
|
) -> AsyncIterator[Buffer]:
|
|
@@ -974,7 +972,7 @@ def bio_skip_iter(
|
|
|
974
972
|
bio: SupportsRead[Buffer] | SupportsReadinto | Callable[[int], Buffer],
|
|
975
973
|
/,
|
|
976
974
|
size: int = -1,
|
|
977
|
-
chunksize: int =
|
|
975
|
+
chunksize: int = READ_BUFSIZE,
|
|
978
976
|
callback: None | Callable[[int], Any] = None,
|
|
979
977
|
) -> Iterator[int]:
|
|
980
978
|
if size == 0:
|
|
@@ -990,7 +988,7 @@ def bio_skip_iter(
|
|
|
990
988
|
length = seek(0, 2) - curpos
|
|
991
989
|
except Exception:
|
|
992
990
|
if chunksize <= 0:
|
|
993
|
-
chunksize =
|
|
991
|
+
chunksize = READ_BUFSIZE
|
|
994
992
|
if callable(bio):
|
|
995
993
|
read = bio
|
|
996
994
|
elif hasattr(bio, "readinto"):
|
|
@@ -1045,7 +1043,7 @@ async def bio_skip_async_iter(
|
|
|
1045
1043
|
bio: SupportsRead[Buffer] | SupportsRead[Awaitable[Buffer]] | SupportsReadinto | Callable[[int], Buffer] | Callable[[int], Awaitable[Buffer]],
|
|
1046
1044
|
/,
|
|
1047
1045
|
size: int = -1,
|
|
1048
|
-
chunksize: int =
|
|
1046
|
+
chunksize: int = READ_BUFSIZE,
|
|
1049
1047
|
callback: None | Callable[[int], Any] = None,
|
|
1050
1048
|
) -> AsyncIterator[int]:
|
|
1051
1049
|
if size == 0:
|
|
@@ -1061,7 +1059,7 @@ async def bio_skip_async_iter(
|
|
|
1061
1059
|
length = (await seek(0, 2)) - curpos
|
|
1062
1060
|
except Exception:
|
|
1063
1061
|
if chunksize <= 0:
|
|
1064
|
-
chunksize =
|
|
1062
|
+
chunksize = READ_BUFSIZE
|
|
1065
1063
|
if callable(bio):
|
|
1066
1064
|
read: Callable[[int], Awaitable[Buffer]] = ensure_async(bio, threaded=True)
|
|
1067
1065
|
elif hasattr(bio, "readinto"):
|
|
@@ -1558,7 +1556,7 @@ def bytes_iter_to_async_reader(
|
|
|
1558
1556
|
def bytes_to_chunk_iter(
|
|
1559
1557
|
b: Buffer,
|
|
1560
1558
|
/,
|
|
1561
|
-
chunksize: int =
|
|
1559
|
+
chunksize: int = READ_BUFSIZE,
|
|
1562
1560
|
) -> Iterator[memoryview]:
|
|
1563
1561
|
m = memoryview(b)
|
|
1564
1562
|
for i in range(0, buffer_length(m), chunksize):
|
|
@@ -1568,7 +1566,7 @@ def bytes_to_chunk_iter(
|
|
|
1568
1566
|
async def bytes_to_chunk_async_iter(
|
|
1569
1567
|
b: Buffer,
|
|
1570
1568
|
/,
|
|
1571
|
-
chunksize: int =
|
|
1569
|
+
chunksize: int = READ_BUFSIZE,
|
|
1572
1570
|
) -> AsyncIterator[memoryview]:
|
|
1573
1571
|
m = memoryview(b)
|
|
1574
1572
|
for i in range(0, buffer_length(m), chunksize):
|
|
@@ -1578,7 +1576,7 @@ async def bytes_to_chunk_async_iter(
|
|
|
1578
1576
|
def bytes_ensure_part_iter(
|
|
1579
1577
|
it: Iterable[Buffer],
|
|
1580
1578
|
/,
|
|
1581
|
-
partsize: int =
|
|
1579
|
+
partsize: int = READ_BUFSIZE,
|
|
1582
1580
|
) -> Iterator[Buffer]:
|
|
1583
1581
|
n = partsize
|
|
1584
1582
|
for b in it:
|
|
@@ -1606,7 +1604,7 @@ def bytes_ensure_part_iter(
|
|
|
1606
1604
|
async def bytes_ensure_part_async_iter(
|
|
1607
1605
|
it: Iterable[Buffer] | AsyncIterable[Buffer],
|
|
1608
1606
|
/,
|
|
1609
|
-
partsize: int =
|
|
1607
|
+
partsize: int = READ_BUFSIZE,
|
|
1610
1608
|
) -> AsyncIterator[Buffer]:
|
|
1611
1609
|
n = partsize
|
|
1612
1610
|
async for b in ensure_aiter(it):
|
|
@@ -1715,10 +1713,10 @@ def copyfileobj(
|
|
|
1715
1713
|
fsrc,
|
|
1716
1714
|
fdst: SupportsWrite[Buffer],
|
|
1717
1715
|
/,
|
|
1718
|
-
chunksize: int =
|
|
1716
|
+
chunksize: int = READ_BUFSIZE,
|
|
1719
1717
|
):
|
|
1720
1718
|
if chunksize <= 0:
|
|
1721
|
-
chunksize =
|
|
1719
|
+
chunksize = READ_BUFSIZE
|
|
1722
1720
|
fdst_write = fdst.write
|
|
1723
1721
|
fsrc_read = getattr(fsrc, "read", None)
|
|
1724
1722
|
fsrc_readinto = getattr(fsrc, "readinto", None)
|
|
@@ -1740,11 +1738,11 @@ async def copyfileobj_async(
|
|
|
1740
1738
|
fsrc,
|
|
1741
1739
|
fdst: SupportsWrite[Buffer],
|
|
1742
1740
|
/,
|
|
1743
|
-
chunksize: int =
|
|
1741
|
+
chunksize: int = READ_BUFSIZE,
|
|
1744
1742
|
threaded: bool = True,
|
|
1745
1743
|
):
|
|
1746
1744
|
if chunksize <= 0:
|
|
1747
|
-
chunksize =
|
|
1745
|
+
chunksize = READ_BUFSIZE
|
|
1748
1746
|
fdst_write = ensure_async(fdst.write, threaded=threaded)
|
|
1749
1747
|
fsrc_read = getattr(fsrc, "read", None)
|
|
1750
1748
|
fsrc_readinto = getattr(fsrc, "readinto", None)
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "python-filewrap"
|
|
3
|
-
version = "0.2.8.
|
|
3
|
+
version = "0.2.8.2"
|
|
4
4
|
description = "Python file wrappers."
|
|
5
5
|
authors = ["ChenyangGao <wosiwujm@gmail.com>"]
|
|
6
6
|
license = "MIT"
|
|
7
7
|
readme = "readme.md"
|
|
8
|
-
homepage = "https://github.com/ChenyangGao/
|
|
9
|
-
repository = "https://github.com/ChenyangGao/
|
|
8
|
+
homepage = "https://github.com/ChenyangGao/python-modules/tree/main/python-filewrap"
|
|
9
|
+
repository = "https://github.com/ChenyangGao/python-modules/tree/main/python-filewrap"
|
|
10
10
|
keywords = ["file", "wrapper"]
|
|
11
11
|
classifiers = [
|
|
12
12
|
"License :: OSI Approved :: MIT License",
|
|
@@ -27,7 +27,7 @@ include = [
|
|
|
27
27
|
|
|
28
28
|
[tool.poetry.dependencies]
|
|
29
29
|
python = "^3.12"
|
|
30
|
-
python-asynctools = ">=0.1"
|
|
30
|
+
python-asynctools = ">=0.1.3"
|
|
31
31
|
python-property = ">=0.0.3"
|
|
32
32
|
|
|
33
33
|
[build-system]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|