python-filewrap 0.2__py3-none-any.whl → 0.2.1__py3-none-any.whl

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.
filewrap/__init__.py CHANGED
@@ -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, 1)
6
6
  __all__ = [
7
7
  "Buffer", "SupportsRead", "SupportsReadinto", "SupportsWrite", "SupportsSeek",
8
8
  "AsyncBufferedReader", "AsyncTextIOWrapper",
@@ -16,7 +16,7 @@ __all__ = [
16
16
  "progress_bytes_iter", "progress_bytes_async_iter",
17
17
  ]
18
18
 
19
- from asyncio import run as run_async, to_thread, Lock as AsyncLock
19
+ from asyncio import to_thread, Lock as AsyncLock
20
20
  from collections.abc import Awaitable, AsyncIterable, AsyncIterator, Callable, Iterable, Iterator
21
21
  from functools import update_wrapper
22
22
  from io import BufferedIOBase, BufferedReader, BytesIO, RawIOBase, TextIOWrapper
@@ -45,7 +45,7 @@ except ImportError:
45
45
  Buffer.register(_SimpleCData)
46
46
  Buffer.register(array)
47
47
 
48
- from asynctools import async_chain, ensure_async, ensure_aiter, ensure_coroutine
48
+ from asynctools import async_chain, ensure_async, ensure_aiter, run_async
49
49
  from property import staticproperty
50
50
 
51
51
 
@@ -164,7 +164,7 @@ class AsyncBufferedReader(BufferedReader):
164
164
  except (AttributeError, TypeError):
165
165
  ret = getattr(raw, "close")()
166
166
  if isawaitable(ret):
167
- run_async(ensure_coroutine(ret))
167
+ run_async(ret)
168
168
 
169
169
  async def flush(self, /):
170
170
  return await ensure_async(self.raw.flush, threaded=True)()
@@ -588,7 +588,7 @@ class AsyncTextIOWrapper(TextIOWrapper):
588
588
  except (AttributeError, TypeError):
589
589
  ret = getattr(buffer, "close")()
590
590
  if isawaitable(ret):
591
- run_async(ensure_coroutine(ret))
591
+ run_async(ret)
592
592
 
593
593
  async def flush(self, /):
594
594
  return await ensure_async(self.buffer.flush, threaded=True)()
@@ -1476,14 +1476,17 @@ def bytes_iter_to_async_reader(
1476
1476
  except:
1477
1477
  pass
1478
1478
  def close():
1479
+ nonlocal at_end
1479
1480
  try:
1480
1481
  method = getattr(it, "aclose")
1481
1482
  except AttributeError:
1482
1483
  method = getattr(it, "close")
1483
1484
  ret = method()
1484
1485
  if isawaitable(ret):
1485
- run_async(ensure_coroutine(ret))
1486
+ run_async(ret)
1487
+ at_end = True
1486
1488
  async def aclose():
1489
+ nonlocal at_end
1487
1490
  try:
1488
1491
  method = getattr(it, "aclose")
1489
1492
  except AttributeError:
@@ -1491,6 +1494,7 @@ def bytes_iter_to_async_reader(
1491
1494
  ret = method()
1492
1495
  if isawaitable(ret):
1493
1496
  await ret
1497
+ at_end = True
1494
1498
  def peek(n: int = 0, /) -> bytearray:
1495
1499
  if n <= 0:
1496
1500
  return unconsumed[:]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-filewrap
3
- Version: 0.2
3
+ Version: 0.2.1
4
4
  Summary: Python file wrappers.
5
5
  Home-page: https://github.com/ChenyangGao/web-mount-packs/tree/main/python-module/python-filewrap
6
6
  License: MIT
@@ -21,7 +21,7 @@ Classifier: Programming Language :: Python :: 3 :: Only
21
21
  Classifier: Topic :: Software Development
22
22
  Classifier: Topic :: Software Development :: Libraries
23
23
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
- Requires-Dist: python-asynctools (>=0.0.4)
24
+ Requires-Dist: python-asynctools (>=0.0.5)
25
25
  Requires-Dist: python-property (>=0.0.2)
26
26
  Project-URL: Repository, https://github.com/ChenyangGao/web-mount-packs/tree/main/python-module/python-filewrap
27
27
  Description-Content-Type: text/markdown
@@ -0,0 +1,7 @@
1
+ LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
2
+ filewrap/__init__.py,sha256=hHxlP4oHxigZM59pS1q2JcHWlir_6Tz5nFmEZKkmaJo,61023
3
+ filewrap/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ python_filewrap-0.2.1.dist-info/LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
5
+ python_filewrap-0.2.1.dist-info/METADATA,sha256=3uqJCHXBeLRckkyTTdzFCBLst6hv31dq68RFPU8Ei_k,1413
6
+ python_filewrap-0.2.1.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
7
+ python_filewrap-0.2.1.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
2
- filewrap/__init__.py,sha256=WKOOUCXO47ZmDRyROPcLkKIFiwsb5eDBhvbItCJ8zm4,61007
3
- filewrap/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- python_filewrap-0.2.dist-info/LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
5
- python_filewrap-0.2.dist-info/METADATA,sha256=mSMywqyvrqatQcKls-K7-2HQP02yE9ux2jMk6Gxuvu4,1411
6
- python_filewrap-0.2.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
7
- python_filewrap-0.2.dist-info/RECORD,,