p115client 0.0.5.11.1__py3-none-any.whl → 0.0.5.11.3__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.
- p115client/_upload.py +4 -4
- p115client/client.py +30 -25
- p115client/tool/attr.py +1 -1
- p115client/tool/download.py +38 -40
- p115client/tool/edit.py +2 -2
- p115client/tool/export_dir.py +13 -13
- p115client/tool/fs_files.py +3 -3
- p115client/tool/history.py +4 -4
- p115client/tool/iterdir.py +73 -74
- p115client/tool/life.py +10 -10
- p115client/tool/pool.py +5 -5
- p115client/tool/upload.py +13 -9
- p115client/tool/xys.py +7 -7
- {p115client-0.0.5.11.1.dist-info → p115client-0.0.5.11.3.dist-info}/METADATA +2 -2
- p115client-0.0.5.11.3.dist-info/RECORD +26 -0
- p115client-0.0.5.11.1.dist-info/RECORD +0 -26
- {p115client-0.0.5.11.1.dist-info → p115client-0.0.5.11.3.dist-info}/LICENSE +0 -0
- {p115client-0.0.5.11.1.dist-info → p115client-0.0.5.11.3.dist-info}/WHEEL +0 -0
p115client/_upload.py
CHANGED
@@ -281,11 +281,11 @@ def oss_multipart_part_iter(
|
|
281
281
|
**request_kwargs,
|
282
282
|
)
|
283
283
|
for el in etree.iterfind("Part"):
|
284
|
-
yield Yield({sel.tag: maybe_integer(sel.text) for sel in el}
|
284
|
+
yield Yield({sel.tag: maybe_integer(sel.text) for sel in el})
|
285
285
|
if getattr(etree.find("IsTruncated"), "text") == "false":
|
286
286
|
break
|
287
287
|
params["part-number-marker"] = getattr(etree.find("NextPartNumberMarker"), "text")
|
288
|
-
return run_gen_step_iter(gen_step,
|
288
|
+
return run_gen_step_iter(gen_step, may_call=False, async_=async_)
|
289
289
|
|
290
290
|
|
291
291
|
@overload
|
@@ -679,7 +679,7 @@ def oss_multipart_upload_part_iter(
|
|
679
679
|
))
|
680
680
|
if part["Size"] < partsize:
|
681
681
|
break
|
682
|
-
return run_gen_step_iter(gen_step,
|
682
|
+
return run_gen_step_iter(gen_step, may_call=False, async_=async_)
|
683
683
|
|
684
684
|
|
685
685
|
@overload
|
@@ -927,7 +927,7 @@ def oss_multipart_upload(
|
|
927
927
|
finally:
|
928
928
|
if close_reporthook is not None:
|
929
929
|
yield close_reporthook()
|
930
|
-
return run_gen_step(gen_step,
|
930
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
931
931
|
|
932
932
|
|
933
933
|
# class MultipartUploader:
|
p115client/client.py
CHANGED
@@ -1101,7 +1101,12 @@ def normalize_attr_simple[D: dict[str, Any]](
|
|
1101
1101
|
*,
|
1102
1102
|
dict_cls: None | type[D] = None,
|
1103
1103
|
) -> dict[str, Any] | D:
|
1104
|
-
return normalize_attr(
|
1104
|
+
return normalize_attr(
|
1105
|
+
info,
|
1106
|
+
simple=False,
|
1107
|
+
keep_raw=keep_raw,
|
1108
|
+
dict_cls=dict_cls,
|
1109
|
+
)
|
1105
1110
|
|
1106
1111
|
|
1107
1112
|
class IgnoreCaseDict[V](dict[str, V]):
|
@@ -2317,7 +2322,7 @@ class ClientRequestMixin:
|
|
2317
2322
|
)
|
2318
2323
|
else:
|
2319
2324
|
return qrcode_token
|
2320
|
-
return run_gen_step(gen_step,
|
2325
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
2321
2326
|
|
2322
2327
|
@overload
|
2323
2328
|
@classmethod
|
@@ -2417,7 +2422,7 @@ class ClientRequestMixin:
|
|
2417
2422
|
async_=async_,
|
2418
2423
|
**request_kwargs,
|
2419
2424
|
)
|
2420
|
-
return run_gen_step(gen_step,
|
2425
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
2421
2426
|
|
2422
2427
|
########## Upload API ##########
|
2423
2428
|
|
@@ -2800,7 +2805,7 @@ class ClientRequestMixin:
|
|
2800
2805
|
async_=async_,
|
2801
2806
|
**request_kwargs,
|
2802
2807
|
)
|
2803
|
-
return run_gen_step(gen_step,
|
2808
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
2804
2809
|
|
2805
2810
|
@overload
|
2806
2811
|
def read_bytes_range(
|
@@ -2915,7 +2920,7 @@ class ClientRequestMixin:
|
|
2915
2920
|
async_=async_,
|
2916
2921
|
**request_kwargs,
|
2917
2922
|
)
|
2918
|
-
return run_gen_step(gen_step,
|
2923
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
2919
2924
|
|
2920
2925
|
|
2921
2926
|
class P115OpenClient(ClientRequestMixin):
|
@@ -3011,7 +3016,7 @@ class P115OpenClient(ClientRequestMixin):
|
|
3011
3016
|
self.refresh_token = data["refresh_token"]
|
3012
3017
|
self.access_token = data["access_token"]
|
3013
3018
|
return self
|
3014
|
-
return run_gen_step(gen_step,
|
3019
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
3015
3020
|
|
3016
3021
|
@classmethod
|
3017
3022
|
def from_token(cls, /, access_token: str, refresh_token: str) -> P115OpenClient:
|
@@ -3078,7 +3083,7 @@ class P115OpenClient(ClientRequestMixin):
|
|
3078
3083
|
self.refresh_token = data["refresh_token"]
|
3079
3084
|
access_token = self.access_token = data["access_token"]
|
3080
3085
|
return access_token
|
3081
|
-
return run_gen_step(gen_step,
|
3086
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
3082
3087
|
|
3083
3088
|
@overload
|
3084
3089
|
def download_url(
|
@@ -4804,7 +4809,7 @@ class P115OpenClient(ClientRequestMixin):
|
|
4804
4809
|
check_response(resp)
|
4805
4810
|
resp["data"] = {**payload, **resp["data"], "sha1": filesha1, "cid": pid}
|
4806
4811
|
return resp
|
4807
|
-
return run_gen_step(gen_step,
|
4812
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
4808
4813
|
|
4809
4814
|
@overload
|
4810
4815
|
def upload_file(
|
@@ -5148,7 +5153,7 @@ class P115OpenClient(ClientRequestMixin):
|
|
5148
5153
|
async_=async_, # type: ignore
|
5149
5154
|
**request_kwargs,
|
5150
5155
|
)
|
5151
|
-
return run_gen_step(gen_step,
|
5156
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
5152
5157
|
|
5153
5158
|
@overload
|
5154
5159
|
def user_info(
|
@@ -5529,7 +5534,7 @@ class P115Client(P115OpenClient):
|
|
5529
5534
|
)
|
5530
5535
|
setattr(self, "check_for_relogin", check_for_relogin)
|
5531
5536
|
return self
|
5532
|
-
return run_gen_step(gen_step,
|
5537
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
5533
5538
|
|
5534
5539
|
@locked_cacheproperty
|
5535
5540
|
def request_lock(self, /) -> Lock:
|
@@ -5701,7 +5706,7 @@ class P115Client(P115OpenClient):
|
|
5701
5706
|
check_response(resp)
|
5702
5707
|
setattr(self, "cookies", resp["data"]["cookie"])
|
5703
5708
|
return self
|
5704
|
-
return run_gen_step(gen_step,
|
5709
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
5705
5710
|
|
5706
5711
|
@overload
|
5707
5712
|
def login_with_app(
|
@@ -5833,7 +5838,7 @@ class P115Client(P115OpenClient):
|
|
5833
5838
|
async_=async_,
|
5834
5839
|
**request_kwargs,
|
5835
5840
|
)
|
5836
|
-
return run_gen_step(gen_step,
|
5841
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
5837
5842
|
|
5838
5843
|
@overload
|
5839
5844
|
def login_without_app(
|
@@ -5891,7 +5896,7 @@ class P115Client(P115OpenClient):
|
|
5891
5896
|
)
|
5892
5897
|
check_response(resp)
|
5893
5898
|
return uid
|
5894
|
-
return run_gen_step(gen_step,
|
5899
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
5895
5900
|
|
5896
5901
|
@overload
|
5897
5902
|
def login_with_open(
|
@@ -5943,7 +5948,7 @@ class P115Client(P115OpenClient):
|
|
5943
5948
|
resp = yield self.login_qrcode_scan_confirm(login_uid, async_=async_, **request_kwargs)
|
5944
5949
|
check_response(resp)
|
5945
5950
|
return self.login_qrcode_access_token_open(login_uid, async_=async_, **request_kwargs)
|
5946
|
-
return run_gen_step(gen_step,
|
5951
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
5947
5952
|
|
5948
5953
|
@overload
|
5949
5954
|
def login_another_app(
|
@@ -6087,7 +6092,7 @@ class P115Client(P115OpenClient):
|
|
6087
6092
|
if self is not inst and ssoent == inst.login_ssoent:
|
6088
6093
|
warn(f"login with the same ssoent {ssoent!r}, {self!r} will expire within 60 seconds", category=P115Warning)
|
6089
6094
|
return inst
|
6090
|
-
return run_gen_step(gen_step,
|
6095
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
6091
6096
|
|
6092
6097
|
@overload
|
6093
6098
|
def login_another_open(
|
@@ -6181,7 +6186,7 @@ class P115Client(P115OpenClient):
|
|
6181
6186
|
inst.access_token = data["access_token"]
|
6182
6187
|
inst.app_id = app_id
|
6183
6188
|
return inst
|
6184
|
-
return run_gen_step(gen_step,
|
6189
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
6185
6190
|
|
6186
6191
|
@overload
|
6187
6192
|
@classmethod
|
@@ -6300,7 +6305,7 @@ class P115Client(P115OpenClient):
|
|
6300
6305
|
resp = yield cls.login_qrcode_scan_result(uid, app, async_=async_, **request_kwargs)
|
6301
6306
|
cookies = check_response(resp)["data"]["cookie"]
|
6302
6307
|
return cls(cookies, check_for_relogin=check_for_relogin)
|
6303
|
-
return run_gen_step(gen_step,
|
6308
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
6304
6309
|
|
6305
6310
|
@overload
|
6306
6311
|
def logout(
|
@@ -6575,7 +6580,7 @@ class P115Client(P115OpenClient):
|
|
6575
6580
|
if check and isinstance(resp, dict):
|
6576
6581
|
check_response(resp)
|
6577
6582
|
return resp
|
6578
|
-
return run_gen_step(gen_step,
|
6583
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
6579
6584
|
|
6580
6585
|
def request(
|
6581
6586
|
self,
|
@@ -7434,7 +7439,7 @@ class P115Client(P115OpenClient):
|
|
7434
7439
|
async_=async_,
|
7435
7440
|
**request_kwargs,
|
7436
7441
|
)
|
7437
|
-
return run_gen_step(gen_step,
|
7442
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
7438
7443
|
|
7439
7444
|
########## Download API ##########
|
7440
7445
|
|
@@ -16009,7 +16014,7 @@ class P115Client(P115OpenClient):
|
|
16009
16014
|
if device is None:
|
16010
16015
|
return None
|
16011
16016
|
return device["icon"]
|
16012
|
-
return run_gen_step(gen_step,
|
16017
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
16013
16018
|
|
16014
16019
|
@overload
|
16015
16020
|
def login_open_auth_detail(
|
@@ -16533,7 +16538,7 @@ class P115Client(P115OpenClient):
|
|
16533
16538
|
return get_default_request()(url=api, async_=async_, **request_kwargs)
|
16534
16539
|
else:
|
16535
16540
|
return request(url=api, **request_kwargs)
|
16536
|
-
return run_gen_step(gen_step,
|
16541
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
16537
16542
|
|
16538
16543
|
@overload
|
16539
16544
|
def logout_by_ssoent(
|
@@ -20427,7 +20432,7 @@ class P115Client(P115OpenClient):
|
|
20427
20432
|
if resp["state"]:
|
20428
20433
|
self.user_key = resp["data"]["userkey"]
|
20429
20434
|
return resp
|
20430
|
-
return run_gen_step(gen_step,
|
20435
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
20431
20436
|
|
20432
20437
|
@overload
|
20433
20438
|
def upload_resume(
|
@@ -20794,7 +20799,7 @@ class P115Client(P115OpenClient):
|
|
20794
20799
|
"pickcode": resp["pickcode"],
|
20795
20800
|
}
|
20796
20801
|
return resp
|
20797
|
-
return run_gen_step(gen_step,
|
20802
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
20798
20803
|
|
20799
20804
|
@overload
|
20800
20805
|
def upload_file_sample(
|
@@ -20930,7 +20935,7 @@ class P115Client(P115OpenClient):
|
|
20930
20935
|
async_=async_,
|
20931
20936
|
**request_kwargs,
|
20932
20937
|
)
|
20933
|
-
return run_gen_step(gen_step,
|
20938
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
20934
20939
|
|
20935
20940
|
@overload # type: ignore
|
20936
20941
|
def upload_file(
|
@@ -21289,7 +21294,7 @@ class P115Client(P115OpenClient):
|
|
21289
21294
|
async_=async_, # type: ignore
|
21290
21295
|
**request_kwargs,
|
21291
21296
|
)
|
21292
|
-
return run_gen_step(gen_step,
|
21297
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
21293
21298
|
|
21294
21299
|
########## User API ##########
|
21295
21300
|
|
p115client/tool/attr.py
CHANGED
@@ -72,7 +72,7 @@ def get_attr(
|
|
72
72
|
resp = yield client.fs_file(id, async_=async_, **request_kwargs)
|
73
73
|
check_response(resp)
|
74
74
|
return normalize_attr_web(resp["data"][0])
|
75
|
-
return run_gen_step(gen_step,
|
75
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
76
76
|
|
77
77
|
|
78
78
|
def type_of_attr(attr: Mapping, /) -> int:
|
p115client/tool/download.py
CHANGED
@@ -145,7 +145,7 @@ def batch_get_url(
|
|
145
145
|
for id, info in resp["data"].items()
|
146
146
|
if info["url"]
|
147
147
|
}
|
148
|
-
return run_gen_step(gen_step,
|
148
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
149
149
|
|
150
150
|
|
151
151
|
@overload
|
@@ -227,8 +227,8 @@ def iter_url_batches(
|
|
227
227
|
sha1=info["sha1"],
|
228
228
|
is_directory=False,
|
229
229
|
headers=headers,
|
230
|
-
)
|
231
|
-
return run_gen_step_iter(gen_step,
|
230
|
+
))
|
231
|
+
return run_gen_step_iter(gen_step, may_call=False, async_=async_)
|
232
232
|
|
233
233
|
|
234
234
|
@overload
|
@@ -376,8 +376,7 @@ def iter_files_with_url(
|
|
376
376
|
app=app,
|
377
377
|
user_agent=user_agent,
|
378
378
|
**params, # type: ignore
|
379
|
-
)
|
380
|
-
may_await=False,
|
379
|
+
)
|
381
380
|
)
|
382
381
|
return
|
383
382
|
if headers := request_kwargs.get("headers"):
|
@@ -403,8 +402,8 @@ def iter_files_with_url(
|
|
403
402
|
async_=async_,
|
404
403
|
**request_kwargs,
|
405
404
|
)
|
406
|
-
yield Yield(attr
|
407
|
-
return run_gen_step_iter(gen_step,
|
405
|
+
yield Yield(attr)
|
406
|
+
return run_gen_step_iter(gen_step, may_call=False, async_=async_)
|
408
407
|
|
409
408
|
|
410
409
|
@overload
|
@@ -536,8 +535,7 @@ def iter_images_with_url(
|
|
536
535
|
suffixes=suffix,
|
537
536
|
app=app,
|
538
537
|
**params, # type: ignore
|
539
|
-
)
|
540
|
-
may_await=False,
|
538
|
+
)
|
541
539
|
)
|
542
540
|
return
|
543
541
|
with with_iter_next(it) as get_next:
|
@@ -562,8 +560,8 @@ def iter_images_with_url(
|
|
562
560
|
async_=async_,
|
563
561
|
**request_kwargs,
|
564
562
|
)
|
565
|
-
yield Yield(attr
|
566
|
-
return run_gen_step_iter(gen_step,
|
563
|
+
yield Yield(attr)
|
564
|
+
return run_gen_step_iter(gen_step, may_call=False, async_=async_)
|
567
565
|
|
568
566
|
|
569
567
|
@overload
|
@@ -728,7 +726,7 @@ def iter_subtitles_with_url(
|
|
728
726
|
if subtitles:
|
729
727
|
for attr in items:
|
730
728
|
attr["url"] = subtitles[attr["sha1"]]
|
731
|
-
yield Yield(attr
|
729
|
+
yield Yield(attr)
|
732
730
|
else:
|
733
731
|
for attr in items:
|
734
732
|
if attr.get("violated", False):
|
@@ -747,8 +745,8 @@ def iter_subtitles_with_url(
|
|
747
745
|
async_=async_,
|
748
746
|
**request_kwargs,
|
749
747
|
)
|
750
|
-
yield Yield(attr
|
751
|
-
return run_gen_step_iter(gen_step,
|
748
|
+
yield Yield(attr)
|
749
|
+
return run_gen_step_iter(gen_step, may_call=False, async_=async_)
|
752
750
|
|
753
751
|
|
754
752
|
@overload
|
@@ -832,14 +830,13 @@ def iter_subtitle_batches(
|
|
832
830
|
)
|
833
831
|
check_response(resp)
|
834
832
|
yield YieldFrom(
|
835
|
-
filter(lambda info: "file_id" in info, resp["data"]["list"])
|
836
|
-
may_await=False,
|
833
|
+
filter(lambda info: "file_id" in info, resp["data"]["list"])
|
837
834
|
)
|
838
835
|
except (StopIteration, StopAsyncIteration):
|
839
836
|
pass
|
840
837
|
finally:
|
841
838
|
yield client.fs_delete(scid, async_=async_, **request_kwargs)
|
842
|
-
return run_gen_step_iter(gen_step,
|
839
|
+
return run_gen_step_iter(gen_step, may_call=False, async_=async_)
|
843
840
|
|
844
841
|
|
845
842
|
@overload
|
@@ -1080,7 +1077,7 @@ def make_strm(
|
|
1080
1077
|
if use_abspath is not None:
|
1081
1078
|
params["path_already"] = path_already
|
1082
1079
|
yield (async_batch if async_ else thread_batch)(
|
1083
|
-
lambda attr: run_gen_step(save(attr),
|
1080
|
+
lambda attr: run_gen_step(save(attr), may_call=False, async_=async_),
|
1084
1081
|
(iter_files if use_abspath is None else iter_files_with_path)(
|
1085
1082
|
client,
|
1086
1083
|
cid,
|
@@ -1117,7 +1114,7 @@ def make_strm(
|
|
1117
1114
|
"ignore": ignored,
|
1118
1115
|
"remove": removed,
|
1119
1116
|
}
|
1120
|
-
return run_gen_step(gen_step,
|
1117
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
1121
1118
|
|
1122
1119
|
|
1123
1120
|
@overload
|
@@ -1185,7 +1182,7 @@ def iter_download_nodes(
|
|
1185
1182
|
resp = yield get_nodes(payload)
|
1186
1183
|
check_response(resp)
|
1187
1184
|
data = resp["data"]
|
1188
|
-
yield YieldFrom(data["list"]
|
1185
|
+
yield YieldFrom(data["list"])
|
1189
1186
|
if not data["has_next_page"]:
|
1190
1187
|
break
|
1191
1188
|
else:
|
@@ -1264,11 +1261,11 @@ def iter_download_nodes(
|
|
1264
1261
|
break
|
1265
1262
|
elif isinstance(ls, BaseException):
|
1266
1263
|
raise ls
|
1267
|
-
yield YieldFrom(ls
|
1264
|
+
yield YieldFrom(ls)
|
1268
1265
|
finally:
|
1269
1266
|
yield shutdown()
|
1270
1267
|
if pickcode:
|
1271
|
-
return run_gen_step_iter(gen_step(pickcode),
|
1268
|
+
return run_gen_step_iter(gen_step(pickcode), may_call=False, async_=async_)
|
1272
1269
|
else:
|
1273
1270
|
def chain():
|
1274
1271
|
with with_iter_next(iterdir(
|
@@ -1284,14 +1281,14 @@ def iter_download_nodes(
|
|
1284
1281
|
attr = yield get_next()
|
1285
1282
|
if not files:
|
1286
1283
|
yield Yield(
|
1287
|
-
{"fid": str(attr["id"]), "pid": "0", "fn": attr["name"]}
|
1288
|
-
may_await=False,
|
1284
|
+
{"fid": str(attr["id"]), "pid": "0", "fn": attr["name"]}
|
1289
1285
|
)
|
1290
|
-
yield YieldFrom(
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1286
|
+
yield YieldFrom(run_gen_step_iter(
|
1287
|
+
gen_step(attr["pickcode"]),
|
1288
|
+
may_call=False,
|
1289
|
+
async_=async_,
|
1290
|
+
))
|
1291
|
+
return run_gen_step_iter(chain, may_call=False, async_=async_)
|
1295
1292
|
|
1296
1293
|
|
1297
1294
|
@overload
|
@@ -1436,12 +1433,13 @@ def iter_download_files(
|
|
1436
1433
|
"pickcode": attr["pickcode"],
|
1437
1434
|
"size": attr["size"],
|
1438
1435
|
**defaults,
|
1439
|
-
}
|
1436
|
+
})
|
1440
1437
|
for pickcode in pickcodes:
|
1441
|
-
yield YieldFrom(
|
1442
|
-
|
1443
|
-
|
1444
|
-
|
1438
|
+
yield YieldFrom(run_gen_step_iter(
|
1439
|
+
gen_step(pickcode),
|
1440
|
+
may_call=False,
|
1441
|
+
async_=async_,
|
1442
|
+
))
|
1445
1443
|
return
|
1446
1444
|
if not pickcode:
|
1447
1445
|
resp = yield client.fs_file_skim(cid, async_=async_, **request_kwargs)
|
@@ -1478,7 +1476,7 @@ def iter_download_files(
|
|
1478
1476
|
finally:
|
1479
1477
|
ancestors_loaded = True
|
1480
1478
|
if async_:
|
1481
|
-
task: Any = create_task(run_gen_step(load_ancestors,
|
1479
|
+
task: Any = create_task(run_gen_step(load_ancestors, may_call=False, async_=True))
|
1482
1480
|
else:
|
1483
1481
|
task = run_as_thread(run_gen_step, load_ancestors)
|
1484
1482
|
cache: list[dict] = []
|
@@ -1495,9 +1493,9 @@ def iter_download_files(
|
|
1495
1493
|
while True:
|
1496
1494
|
info = yield get_next()
|
1497
1495
|
if ancestors_loaded is None:
|
1498
|
-
yield Yield(norm_attr(info)
|
1496
|
+
yield Yield(norm_attr(info))
|
1499
1497
|
elif ancestors_loaded:
|
1500
|
-
yield YieldFrom(map(norm_attr, cache)
|
1498
|
+
yield YieldFrom(map(norm_attr, cache))
|
1501
1499
|
cache.clear()
|
1502
1500
|
if async_:
|
1503
1501
|
yield task
|
@@ -1511,8 +1509,8 @@ def iter_download_files(
|
|
1511
1509
|
yield task
|
1512
1510
|
else:
|
1513
1511
|
task.result()
|
1514
|
-
yield YieldFrom(map(norm_attr, cache)
|
1515
|
-
return run_gen_step_iter(gen_step,
|
1512
|
+
yield YieldFrom(map(norm_attr, cache))
|
1513
|
+
return run_gen_step_iter(gen_step, may_call=False, async_=async_)
|
1516
1514
|
|
1517
1515
|
|
1518
1516
|
@overload
|
@@ -1588,5 +1586,5 @@ def get_remaining_open_count(
|
|
1588
1586
|
for f in cache:
|
1589
1587
|
f.close()
|
1590
1588
|
return len(cache)
|
1591
|
-
return run_gen_step(gen_step,
|
1589
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
1592
1590
|
|
p115client/tool/edit.py
CHANGED
@@ -91,7 +91,7 @@ def update_abstract(
|
|
91
91
|
chunked(ids, batch_size),
|
92
92
|
max_workers=max_workers
|
93
93
|
))
|
94
|
-
return run_gen_step(gen_step,
|
94
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
95
95
|
|
96
96
|
|
97
97
|
@overload
|
@@ -634,5 +634,5 @@ def batch_unstar(
|
|
634
634
|
async_=async_, # type: ignore
|
635
635
|
**request_kwargs,
|
636
636
|
)
|
637
|
-
return run_gen_step(gen_step,
|
637
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
638
638
|
|
p115client/tool/export_dir.py
CHANGED
@@ -95,7 +95,7 @@ def parse_export_dir_as_dict_iter(
|
|
95
95
|
stack[depth]["name"] += "\n" + line[:-1]
|
96
96
|
continue
|
97
97
|
else:
|
98
|
-
yield Yield(stack[depth]
|
98
|
+
yield Yield(stack[depth])
|
99
99
|
name = m[1]
|
100
100
|
depth = (len(line) - len(name)) // 2 - 1
|
101
101
|
item = {
|
@@ -110,7 +110,7 @@ def parse_export_dir_as_dict_iter(
|
|
110
110
|
push(item)
|
111
111
|
except (StopIteration, StopAsyncIteration):
|
112
112
|
if depth:
|
113
|
-
yield Yield(stack[depth]
|
113
|
+
yield Yield(stack[depth])
|
114
114
|
finally:
|
115
115
|
if close_file:
|
116
116
|
if async_:
|
@@ -120,7 +120,7 @@ def parse_export_dir_as_dict_iter(
|
|
120
120
|
yield ensure_async(close, threaded=True)
|
121
121
|
elif callable(close := getattr(file, "close", None)):
|
122
122
|
close()
|
123
|
-
return run_gen_step_iter(gen_step,
|
123
|
+
return run_gen_step_iter(gen_step, may_call=False, async_=async_)
|
124
124
|
|
125
125
|
|
126
126
|
@overload
|
@@ -206,7 +206,7 @@ def parse_export_dir_as_path_iter(
|
|
206
206
|
stack[depth] += "\n" + line[:-1]
|
207
207
|
continue
|
208
208
|
elif depth:
|
209
|
-
yield Yield(stack[depth]
|
209
|
+
yield Yield(stack[depth])
|
210
210
|
else:
|
211
211
|
yield "/" if root == "根目录" else root
|
212
212
|
name = m[1]
|
@@ -220,7 +220,7 @@ def parse_export_dir_as_path_iter(
|
|
220
220
|
push(path)
|
221
221
|
except (StopIteration, StopAsyncIteration):
|
222
222
|
if depth:
|
223
|
-
yield Yield(stack[depth]
|
223
|
+
yield Yield(stack[depth])
|
224
224
|
finally:
|
225
225
|
if close_file:
|
226
226
|
if async_:
|
@@ -230,7 +230,7 @@ def parse_export_dir_as_path_iter(
|
|
230
230
|
yield ensure_async(close, threaded=True)
|
231
231
|
elif callable(close := getattr(file, "close", None)):
|
232
232
|
close()
|
233
|
-
return run_gen_step_iter(gen_step,
|
233
|
+
return run_gen_step_iter(gen_step, may_call=False, async_=async_)
|
234
234
|
|
235
235
|
|
236
236
|
@overload
|
@@ -298,7 +298,7 @@ def parse_export_dir_as_patht_iter(
|
|
298
298
|
stack[depth] += "\n" + line[:-1]
|
299
299
|
continue
|
300
300
|
else:
|
301
|
-
yield Yield(stack[:depth+1]
|
301
|
+
yield Yield(stack[:depth+1])
|
302
302
|
name = m[1]
|
303
303
|
depth = (len(line) - len(name)) // 2 - from_top_root
|
304
304
|
try:
|
@@ -307,7 +307,7 @@ def parse_export_dir_as_patht_iter(
|
|
307
307
|
push(name)
|
308
308
|
except (StopIteration, StopAsyncIteration):
|
309
309
|
if depth:
|
310
|
-
yield Yield(stack[:depth+1]
|
310
|
+
yield Yield(stack[:depth+1])
|
311
311
|
finally:
|
312
312
|
if close_file:
|
313
313
|
if async_:
|
@@ -317,7 +317,7 @@ def parse_export_dir_as_patht_iter(
|
|
317
317
|
yield ensure_async(close, threaded=True)
|
318
318
|
elif callable(close := getattr(file, "close", None)):
|
319
319
|
close()
|
320
|
-
return run_gen_step_iter(gen_step,
|
320
|
+
return run_gen_step_iter(gen_step, may_call=False, async_=async_)
|
321
321
|
|
322
322
|
|
323
323
|
@overload
|
@@ -406,7 +406,7 @@ def export_dir(
|
|
406
406
|
payload["layer_limit"] = layer_limit
|
407
407
|
resp = yield client.fs_export_dir(payload, async_=async_, **request_kwargs)
|
408
408
|
return check_response(resp)["data"]["export_id"]
|
409
|
-
return run_gen_step(gen_step,
|
409
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
410
410
|
|
411
411
|
|
412
412
|
@overload
|
@@ -486,7 +486,7 @@ def export_dir_result(
|
|
486
486
|
raise TimeoutError(export_id)
|
487
487
|
if check_interval:
|
488
488
|
yield do_sleep(min(check_interval, remaining_seconds))
|
489
|
-
return run_gen_step(gen_step,
|
489
|
+
return run_gen_step(gen_step, may_call=False, async_=async_)
|
490
490
|
|
491
491
|
|
492
492
|
@overload
|
@@ -629,7 +629,7 @@ def export_dir_parse_iter(
|
|
629
629
|
file_wrapper: IO = AsyncTextIOWrapper(AsyncBufferedReader(file), encoding="utf-16", newline="\n")
|
630
630
|
else:
|
631
631
|
file_wrapper = TextIOWrapper(BufferedReader(file), encoding="utf-16", newline="\n")
|
632
|
-
yield YieldFrom(parse_iter(file_wrapper)
|
632
|
+
yield YieldFrom(parse_iter(file_wrapper)) # type: ignore
|
633
633
|
finally:
|
634
634
|
if async_:
|
635
635
|
if callable(aclose := getattr(file, "aclose", None)):
|
@@ -645,5 +645,5 @@ def export_dir_parse_iter(
|
|
645
645
|
async_=async_, # type: ignore
|
646
646
|
**request_kwargs,
|
647
647
|
)
|
648
|
-
return run_gen_step_iter(gen_step,
|
648
|
+
return run_gen_step_iter(gen_step, may_call=False, async_=async_)
|
649
649
|
|
p115client/tool/fs_files.py
CHANGED
@@ -145,13 +145,13 @@ def iter_fs_files(
|
|
145
145
|
return resp
|
146
146
|
def gen_step():
|
147
147
|
while True:
|
148
|
-
resp = yield run_gen_step(get_files(payload),
|
148
|
+
resp = yield run_gen_step(get_files(payload), may_call=False, async_=async_)
|
149
149
|
payload["limit"] = page_size
|
150
|
-
yield Yield(resp
|
150
|
+
yield Yield(resp)
|
151
151
|
payload["offset"] += len(resp["data"])
|
152
152
|
if payload["offset"] >= count:
|
153
153
|
break
|
154
|
-
return run_gen_step_iter(gen_step,
|
154
|
+
return run_gen_step_iter(gen_step, may_call=False, async_=async_)
|
155
155
|
|
156
156
|
|
157
157
|
def iter_fs_files_threaded(
|
p115client/tool/history.py
CHANGED
@@ -105,7 +105,7 @@ def iter_history_list_once(
|
|
105
105
|
if from_id and event_id <= from_id or from_time and int(event["update_time"]) < from_time:
|
106
106
|
return
|
107
107
|
if event_id not in seen:
|
108
|
-
yield Yield(event
|
108
|
+
yield Yield(event)
|
109
109
|
seen_add(event_id)
|
110
110
|
offset += len(events)
|
111
111
|
if offset >= int(resp["data"]["total"]):
|
@@ -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,
|
122
|
+
return run_gen_step_iter(gen_step, may_call=False, async_=async_)
|
123
123
|
|
124
124
|
|
125
125
|
@overload
|
@@ -219,6 +219,6 @@ def iter_history_list(
|
|
219
219
|
from_id = int(event["id"])
|
220
220
|
from_time = int(event["update_time"])
|
221
221
|
sub_first_loop = False
|
222
|
-
yield Yield(event
|
223
|
-
return run_gen_step_iter(gen_step,
|
222
|
+
yield Yield(event)
|
223
|
+
return run_gen_step_iter(gen_step, may_call=False, async_=async_)
|
224
224
|
|