p115client 0.0.5.12.1__py3-none-any.whl → 0.0.5.12.2__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.
@@ -7,18 +7,19 @@ __doc__ = "这个模块利用 P115Client.fs_files 方法做了一些封装"
7
7
 
8
8
  from asyncio import shield, wait_for, Task, TaskGroup
9
9
  from collections import deque
10
- from collections.abc import AsyncIterator, Callable, Iterator
10
+ from collections.abc import AsyncIterator, Awaitable, Callable, Iterator
11
11
  from concurrent.futures import Future, ThreadPoolExecutor
12
12
  from copy import copy
13
13
  from errno import EBUSY, ENOENT, ENOTDIR
14
14
  from functools import partial
15
15
  from inspect import isawaitable
16
16
  from itertools import cycle
17
+ from sys import exc_info
17
18
  from time import time
18
- from typing import overload, Any, Final, Literal
19
+ from typing import cast, overload, Any, Final, Literal
19
20
  from warnings import warn
20
21
 
21
- from iterutils import run_gen_step, run_gen_step_iter, Yield
22
+ from iterutils import as_gen_step, run_gen_step_iter, Yield
22
23
  from p115client import check_response, P115Client, P115OpenClient
23
24
  from p115client.client import get_status_code
24
25
  from p115client.exception import BusyOSError, DataError, P115Warning
