python-iterutils 0.2.6__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_iterutils-0.2.6 → python_iterutils-0.2.8}/PKG-INFO +3 -3
- {python_iterutils-0.2.6 → python_iterutils-0.2.8}/iterutils/__init__.py +49 -30
- {python_iterutils-0.2.6 → python_iterutils-0.2.8}/pyproject.toml +3 -3
- {python_iterutils-0.2.6 → python_iterutils-0.2.8}/LICENSE +0 -0
- {python_iterutils-0.2.6 → python_iterutils-0.2.8}/iterutils/py.typed +0 -0
- {python_iterutils-0.2.6 → python_iterutils-0.2.8}/readme.md +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: python-iterutils
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.8
|
|
4
4
|
Summary: Python another itertools.
|
|
5
|
-
Home-page: https://github.com/ChenyangGao/
|
|
5
|
+
Home-page: https://github.com/ChenyangGao/python-modules/tree/main/python-iterutils
|
|
6
6
|
License: MIT
|
|
7
7
|
Keywords: iterable,iterutils
|
|
8
8
|
Author: ChenyangGao
|
|
@@ -23,7 +23,7 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
|
23
23
|
Requires-Dist: python-asynctools (>=0.1.3.4)
|
|
24
24
|
Requires-Dist: python-texttools (>=0.0.3)
|
|
25
25
|
Requires-Dist: python-undefined (>=0.0.3)
|
|
26
|
-
Project-URL: Repository, https://github.com/ChenyangGao/
|
|
26
|
+
Project-URL: Repository, https://github.com/ChenyangGao/python-modules/tree/main/python-iterutils
|
|
27
27
|
Description-Content-Type: text/markdown
|
|
28
28
|
|
|
29
29
|
# Python another itertools.
|
|
@@ -2,14 +2,13 @@
|
|
|
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
|
-
"Yield", "YieldFrom", "GenStep", "
|
|
8
|
-
"
|
|
9
|
-
"as_gen_step_iter", "split_cm", "with_iter_next",
|
|
10
|
-
"map", "filter", "reduce", "zip", "chain",
|
|
11
|
-
"
|
|
12
|
-
"async_foreach", "through", "async_through",
|
|
7
|
+
"Yield", "YieldFrom", "GenStep", "GenStepIter", "iterable",
|
|
8
|
+
"async_iterable", "run_gen_step", "run_gen_step_iter",
|
|
9
|
+
"as_gen_step", "as_gen_step_iter", "split_cm", "with_iter_next",
|
|
10
|
+
"map", "filter", "reduce", "zip", "chain", "chain_from_iterable",
|
|
11
|
+
"chunked", "foreach", "async_foreach", "through", "async_through",
|
|
13
12
|
"flatten", "async_flatten", "collect", "async_collect",
|
|
14
13
|
"group_collect", "async_group_collect", "iter_unique",
|
|
15
14
|
"async_iter_unique", "wrap_iter", "wrap_aiter", "acc_step",
|
|
@@ -68,7 +67,15 @@ class GenStep:
|
|
|
68
67
|
"""专供 `run_gen_step` 和 `run_gen_step_iter`,说明值需要进一步提取
|
|
69
68
|
"""
|
|
70
69
|
value: Generator
|
|
71
|
-
max_depth: int =
|
|
70
|
+
max_depth: int = 0
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@dataclass(slots=True, frozen=True, unsafe_hash=True)
|
|
74
|
+
class GenStepIter:
|
|
75
|
+
"""专供 `run_gen_step_iter`,说明值需要进一步提取
|
|
76
|
+
"""
|
|
77
|
+
value: Generator
|
|
78
|
+
max_depth: int = 0
|
|
72
79
|
|
|
73
80
|
|
|
74
81
|
iterable = Iterable.__instancecheck__
|
|
@@ -204,14 +211,17 @@ def _run_gen_step_iter(
|
|
|
204
211
|
val_type = type(value)
|
|
205
212
|
if issubclass(val_type, (Yield, YieldFrom)):
|
|
206
213
|
value = value.value
|
|
207
|
-
if isinstance(value,
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
214
|
+
if isinstance(value, GenStepIter):
|
|
215
|
+
yield from _run_gen_step_iter(value.value, value.max_depth)
|
|
216
|
+
else:
|
|
217
|
+
if isinstance(value, GenStep):
|
|
218
|
+
value = _run_gen_step(value.value, value.max_depth)
|
|
219
|
+
elif drive_generator and isinstance(value, Generator):
|
|
220
|
+
value = _run_gen_step(value, dgen)
|
|
221
|
+
if val_type is Yield:
|
|
222
|
+
yield value
|
|
223
|
+
elif val_type is YieldFrom:
|
|
224
|
+
yield from value
|
|
215
225
|
except BaseException as e:
|
|
216
226
|
value = throw(e)
|
|
217
227
|
else:
|
|
@@ -221,7 +231,9 @@ def _run_gen_step_iter(
|
|
|
221
231
|
val_type = type(value)
|
|
222
232
|
if issubclass(val_type, (Yield, YieldFrom)):
|
|
223
233
|
value = value.value
|
|
224
|
-
|
|
234
|
+
elif isinstance(value, GenStepIter):
|
|
235
|
+
yield from _run_gen_step_iter(value.value, value.max_depth)
|
|
236
|
+
elif isinstance(value, GenStep):
|
|
225
237
|
value = _run_gen_step(value.value, value.max_depth)
|
|
226
238
|
elif drive_generator and isinstance(value, Generator):
|
|
227
239
|
value = _run_gen_step(value, dgen)
|
|
@@ -250,6 +262,9 @@ async def _run_gen_step_async_iter(
|
|
|
250
262
|
value = value.value
|
|
251
263
|
if isawaitable(value):
|
|
252
264
|
value = await value
|
|
265
|
+
elif isinstance(value, GenStepIter):
|
|
266
|
+
async for el in _run_gen_step_async_iter(value.value, value.max_depth):
|
|
267
|
+
yield el
|
|
253
268
|
elif isinstance(value, GenStep):
|
|
254
269
|
value = await _run_gen_step_async(value.value, value.max_depth)
|
|
255
270
|
elif drive_generator and isinstance(value, Generator):
|
|
@@ -274,19 +289,23 @@ async def _run_gen_step_async_iter(
|
|
|
274
289
|
value = value.value
|
|
275
290
|
if isawaitable(value):
|
|
276
291
|
value = await value
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
292
|
+
if isinstance(value, GenStepIter):
|
|
293
|
+
async for el in _run_gen_step_async_iter(value.value, value.max_depth):
|
|
294
|
+
yield el
|
|
295
|
+
else:
|
|
296
|
+
if isinstance(value, GenStep):
|
|
297
|
+
value = await _run_gen_step_async(value.value, value.max_depth)
|
|
298
|
+
elif drive_generator and isinstance(value, Generator):
|
|
299
|
+
value = await _run_gen_step_async(value, dgen)
|
|
300
|
+
if val_type is Yield:
|
|
301
|
+
yield value
|
|
302
|
+
elif val_type is YieldFrom:
|
|
303
|
+
if isinstance(value, AsyncIterable):
|
|
304
|
+
async for el in value:
|
|
305
|
+
yield el
|
|
306
|
+
else:
|
|
307
|
+
for el in value:
|
|
308
|
+
yield el
|
|
290
309
|
finally:
|
|
291
310
|
gen.close()
|
|
292
311
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "python-iterutils"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.8"
|
|
4
4
|
description = "Python another itertools."
|
|
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-iterutils"
|
|
9
|
+
repository = "https://github.com/ChenyangGao/python-modules/tree/main/python-iterutils"
|
|
10
10
|
keywords = ["iterable", "iterutils"]
|
|
11
11
|
classifiers = [
|
|
12
12
|
"License :: OSI Approved :: MIT License",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|