python-iterutils 0.2.2__tar.gz → 0.2.3__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.2 → python_iterutils-0.2.3}/PKG-INFO +1 -1
- {python_iterutils-0.2.2 → python_iterutils-0.2.3}/iterutils/__init__.py +74 -34
- {python_iterutils-0.2.2 → python_iterutils-0.2.3}/pyproject.toml +1 -1
- {python_iterutils-0.2.2 → python_iterutils-0.2.3}/LICENSE +0 -0
- {python_iterutils-0.2.2 → python_iterutils-0.2.3}/iterutils/py.typed +0 -0
- {python_iterutils-0.2.2 → python_iterutils-0.2.3}/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, 3)
|
|
6
6
|
__all__ = [
|
|
7
7
|
"Return", "Yield", "YieldFrom", "iterable", "async_iterable",
|
|
8
8
|
"foreach", "async_foreach", "through", "async_through", "flatten",
|
|
@@ -11,8 +11,8 @@ __all__ = [
|
|
|
11
11
|
"iter_unique", "async_iter_unique", "wrap_iter", "wrap_aiter",
|
|
12
12
|
"acc_step", "cut_iter", "iter_gen_step", "iter_gen_step_async",
|
|
13
13
|
"run_gen_step", "run_gen_step_sync_iter", "run_gen_step_async_iter",
|
|
14
|
-
"run_gen_step_iter", "as_gen_step", "
|
|
15
|
-
"backgroud_loop",
|
|
14
|
+
"run_gen_step_iter", "as_gen_step", "as_gen_step_iter", "bfs_gen",
|
|
15
|
+
"with_iter_next", "backgroud_loop",
|
|
16
16
|
]
|
|
17
17
|
|
|
18
18
|
from abc import ABC, abstractmethod
|
|
@@ -813,6 +813,18 @@ async def iter_gen_step_async(
|
|
|
813
813
|
await close()
|
|
814
814
|
|
|
815
815
|
|
|
816
|
+
@overload
|
|
817
|
+
def run_gen_step(
|
|
818
|
+
gen_step: Generator | Callable[[], Generator],
|
|
819
|
+
may_await: bool | Literal[1] = True,
|
|
820
|
+
may_call: bool | Literal[1] = True,
|
|
821
|
+
threaded: bool = False,
|
|
822
|
+
running_flag: None | SupportsBool | Callable[[], SupportsBool] | Callable[[], Awaitable[SupportsBool]] = None,
|
|
823
|
+
*,
|
|
824
|
+
async_: None = None,
|
|
825
|
+
):
|
|
826
|
+
...
|
|
827
|
+
@overload
|
|
816
828
|
def run_gen_step(
|
|
817
829
|
gen_step: Generator | Callable[[], Generator],
|
|
818
830
|
may_await: bool | Literal[1] = True,
|
|
@@ -820,7 +832,28 @@ def run_gen_step(
|
|
|
820
832
|
threaded: bool = False,
|
|
821
833
|
running_flag: None | SupportsBool | Callable[[], SupportsBool] | Callable[[], Awaitable[SupportsBool]] = None,
|
|
822
834
|
*,
|
|
823
|
-
async_:
|
|
835
|
+
async_: Literal[False],
|
|
836
|
+
):
|
|
837
|
+
...
|
|
838
|
+
@overload
|
|
839
|
+
def run_gen_step(
|
|
840
|
+
gen_step: Generator | Callable[[], Generator],
|
|
841
|
+
may_await: bool | Literal[1] = True,
|
|
842
|
+
may_call: bool | Literal[1] = True,
|
|
843
|
+
threaded: bool = False,
|
|
844
|
+
running_flag: None | SupportsBool | Callable[[], SupportsBool] | Callable[[], Awaitable[SupportsBool]] = None,
|
|
845
|
+
*,
|
|
846
|
+
async_: Literal[True],
|
|
847
|
+
) -> Coroutine:
|
|
848
|
+
...
|
|
849
|
+
def run_gen_step(
|
|
850
|
+
gen_step: Generator | Callable[[], Generator],
|
|
851
|
+
may_await: bool | Literal[1] = True,
|
|
852
|
+
may_call: bool | Literal[1] = True,
|
|
853
|
+
threaded: bool = False,
|
|
854
|
+
running_flag: None | SupportsBool | Callable[[], SupportsBool] | Callable[[], Awaitable[SupportsBool]] = None,
|
|
855
|
+
*,
|
|
856
|
+
async_: None | Literal[False, True] = None,
|
|
824
857
|
):
|
|
825
858
|
"""
|
|
826
859
|
"""
|
|
@@ -1013,6 +1046,7 @@ def run_gen_step_iter(
|
|
|
1013
1046
|
may_await: bool | Literal[1] = True,
|
|
1014
1047
|
may_call: bool | Literal[1] = True,
|
|
1015
1048
|
threaded: bool = False,
|
|
1049
|
+
running_flag: None | SupportsBool | Callable[[], SupportsBool] | Callable[[], Awaitable[SupportsBool]] = None,
|
|
1016
1050
|
*,
|
|
1017
1051
|
async_: None = None,
|
|
1018
1052
|
) -> Iterator | AsyncIterator:
|
|
@@ -1023,6 +1057,7 @@ def run_gen_step_iter(
|
|
|
1023
1057
|
may_await: bool | Literal[1] = True,
|
|
1024
1058
|
may_call: bool | Literal[1] = True,
|
|
1025
1059
|
threaded: bool = False,
|
|
1060
|
+
running_flag: None | SupportsBool | Callable[[], SupportsBool] | Callable[[], Awaitable[SupportsBool]] = None,
|
|
1026
1061
|
*,
|
|
1027
1062
|
async_: Literal[False],
|
|
1028
1063
|
) -> Iterator:
|
|
@@ -1033,6 +1068,7 @@ def run_gen_step_iter(
|
|
|
1033
1068
|
may_await: bool | Literal[1] = True,
|
|
1034
1069
|
may_call: bool | Literal[1] = True,
|
|
1035
1070
|
threaded: bool = False,
|
|
1071
|
+
running_flag: None | SupportsBool | Callable[[], SupportsBool] | Callable[[], Awaitable[SupportsBool]] = None,
|
|
1036
1072
|
*,
|
|
1037
1073
|
async_: Literal[True],
|
|
1038
1074
|
) -> AsyncIterator:
|
|
@@ -1042,8 +1078,9 @@ def run_gen_step_iter(
|
|
|
1042
1078
|
may_await: bool | Literal[1] = True,
|
|
1043
1079
|
may_call: bool | Literal[1] = True,
|
|
1044
1080
|
threaded: bool = False,
|
|
1081
|
+
running_flag: None | SupportsBool | Callable[[], SupportsBool] | Callable[[], Awaitable[SupportsBool]] = None,
|
|
1045
1082
|
*,
|
|
1046
|
-
async_: None |
|
|
1083
|
+
async_: None | Literal[False, True] = None,
|
|
1047
1084
|
) -> Iterator | AsyncIterator:
|
|
1048
1085
|
"""
|
|
1049
1086
|
"""
|
|
@@ -1062,38 +1099,41 @@ def run_gen_step_iter(
|
|
|
1062
1099
|
|
|
1063
1100
|
@optional
|
|
1064
1101
|
def as_gen_step(
|
|
1065
|
-
func: Callable,
|
|
1102
|
+
func: Callable[..., Generator],
|
|
1066
1103
|
/,
|
|
1104
|
+
*deco_args,
|
|
1067
1105
|
iter: bool = False,
|
|
1068
|
-
|
|
1069
|
-
may_call: bool | Literal[1] = True,
|
|
1070
|
-
threaded: bool = False,
|
|
1071
|
-
running_flag: None | SupportsBool | Callable[[], SupportsBool] | Callable[[], Awaitable[SupportsBool]] = None,
|
|
1072
|
-
*,
|
|
1073
|
-
async_: None | bool = None,
|
|
1106
|
+
**deco_kwds,
|
|
1074
1107
|
) -> Callable:
|
|
1075
|
-
"""
|
|
1076
|
-
"""
|
|
1077
|
-
if
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1108
|
+
"""装饰器,把生成器封装成 gen_step 函数
|
|
1109
|
+
"""
|
|
1110
|
+
call = run_gen_step_iter if iter else run_gen_step
|
|
1111
|
+
def wrapper(*args, async_: Literal[False, True] = False, **kwds):
|
|
1112
|
+
return call(
|
|
1113
|
+
func(*args, async_=async_, **kwds),
|
|
1114
|
+
*deco_args,
|
|
1115
|
+
async_=async_,
|
|
1116
|
+
**deco_kwds,
|
|
1117
|
+
)
|
|
1118
|
+
return wrapper
|
|
1119
|
+
|
|
1120
|
+
|
|
1121
|
+
@optional
|
|
1122
|
+
def as_gen_step_iter(
|
|
1123
|
+
func: Callable[..., Generator],
|
|
1124
|
+
/,
|
|
1125
|
+
*deco_args,
|
|
1126
|
+
**deco_kwds,
|
|
1127
|
+
) -> Callable:
|
|
1128
|
+
"""装饰器,把生成器封装成 gen_step 函数
|
|
1129
|
+
"""
|
|
1130
|
+
def wrapper(*args, async_: Literal[False, True] = False, **kwds):
|
|
1131
|
+
return run_gen_step_iter(
|
|
1132
|
+
func(*args, async_=async_, **kwds),
|
|
1133
|
+
*deco_args,
|
|
1134
|
+
async_=async_,
|
|
1135
|
+
**deco_kwds,
|
|
1136
|
+
)
|
|
1097
1137
|
return wrapper
|
|
1098
1138
|
|
|
1099
1139
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|