python-iterutils 0.0.7.1__py3-none-any.whl → 0.0.8__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.
- iterutils/__init__.py +20 -8
- {python_iterutils-0.0.7.1.dist-info → python_iterutils-0.0.8.dist-info}/METADATA +1 -1
- python_iterutils-0.0.8.dist-info/RECORD +7 -0
- python_iterutils-0.0.7.1.dist-info/RECORD +0 -7
- {python_iterutils-0.0.7.1.dist-info → python_iterutils-0.0.8.dist-info}/LICENSE +0 -0
- {python_iterutils-0.0.7.1.dist-info → python_iterutils-0.0.8.dist-info}/WHEEL +0 -0
iterutils/__init__.py
CHANGED
|
@@ -2,23 +2,23 @@
|
|
|
2
2
|
# encoding: utf-8
|
|
3
3
|
|
|
4
4
|
__author__ = "ChenyangGao <https://chenyanggao.github.io>"
|
|
5
|
-
__version__ = (0, 0,
|
|
5
|
+
__version__ = (0, 0, 8)
|
|
6
6
|
__all__ = [
|
|
7
7
|
"iterable", "async_iterable", "foreach", "async_foreach", "through", "async_through",
|
|
8
8
|
"wrap_iter", "wrap_aiter", "acc_step", "cut_iter", "run_gen_step", "run_gen_step_iter",
|
|
9
9
|
"Yield", "YieldFrom",
|
|
10
10
|
]
|
|
11
11
|
|
|
12
|
-
from dataclasses import dataclass
|
|
13
12
|
from abc import ABC, abstractmethod
|
|
14
13
|
from asyncio import to_thread
|
|
15
14
|
from collections.abc import (
|
|
16
15
|
AsyncIterable, AsyncIterator, Callable, Generator, Iterable, Iterator,
|
|
17
16
|
)
|
|
17
|
+
from dataclasses import dataclass
|
|
18
18
|
from inspect import isawaitable
|
|
19
19
|
from typing import overload, Any, Literal, TypeVar
|
|
20
20
|
|
|
21
|
-
from asynctools import async_zip, ensure_async, ensure_aiter
|
|
21
|
+
from asynctools import async_map, async_zip, ensure_async, ensure_aiter
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
T = TypeVar("T")
|
|
@@ -77,18 +77,30 @@ async def async_foreach(ret: Callable, iterable, /, *iterables, threaded: bool =
|
|
|
77
77
|
await ret(arg)
|
|
78
78
|
|
|
79
79
|
|
|
80
|
-
def through(it: Iterable,
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
def through(it: Iterable, /, take_while: None | Callable = None):
|
|
81
|
+
if take_while is None:
|
|
82
|
+
for _ in it:
|
|
83
|
+
pass
|
|
84
|
+
else:
|
|
85
|
+
for v in map(take_while, it):
|
|
86
|
+
if not v:
|
|
87
|
+
break
|
|
83
88
|
|
|
84
89
|
|
|
85
90
|
async def async_through(
|
|
86
91
|
it: Iterable | AsyncIterable,
|
|
87
92
|
/,
|
|
93
|
+
take_while: None | Callable = None,
|
|
88
94
|
threaded: bool = True,
|
|
89
95
|
):
|
|
90
|
-
|
|
91
|
-
|
|
96
|
+
it = ensure_aiter(it, threaded=threaded)
|
|
97
|
+
if take_while is None:
|
|
98
|
+
async for _ in it:
|
|
99
|
+
pass
|
|
100
|
+
else:
|
|
101
|
+
async for v in async_map(take_while, it):
|
|
102
|
+
if not v:
|
|
103
|
+
break
|
|
92
104
|
|
|
93
105
|
|
|
94
106
|
def wrap_iter(
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
|
|
2
|
+
iterutils/__init__.py,sha256=rwD7tD31XxBl85Yo2pONeJoOng3aqYySh-I6CzEPILA,12467
|
|
3
|
+
iterutils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
python_iterutils-0.0.8.dist-info/LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
|
|
5
|
+
python_iterutils-0.0.8.dist-info/METADATA,sha256=3BSfEd9eF0b_zmgOE_pCEO6BNQeIRRv9X1UgGBUADSY,1382
|
|
6
|
+
python_iterutils-0.0.8.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
7
|
+
python_iterutils-0.0.8.dist-info/RECORD,,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
|
|
2
|
-
iterutils/__init__.py,sha256=d1nN35bvpA0SJTgYFKmWtt6cofF6p4yg1E_uhKyyzFw,12101
|
|
3
|
-
iterutils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
python_iterutils-0.0.7.1.dist-info/LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
|
|
5
|
-
python_iterutils-0.0.7.1.dist-info/METADATA,sha256=Fv-Zi3_OkM31ZPHTO0JBLmACgs7rFEqFJLchFJUWErU,1384
|
|
6
|
-
python_iterutils-0.0.7.1.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
7
|
-
python_iterutils-0.0.7.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|