@@ -95,6 +96,16 @@ def iter_fs_files(
95
96
  client = P115Client(client, check_for_relogin=True)
96
97
  if page_size <= 0:
97
98
  page_size = 10_000
99
+ if not isinstance(client, P115Client) or app == "open":
100
+ page_size = min(page_size, 1150)
101
+ fs_files = partial(client.fs_files_open, **request_kwargs)
102
+ elif app in ("", "web", "desktop", "harmony"):
103
+ page_size = min(page_size, 1150)
104
+ request_kwargs.setdefault("base_url", get_webapi_origin)
105
+ fs_files = partial(client.fs_files, **request_kwargs)
106
+ else:
107
+ request_kwargs.setdefault("base_url", get_proapi_origin)
108
+ fs_files = partial(client.fs_files_app, app=app, **request_kwargs)
98
109
  if first_page_size <= 0:
99
110
  first_page_size = page_size
100
111
  if isinstance(payload, (int, str)):
@@ -104,14 +115,7 @@ def iter_fs_files(
104
115
  "limit": first_page_size, "show_dir": 1, **payload,
105
116
  }
106
117
  cid = int(payload["cid"])
107
- if not isinstance(client, P115Client) or app == "open":
108
- fs_files = partial(client.fs_files_open, **request_kwargs)
109
- elif app in ("", "web", "desktop", "harmony"):
110
- request_kwargs.setdefault("base_url", get_webapi_origin)
111
- fs_files = partial(client.fs_files, **request_kwargs)
112
- else:
113
- request_kwargs.setdefault("base_url", get_proapi_origin)
114
- fs_files = partial(client.fs_files_app, app=app, **request_kwargs)
118
+ @as_gen_step
115
119
  def get_files(payload: dict, /):
116
120
  nonlocal count
117
121
  while True:
@@ -145,13 +149,13 @@ def iter_fs_files(
145
149
  return resp
146
150
  def gen_step():
147
151
  while True:
148
- resp = yield run_gen_step(get_files(payload), may_call=False, async_=async_)
152
+ resp = yield get_files(payload)
149
153
  payload["limit"] = page_size
150
154
  yield Yield(resp)
151
155
  payload["offset"] += len(resp["data"])
152
156
  if payload["offset"] >= count:
153
157
  break
154
- return run_gen_step_iter(gen_step, may_call=False, async_=async_)
158
+ return run_gen_step_iter(gen_step, async_)
155
159
 
156
160
 
157
161
  def iter_fs_files_threaded(
@@ -187,14 +191,7 @@ def iter_fs_files_threaded(
187
191
  if isinstance(client, str):
188
192
  client = P115Client(client, check_for_relogin=True)
189
193
  if page_size <= 0:
190
- page_size = 7_000
191
- if isinstance(payload, (int, str)):
192
- payload = {"cid": payload}
193
- payload = {
194
- "asc": 1, "cid": 0, "fc_mix": 1, "o": "user_ptime", "offset": 0,
195
- "limit": page_size, "show_dir": 1, **payload,
196
- }
197
- cid = int(payload["cid"])
194
+ page_size = 10_000
198
195
  if not isinstance(client, P115Client) or app == "open":
199
196
  page_size = min(page_size, 1150)
200
197
  fs_files = partial(client.fs_files_open, **request_kwargs)
@@ -205,6 +202,13 @@ def iter_fs_files_threaded(
205
202
  else:
206
203
  request_kwargs.setdefault("base_url", get_proapi_origin)
207
204
  fs_files = partial(client.fs_files_app, app=app, **request_kwargs)
205
+ if isinstance(payload, (int, str)):
206
+ payload = {"cid": payload}
207
+ payload = {
208
+ "asc": 1, "cid": 0, "fc_mix": 1, "o": "user_ptime", "offset": 0,
209
+ "limit": page_size, "show_dir": 1, **payload,
210
+ }
211
+ cid = int(payload["cid"])
208
212
  def get_files(payload: dict, /):
209
213
  nonlocal count
210
214
  resp = fs_files(payload)
@@ -302,27 +306,41 @@ async def iter_fs_files_asynchronized(
302
306
  if isinstance(client, str):
303
307
  client = P115Client(client, check_for_relogin=True)
304
308
  if page_size <= 0:
305
- page_size = 7_000
306
- if isinstance(payload, (int, str)):
307
- payload = {"cid": payload}
308
- payload = {
309
- "asc": 1, "cid": 0, "fc_mix": 1, "o": "user_ptime", "offset": 0,
310
- "limit": page_size, "show_dir": 1, **payload,
311
- }
312
- cid = int(payload["cid"])
309
+ page_size = 10_000
310
+ fs_files: Callable[..., Awaitable[dict]]
313
311
  if not isinstance(client, P115Client) or app == "open":
314
312
  page_size = min(page_size, 1150)
315
- fs_files = partial(client.fs_files_open, **request_kwargs)
313
+ fs_files = cast(Callable, partial(
314
+ client.fs_files_open,
315
+ async_=True,
316
+ **request_kwargs,
317
+ ))
316
318
  elif app in ("", "web", "desktop", "harmony"):
317
319
  page_size = min(page_size, 1150)
318
320
  request_kwargs.setdefault("base_url", get_webapi_origin)
319
- fs_files = partial(client.fs_files, **request_kwargs)
321
+ fs_files = cast(Callable, partial(
322
+ client.fs_files,
323
+ async_=True,
324
+ **request_kwargs,
325
+ ))
320
326
  else:
321
327
  request_kwargs.setdefault("base_url", get_proapi_origin)
322
- fs_files = partial(client.fs_files_app, app=app, **request_kwargs)
328
+ fs_files = cast(Callable, partial(
329
+ client.fs_files_app,
330
+ app=app,
331
+ async_=True,
332
+ **request_kwargs,
333
+ ))
334
+ if isinstance(payload, (int, str)):
335
+ payload = {"cid": payload}
336
+ payload = {
337
+ "asc": 1, "cid": 0, "fc_mix": 1, "o": "user_ptime", "offset": 0,
338
+ "limit": page_size, "show_dir": 1, **payload,
339
+ }
340
+ cid = int(payload["cid"])
323
341
  async def get_files(payload: dict, /):
324
342
  nonlocal count
325
- resp = await fs_files(payload, async_=True) # type: ignore
343
+ resp = await fs_files(payload)
326
344
  check_response(resp)
327
345
  if cid and int(resp["path"][-1]["cid"]) != cid:
328
346
  if count < 0:
@@ -390,7 +408,5 @@ async def iter_fs_files_asynchronized(
390
408
  finally:
391
409
  for t in tuple(tg._tasks):
392
410
  t.cancel()
393
- await tg.__aexit__(None, None, None)
394
-
411
+ await tg.__aexit__(*exc_info())
395
412
 
396
- # TODO: 以上的数据获取方式某种程度上应该是通用的,只要是涉及到 offset 和 count,因此可以总结出一个更抽象的函数
@@ -119,7 +119,7 @@ def iter_history_list_once(
119
119
  ts_last_call = time()
120
120
  resp = yield history_list(payload, async_=async_)
121
121
  events = check_response(resp)["data"]["list"]
122
- return run_gen_step_iter(gen_step, may_call=False, async_=async_)
122
+ return run_gen_step_iter(gen_step, async_)
123
123
 
124
124
 
125
125
  @overload
@@ -220,5 +220,5 @@ def iter_history_list(
220
220
  from_time = int(event["update_time"])
221
221
  sub_first_loop = False
222
222
  yield Yield(event)
223
- return run_gen_step_iter(gen_step, may_call=False, async_=async_)
223
+ return run_gen_step_iter(gen_step, async_)
224
224
 
@@ -40,9 +40,9 @@ from weakref import WeakValueDictionary
40
40
  from asynctools import async_chain, async_filter, async_map, to_list
41
41
  from concurrenttools import run_as_thread, taskgroup_map, threadpool_map
42
42
  from iterutils import (
43
- as_gen_step, bfs_gen, chunked, ensure_aiter, foreach,
44
- flatten, iter_unique, run_gen_step, run_gen_step_iter, through,
45
- async_through, with_iter_next, Yield, YieldFrom,
43
+ bfs_gen, chunked, ensure_aiter, foreach, flatten, iter_unique,
44
+ run_gen_step, run_gen_step_iter, through, async_through, with_iter_next,
45
+ Yield, YieldFrom,
46
46
  )
47
47
  from iter_collect import iter_keyed_dups, SupportsLT
48
48
  from orjson import loads
@@ -238,7 +238,7 @@ def get_path_to_cid(
238
238
  return "/" + path
239
239
  else:
240
240
  return path
241
- return run_gen_step(gen_step, may_call=False, async_=async_)
241
+ return run_gen_step(gen_step, async_)
242
242
 
243
243
 
244
244
  @overload
@@ -370,7 +370,7 @@ def get_file_count(
370
370
  node = DirNode(info["file_name"], pid)
371
371
  id_to_dirnode[(pid := int(info["file_id"]))] = node
372
372
  return int(resp["count"]) - int(resp.get("folder_count") or 0)
373
- return run_gen_step(gen_step, may_call=False, async_=async_)
373
+ return run_gen_step(gen_step, async_)
374
374
 
375
375
 
376
376
  @overload
@@ -590,7 +590,7 @@ def get_ancestors(
590
590
  if not resp.get("sha1") and id_to_dirnode is not ...:
591
591
  id_to_dirnode[ans["id"]] = DirNode(ans["name"], ans["parent_id"])
592
592
  return ancestors
593
- return run_gen_step(gen_step, may_call=False, async_=async_)
593
+ return run_gen_step(gen_step, async_)
594
594
 
595
595
 
596
596
  @overload
@@ -692,7 +692,7 @@ def get_ancestors_to_cid(
692
692
  parts.append({"id": 0, "name": "", "parent_id": 0})
693
693
  parts.reverse()
694
694
  return parts
695
- return run_gen_step(gen_step, may_call=False, async_=async_)
695
+ return run_gen_step(gen_step, async_)
696
696
 
697
697
 
698
698
  # TODO: 使用 search 接口以在特定目录之下搜索某个名字,以便减少风控
@@ -887,7 +887,7 @@ def get_id_to_path(
887
887
  if ensure_file is None or ensure_file ^ attr["is_dir"]:
888
888
  return P115ID(attr["id"], attr, about="path")
889
889
  raise error
890
- return run_gen_step(gen_step, may_call=False, async_=async_)
890
+ return run_gen_step(gen_step, async_)
891
891
 
892
892
 
893
893
  @overload
@@ -941,7 +941,7 @@ def get_id_to_pickcode(
941
941
  check_response(resp)
942
942
  data = resp["data"]
943
943
  return P115ID(data["file_id"], data, about="pickcode")
944
- return run_gen_step(gen_step, may_call=False, async_=async_)
944
+ return run_gen_step(gen_step, async_)
945
945
 
946
946
 
947
947
  @overload
@@ -1001,7 +1001,7 @@ def get_id_to_sha1(
1001
1001
  else:
1002
1002
  raise FileNotFoundError(ENOENT, file_sha1)
1003
1003
  return P115ID(data["file_id"], data, about="sha1", file_sha1=file_sha1)
1004
- return run_gen_step(gen_step, may_call=False, async_=async_)
1004
+ return run_gen_step(gen_step, async_)
1005
1005
 
1006
1006
 
1007
1007
  @overload
@@ -1054,7 +1054,7 @@ def iter_nodes_skim(
1054
1054
  for a in resp["data"]:
1055
1055
  a["file_name"] = unescape_115_charref(a["file_name"])
1056
1056
  yield YieldFrom(resp["data"])
1057
- return run_gen_step_iter(gen_step, may_call=False, async_=async_)
1057
+ return run_gen_step_iter(gen_step, async_)
1058
1058
 
1059
1059
 
1060
1060
  @overload
@@ -1203,7 +1203,7 @@ def _iter_fs_files(
1203
1203
  yield Yield(info)
1204
1204
  except (StopAsyncIteration, StopIteration):
1205
1205
  pass
1206
- return run_gen_step_iter(gen_step, may_call=False, async_=async_)
1206
+ return run_gen_step_iter(gen_step, async_)
1207
1207
 
1208
1208
 
1209
1209
  @overload
@@ -1593,7 +1593,7 @@ def ensure_attr_path[D: dict](
1593
1593
  attr.setdefault("ancestors", None)
1594
1594
  attr.setdefault("path", "")
1595
1595
  yield Yield(attr)
1596
- return run_gen_step_iter(gen_step, may_call=False, async_=async_)
1596
+ return run_gen_step_iter(gen_step, async_)
1597
1597
 
1598
1598
 
1599
1599
  @overload
@@ -2078,7 +2078,7 @@ def iterdir(
2078
2078
  yield YieldFrom(do_map(process, it)) # type: ignore
2079
2079
  else:
2080
2080
  yield YieldFrom(do_map(normalize_attr, it)) # type: ignore
2081
- return run_gen_step_iter(gen_step, may_call=False, async_=async_)
2081
+ return run_gen_step_iter(gen_step, async_)
2082
2082
 
2083
2083
 
2084
2084
  def iterdir_limited(
@@ -2187,7 +2187,7 @@ def iterdir_limited(
2187
2187
  attr["path"] = dirname + name
2188
2188
  yield attr
2189
2189
  def gen_step():
2190
- resp: dict = yield run_gen_step(request, may_call=False, async_=async_)
2190
+ resp: dict = yield run_gen_step(request, async_)
2191
2191
  yield YieldFrom(iter_attrs(resp))
2192
2192
  count = int(resp["count"])
2193
2193
  count_fetched = len(resp["data"])
@@ -2239,7 +2239,7 @@ def iterdir_limited(
2239
2239
  yield YieldFrom(iter_attrs(resp))
2240
2240
  if diff := count_files - len(seen_files):
2241
2241
  warn(f"lost {diff} files: cid={cid}", category=P115Warning)
2242
- return run_gen_step_iter(gen_step, may_call=False, async_=async_)
2242
+ return run_gen_step_iter(gen_step, async_)
2243
2243
 
2244
2244
 
2245
2245
  @overload
@@ -2609,7 +2609,7 @@ def iter_files(
2609
2609
  async_=async_, # type: ignore
2610
2610
  **request_kwargs,
2611
2611
  ))
2612
- return run_gen_step_iter(gen_step, may_call=False, async_=async_)
2612
+ return run_gen_step_iter(gen_step, async_)
2613
2613
 
2614
2614
 
2615
2615
  @overload
@@ -2814,7 +2814,7 @@ def traverse_files(
2814
2814
  type_of_attr(attr) == type
2815
2815
  ):
2816
2816
  yield Yield(attr)
2817
- return run_gen_step_iter(gen_step, may_call=False, async_=async_)
2817
+ return run_gen_step_iter(gen_step, async_)
2818
2818
 
2819
2819
 
2820
2820
  @overload
@@ -2885,7 +2885,6 @@ def iter_dirs(
2885
2885
  it = do_map(project, it)
2886
2886
  if with_pickcode:
2887
2887
  file_skim = client.fs_file_skim
2888
- @as_gen_step(async_=async_)
2889
2888
  def batch_load_pickcode(batch: Sequence[dict], /):
2890
2889
  resp = yield file_skim(
2891
2890
  (a["id"] for a in batch),
@@ -2901,14 +2900,14 @@ def iter_dirs(
2901
2900
  def gen_step(iterable):
2902
2901
  batch_map = taskgroup_map if async_ else threadpool_map
2903
2902
  with with_iter_next(batch_map(
2904
- batch_load_pickcode,
2903
+ lambda batch: run_gen_step(batch_load_pickcode(batch), async_),
2905
2904
  chunked(iterable, 3000),
2906
2905
  max_workers=max_workers,
2907
2906
  )) as get_next:
2908
2907
  while True:
2909
2908
  batch = yield get_next()
2910
2909
  yield YieldFrom(batch)
2911
- it = run_gen_step_iter(gen_step(it), may_call=False, async_=async_)
2910
+ it = run_gen_step_iter(gen_step(it), async_)
2912
2911
  return it
2913
2912
 
2914
2913
 
@@ -3160,7 +3159,7 @@ def iter_image_files(
3160
3159
  if offset >= count:
3161
3160
  break
3162
3161
  payload["offset"] = offset
3163
- return run_gen_step_iter(gen_step, may_call=False, async_=async_)
3162
+ return run_gen_step_iter(gen_step, async_)
3164
3163
 
3165
3164
 
3166
3165
  @overload
@@ -3273,7 +3272,7 @@ def share_iterdir(
3273
3272
  payload["offset"] += page_size # type: ignore
3274
3273
  if payload["offset"] >= count: # type: ignore
3275
3274
  break
3276
- return run_gen_step_iter(gen_step, may_call=False, async_=async_)
3275
+ return run_gen_step_iter(gen_step, async_)
3277
3276
 
3278
3277
 
3279
3278
  @overload
@@ -3376,7 +3375,7 @@ def share_iter_files(
3376
3375
  yield Yield({k: attr[k] for k in ("id", "sha1", "name", "size", "path")})
3377
3376
  except (StopIteration, StopAsyncIteration):
3378
3377
  pass
3379
- return run_gen_step(gen_step, may_call=False, async_=async_)
3378
+ return run_gen_step(gen_step, async_)
3380
3379
 
3381
3380
 
3382
3381
  @overload
@@ -3546,7 +3545,7 @@ def share_get_id_to_path(
3546
3545
  if ensure_file is None or ensure_file ^ attr["is_dir"]:
3547
3546
  return P115ID(attr["id"], attr, about="path")
3548
3547
  raise error
3549
- return run_gen_step(gen_step, may_call=False, async_=async_)
3548
+ return run_gen_step(gen_step, async_)
3550
3549
 
3551
3550
 
3552
3551
  @overload
@@ -4088,7 +4087,7 @@ def iter_selected_nodes_using_star_event(
4088
4087
  break
4089
4088
  except (StopIteration, StopAsyncIteration):
4090
4089
  pass
4091
- return run_gen_step_iter(gen_step, may_call=False, async_=async_)
4090
+ return run_gen_step_iter(gen_step, async_)
4092
4091
 
4093
4092
 
4094
4093
  @overload
@@ -4188,7 +4187,7 @@ def iter_selected_dirs_using_star(
4188
4187
  break
4189
4188
  except (StopIteration, StopAsyncIteration):
4190
4189
  pass
4191
- return run_gen_step_iter(gen_step, may_call=False, async_=async_)
4190
+ return run_gen_step_iter(gen_step, async_)
4192
4191
 
4193
4192
 
4194
4193
  @overload
@@ -4362,7 +4361,7 @@ def iter_files_with_dirname(
4362
4361
  it = iter_parents_3_level(
4363
4362
  client,
4364
4363
  iter_unique((async_map if async_ else map)(
4365
- get_pid, run_gen_step_iter(gen_step, may_call=False, async_=async_))), # type: ignore
4364
+ get_pid, run_gen_step_iter(gen_step, async_))), # type: ignore
4366
4365
  async_=async_, # type: ignore
4367
4366
  **request_kwargs,
4368
4367
  )
@@ -4376,8 +4375,8 @@ def iter_files_with_dirname(
4376
4375
  for attr in files:
4377
4376
  attr["parents"] = (attr["dir_name"], *id_to_parents[attr["parent_id"]])
4378
4377
  yield Yield(attr)
4379
- return run_gen_step_iter(gen_step2, may_call=False, async_=async_)
4380
- return run_gen_step_iter(gen_step, may_call=False, async_=async_)
4378
+ return run_gen_step_iter(gen_step2, async_)
4379
+ return run_gen_step_iter(gen_step, async_)
4381
4380
 
4382
4381
 
4383
4382
  @overload
@@ -4550,7 +4549,7 @@ def iter_files_with_path(
4550
4549
  )) as get_next:
4551
4550
  while True:
4552
4551
  attr = yield get_next()
4553
- yield run_gen_step(fetch_dirs(attr["pickcode"]), may_call=False, async_=async_)
4552
+ yield run_gen_step(fetch_dirs(attr["pickcode"]), async_)
4554
4553
  if with_ancestors:
4555
4554
  id_to_ancestors: dict[int, list[dict]] = {}
4556
4555
  def get_ancestors(id: int, attr: dict | tuple[str, int] | DirNode, /) -> list[dict]:
@@ -4597,7 +4596,7 @@ def iter_files_with_path(
4597
4596
  add_to_cache = cache.append
4598
4597
  if not path_already:
4599
4598
  if async_:
4600
- task: Any = create_task(run_gen_step(fetch_dirs(cid), may_call=False, async_=True))
4599
+ task: Any = create_task(run_gen_step(fetch_dirs(cid), True))
4601
4600
  else:
4602
4601
  task = run_as_thread(run_gen_step, fetch_dirs(cid))
4603
4602
  task.add_done_callback(set_path_already)
@@ -4641,7 +4640,7 @@ def iter_files_with_path(
4641
4640
  else:
4642
4641
  task.result()
4643
4642
  yield YieldFrom(map(update_path, cache))
4644
- return run_gen_step_iter(gen_step, may_call=False, async_=async_)
4643
+ return run_gen_step_iter(gen_step, async_)
4645
4644
 
4646
4645
 
4647
4646
  @overload
@@ -4898,7 +4897,7 @@ def iter_files_with_path_by_export_dir(
4898
4897
  name = escape(name)
4899
4898
  attr["path"] = dir_path + name
4900
4899
  yield Yield(attr)
4901
- return run_gen_step_iter(gen_step, may_call=False, async_=async_)
4900
+ return run_gen_step_iter(gen_step, async_)
4902
4901
 
4903
4902
 
4904
4903
  @overload
@@ -4989,7 +4988,7 @@ def iter_parents_3_level(
4989
4988
  ids = (async_filter if async_ else filter)(None, ids) # type: ignore
4990
4989
  return flatten(
4991
4990
  batch_map(
4992
- lambda ids, /: run_gen_step(get_parents(ids), may_call=False, async_=async_),
4991
+ lambda ids, /: run_gen_step(get_parents(ids), async_),
4993
4992
  chunked(ids, 1150),
4994
4993
  max_workers=max_workers,
4995
4994
  ),
@@ -5088,12 +5087,8 @@ def iter_dir_nodes(
5088
5087
  "name": attr["name"],
5089
5088
  }
5090
5089
  )
5091
- yield YieldFrom(run_gen_step_iter(
5092
- gen_step(attr["pickcode"]),
5093
- may_call=False,
5094
- async_=async_,
5095
- ))
5096
- return run_gen_step_iter(gen_step(cid or 0), may_call=False, async_=async_)
5090
+ yield YieldFrom(run_gen_step_iter(gen_step(attr["pickcode"]), async_))
5091
+ return run_gen_step_iter(gen_step(cid or 0), async_)
5097
5092
 
5098
5093
 
5099
5094
  @overload
@@ -5172,5 +5167,5 @@ def search_for_any_file(
5172
5167
  )
5173
5168
  check_response(resp)
5174
5169
  return bool(resp["data"])
5175
- return run_gen_step(gen_step, may_call=False, async_=async_)
5170
+ return run_gen_step(gen_step, async_)
5176
5171
 
p115client/tool/life.py CHANGED
@@ -172,7 +172,7 @@ def iter_life_list(
172
172
  else:
173
173
  sleep(1 - diff)
174
174
  end_time = int(time())
175
- return run_gen_step_iter(gen_step, may_call=False, async_=async_)
175
+ return run_gen_step_iter(gen_step, async_)
176
176
 
177
177
 
178
178
  @overload
@@ -276,7 +276,7 @@ def iter_life_behavior_once(
276
276
  ts_last_call = time()
277
277
  resp = yield life_behavior_detail(payload, async_=async_)
278
278
  events = check_response(resp)["data"]["list"]
279
- return run_gen_step_iter(gen_step, may_call=False, async_=async_)
279
+ return run_gen_step_iter(gen_step, async_)
280
280
 
281
281
 
282
282
  @overload
@@ -377,7 +377,7 @@ def iter_life_behavior(
377
377
  if not type and ignore_types and event["type"] in ignore_types:
378
378
  continue
379
379
  yield Yield(event)
380
- return run_gen_step_iter(gen_step, may_call=False, async_=async_)
380
+ return run_gen_step_iter(gen_step, async_)
381
381
 
382
382
 
383
383
  @overload
@@ -469,5 +469,5 @@ def iter_life_behavior_list(
469
469
  continue
470
470
  push(event)
471
471
  yield Yield(ls)
472
- return run_gen_step_iter(gen_step, may_call=False, async_=async_)
472
+ return run_gen_step_iter(gen_step, async_)
473
473
 
@@ -128,7 +128,7 @@ def offline_iter(
128
128
  yield YieldFrom(resp["tasks"])
129
129
  if len(tasks) < 30 or page >= resp["page_count"]:
130
130
  break
131
- return run_gen_step_iter(gen_step, async_=async_)
131
+ return run_gen_step_iter(gen_step, async_)
132
132
 
133
133
 
134
134
  @overload
@@ -192,5 +192,5 @@ def offline_restart_iter(
192
192
  )
193
193
  resp["task"] = task
194
194
  yield Yield(resp)
195
- return run_gen_step_iter(gen_step, async_=async_)
195
+ return run_gen_step_iter(gen_step, async_)
196
196
 
p115client/tool/pool.py CHANGED
@@ -87,7 +87,7 @@ def generate_auth_factory(
87
87
  "authorization": "Bearer " + resp["data"]["access_token"],
88
88
  "app_id": str(app_id),
89
89
  }
90
- return run_gen_step(gen_step, may_call=False, async_=async_)
90
+ return run_gen_step(gen_step, async_)
91
91
  return make_cookies
92
92
 
93
93
 
@@ -141,7 +141,7 @@ def generate_cookies_factory(
141
141
  "cookie": "; ".join(f"{k}={v}" for k, v in resp["data"]["cookie"].items()),
142
142
  "app": app,
143
143
  }
144
- return run_gen_step(gen_step, may_call=False, async_=async_)
144
+ return run_gen_step(gen_step, async_)
145
145
  return make_cookies
146
146
 
147
147
 
@@ -164,7 +164,7 @@ def generate_client_factory(
164
164
  def gen_step():
165
165
  headers = yield call(async_=async_)
166
166
  return cls(headers["cookie"])
167
- return run_gen_step(gen_step, may_call=False, async_=async_)
167
+ return run_gen_step(gen_step, async_)
168
168
  return make_client
169
169
 
170
170
 
@@ -214,7 +214,7 @@ def make_pool[T](
214
214
  value = generate()
215
215
  val = ComparedWithID(value)
216
216
  return value, partial(heappush, heap_, (time(), val))
217
- return run_gen_step(call, may_call=False, async_=async_)
217
+ return run_gen_step(call, async_)
218
218
  if not lock:
219
219
  setattr(get_value, "heap", heap_)
220
220
  return get_value
@@ -376,7 +376,7 @@ def call_wrap_with_pool(get_cert_headers: Callable, /, func: Callable) -> Callab
376
376
  if not isinstance(e, (AuthenticationError, LoginError)) and get_status_code(e) != 405:
377
377
  revert()
378
378
  raise
379
- return run_gen_step(gen_step, may_call=False, async_=async_)
379
+ return run_gen_step(gen_step, async_)
380
380
  return update_wrapper(wrapper, func)
381
381
 
382
382
 
p115client/tool/upload.py CHANGED
@@ -98,9 +98,9 @@ def iter_115_to_115(
98
98
 
99
99
  :return: 迭代器,产生转移结果,有 3 种类型:"good"、"fail" 和 "skip"
100
100
  """
101
- @as_gen_step(async_=async_)
101
+ @as_gen_step
102
102
  def upload(attr: dict, pid: int, /):
103
- @as_gen_step(async_=async_)
103
+ @as_gen_step
104
104
  def read_range_bytes_or_hash(sign_check: str, /):
105
105
  if attr["is_collect"]:
106
106
  url = yield from_client.download_url(
@@ -163,7 +163,7 @@ def iter_115_to_115(
163
163
  else:
164
164
  return {"type": "fail", "attr": attr, "resp": None, "exc": e}
165
165
  key_of_id = "id" if with_root else "parent_id"
166
- @as_gen_step(async_=async_)
166
+ @as_gen_step
167
167
  def get_pid(attr: dict, /):
168
168
  if use_iter_files:
169
169
  if attr["is_collect"] and attr["size"] >= 1024 * 1024 * 115:
@@ -268,9 +268,9 @@ def iter_115_to_115_resume(
268
268
 
269
269
  :return: 迭代器,产生转移结果,有 3 种类型:"good"、"fail" 和 "skip"
270
270
  """
271
- @as_gen_step(async_=async_)
271
+ @as_gen_step
272
272
  def upload(attr: dict, pid: int, /):
273
- @as_gen_step(async_=async_)
273
+ @as_gen_step
274
274
  def read_range_bytes_or_hash(sign_check: str, /):
275
275
  if attr["is_collect"]:
276
276
  url = yield from_client.download_url(
@@ -316,7 +316,7 @@ def iter_115_to_115_resume(
316
316
  return {"type": "fail", "attr": attr, "resp": None, "exc": e}
317
317
  dirt_to_cid: dict[tuple[str, ...], int] = {}
318
318
  key_of_id = "id" if with_root else "parent_id"
319
- @as_gen_step(async_=async_)
319
+ @as_gen_step
320
320
  def get_pid(attr: dict, /):
321
321
  if attr["is_collect"] and attr["size"] >= 1024 * 1024 * 115:
322
322
  return Return({"type": "skip", "attr": attr, "resp": None})
@@ -456,7 +456,7 @@ def iter_115_to_115_resume(
456
456
  arg_func=get_pid,
457
457
  max_workers=max_workers,
458
458
  ))
459
- return run_gen_step_iter(gen_step, may_call=False, async_=async_)
459
+ return run_gen_step_iter(gen_step, async_)
460
460
 
461
461
 
462
462
  @overload
@@ -716,7 +716,7 @@ def multipart_upload_init(
716
716
  upload_data["parts"] = []
717
717
  upload_data["_upload_"] = None
718
718
  return upload_data
719
- return run_gen_step(gen_step, async_=async_)
719
+ return run_gen_step(gen_step, async_)
720
720
 
721
721
 
722
722
  def multipart_upload_url(
@@ -865,5 +865,5 @@ def multipart_upload_complete(
865
865
  async_=async_,
866
866
  **request_kwargs,
867
867
  )
868
- return run_gen_step(gen_step, async_=async_)
868
+ return run_gen_step(gen_step, async_)
869
869