python-filewrap 0.2.7.1__tar.gz → 0.2.8__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.7.1 → python_filewrap-0.2.8}/PKG-INFO +1 -1
- {python_filewrap-0.2.7.1 → python_filewrap-0.2.8}/filewrap/__init__.py +42 -50
- {python_filewrap-0.2.7.1 → python_filewrap-0.2.8}/pyproject.toml +1 -1
- {python_filewrap-0.2.7.1 → python_filewrap-0.2.8}/LICENSE +0 -0
- {python_filewrap-0.2.7.1 → python_filewrap-0.2.8}/filewrap/py.typed +0 -0
- {python_filewrap-0.2.7.1 → python_filewrap-0.2.8}/readme.md +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# encoding: utf-8
|
|
3
3
|
|
|
4
4
|
__author__ = "ChenyangGao <https://chenyanggao.github.io>"
|
|
5
|
-
__version__ = (0, 2,
|
|
5
|
+
__version__ = (0, 2, 8)
|
|
6
6
|
__all__ = [
|
|
7
7
|
"SupportsRead", "SupportsReadinto", "SupportsWrite", "SupportsSeek",
|
|
8
8
|
"AsyncBufferedReader", "AsyncTextIOWrapper", "buffer_length",
|
|
@@ -1275,28 +1275,28 @@ def bytes_iter_to_reader(
|
|
|
1275
1275
|
if at_end or not (bufsize := buffer_length(buf)):
|
|
1276
1276
|
return 0
|
|
1277
1277
|
with lock:
|
|
1278
|
-
n
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1278
|
+
if n := buffer_length(unconsumed):
|
|
1279
|
+
if bufsize <= n:
|
|
1280
|
+
buf[:], unconsumed = unconsumed[:bufsize], unconsumed[bufsize:]
|
|
1281
|
+
pos += bufsize
|
|
1282
|
+
return bufsize
|
|
1283
|
+
buf[:n] = unconsumed
|
|
1284
|
+
pos += n
|
|
1285
|
+
del unconsumed[:]
|
|
1285
1286
|
try:
|
|
1286
1287
|
while True:
|
|
1287
|
-
b
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
n = m
|
|
1288
|
+
if b := memoryview(getnext()):
|
|
1289
|
+
m = n + len(b)
|
|
1290
|
+
if m >= bufsize:
|
|
1291
|
+
delta = bufsize - n
|
|
1292
|
+
buf[n:] = b[:delta]
|
|
1293
|
+
unconsumed += b[delta:]
|
|
1294
|
+
pos += delta
|
|
1295
|
+
return bufsize
|
|
1296
|
+
else:
|
|
1297
|
+
buf[n:m] = b
|
|
1298
|
+
pos += len(b)
|
|
1299
|
+
n = m
|
|
1300
1300
|
except StopIteration:
|
|
1301
1301
|
at_end = True
|
|
1302
1302
|
return n
|
|
@@ -1401,15 +1401,7 @@ def bytes_iter_to_async_reader(
|
|
|
1401
1401
|
except:
|
|
1402
1402
|
pass
|
|
1403
1403
|
def close():
|
|
1404
|
-
|
|
1405
|
-
try:
|
|
1406
|
-
method = getattr(it, "aclose")
|
|
1407
|
-
except AttributeError:
|
|
1408
|
-
method = getattr(it, "close")
|
|
1409
|
-
ret = method()
|
|
1410
|
-
if isawaitable(ret):
|
|
1411
|
-
run_async(ret)
|
|
1412
|
-
at_end = True
|
|
1404
|
+
run_async(aclose())
|
|
1413
1405
|
async def aclose():
|
|
1414
1406
|
nonlocal at_end
|
|
1415
1407
|
try:
|
|
@@ -1452,28 +1444,28 @@ def bytes_iter_to_async_reader(
|
|
|
1452
1444
|
if at_end or not (bufsize := buffer_length(buf)):
|
|
1453
1445
|
return 0
|
|
1454
1446
|
async with lock:
|
|
1455
|
-
n
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1447
|
+
if n := buffer_length(unconsumed):
|
|
1448
|
+
if bufsize <= n:
|
|
1449
|
+
buf[:], unconsumed = unconsumed[:bufsize], unconsumed[bufsize:]
|
|
1450
|
+
pos += bufsize
|
|
1451
|
+
return bufsize
|
|
1452
|
+
buf[:n] = unconsumed
|
|
1453
|
+
pos += n
|
|
1454
|
+
del unconsumed[:]
|
|
1462
1455
|
try:
|
|
1463
1456
|
while True:
|
|
1464
|
-
b
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
n = m
|
|
1457
|
+
if b := memoryview(await getnext()):
|
|
1458
|
+
m = n + len(b)
|
|
1459
|
+
if m >= bufsize:
|
|
1460
|
+
delta = bufsize - n
|
|
1461
|
+
buf[n:] = b[:delta]
|
|
1462
|
+
unconsumed += b[delta:]
|
|
1463
|
+
pos += delta
|
|
1464
|
+
return bufsize
|
|
1465
|
+
else:
|
|
1466
|
+
buf[n:m] = b
|
|
1467
|
+
pos += len(b)
|
|
1468
|
+
n = m
|
|
1477
1469
|
except (StopIteration, StopAsyncIteration):
|
|
1478
1470
|
at_end = True
|
|
1479
1471
|
return n
|
|
File without changes
|
|
File without changes
|
|
File without changes
|