reykit 1.1.82__py3-none-any.whl → 1.1.84__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.
reykit/rmonkey.py CHANGED
@@ -9,9 +9,6 @@
9
9
  """
10
10
 
11
11
 
12
- from __future__ import annotations
13
-
14
-
15
12
  __all__ = (
16
13
  'monkey_sqlalchemy_result_more_fetch',
17
14
  'monkey_sqlalchemy_row_index_field',
@@ -47,7 +44,6 @@ def monkey_sqlalchemy_result_more_fetch():
47
44
 
48
45
  # Import.
49
46
  from typing import Self
50
- from types import MethodType
51
47
  from sqlalchemy.engine.cursor import CursorResult
52
48
  from pandas import DataFrame, NA, concat
53
49
  from .rbase import Base
reykit/rnet.py CHANGED
@@ -211,22 +211,8 @@ def get_content_type(file: str | bytes) -> str | None:
211
211
  def request(
212
212
  url: str,
213
213
  params: dict | None = None,
214
+ data: dict | str | bytes | None = None,
214
215
  *,
215
- headers: dict[str, str] = {},
216
- timeout: float | None = None,
217
- proxies: dict[str, str] = {},
218
- stream: bool = False,
219
- verify: bool = False,
220
- method: Literal['get', 'post', 'put', 'patch', 'delete', 'options', 'head'] = Literal['get'],
221
- check: bool | int | Iterable[int] = False
222
- ) -> Response: ...
223
-
224
- @overload
225
- def request(
226
- url: str,
227
- params: dict | None = None,
228
- *,
229
- data: dict | str | bytes,
230
216
  files: dict[str, str | bytes | tuple[str | bytes, dict]] | None = None,
231
217
  headers: dict[str, str] = {},
232
218
  timeout: float | None = None,
@@ -237,28 +223,13 @@ def request(
237
223
  check: bool | int | Iterable[int] = False
238
224
  ) -> Response: ...
239
225
 
240
- @overload
241
- def request(
242
- url: str,
243
- params: dict | None = None,
244
- *,
245
- data: dict | str | bytes | None = None,
246
- files: dict[str, str | bytes | tuple[str | bytes, dict]],
247
- headers: dict[str, str] = {},
248
- timeout: float | None = None,
249
- proxies: dict[str, str] = {},
250
- stream: bool = False,
251
- verify: bool = False,
252
- method: Literal['get', 'post', 'put', 'patch', 'delete', 'options', 'head'] | None = Literal['post'],
253
- check: bool | int | Iterable[int] = False
254
- ) -> Response: ...
255
226
 
256
227
  @overload
257
228
  def request(
258
229
  url: str,
259
230
  params: dict | None = None,
260
231
  *,
261
- json: dict,
232
+ json: dict | None = None,
262
233
  headers: dict[str, str] = {},
263
234
  timeout: float | None = None,
264
235
  proxies: dict[str, str] = {},
@@ -312,7 +283,7 @@ def request(
312
283
  - `None`: No setup.
313
284
  - `dict[str, str]`: Name and use IP of each protocol.
314
285
  stream : Whether use stream request.
315
- verify : Whether verify certificate.
286
+ verify : Whether verify SSL certificate.
316
287
  method : Request method.
317
288
  - `None`: Automatic judge.
318
289
  When parameter `data` or `json` or `files` not has value, then request method is `get`.
reykit/ros.py CHANGED
@@ -9,7 +9,6 @@
9
9
  """
10
10
 
11
11
 
12
- from __future__ import annotations
13
12
  from typing import Any, Literal, TextIO, BinaryIO, overload, TYPE_CHECKING
14
13
  if TYPE_CHECKING:
15
14
  from _typeshed import OpenTextMode, OpenBinaryMode
@@ -297,7 +296,7 @@ def read_file_bytes(source: FileSourceBytes) -> bytes:
297
296
  return file_bytes
298
297
 
299
298
 
300
- def read_toml(path: str | File) -> dict[str, Any]:
299
+ def read_toml(path: 'str | File') -> dict[str, Any]:
301
300
  """
302
301
  Read and parse TOML file.
303
302
  Treat nan as a None or null value.
@@ -353,12 +352,12 @@ class File(Base):
353
352
 
354
353
 
355
354
  @overload
356
- def open(self, mode: OpenBinaryMode = 'wb+') -> BinaryIO: ...
355
+ def open(self, mode: 'OpenBinaryMode' = 'wb+') -> BinaryIO: ...
357
356
 
358
357
  @overload
359
- def open(self, mode: OpenTextMode, encode: str = 'utf-8') -> TextIO: ...
358
+ def open(self, mode: 'OpenTextMode', encode: str = 'utf-8') -> TextIO: ...
360
359
 
361
- def open(self, mode: OpenTextMode | OpenBinaryMode = 'wb+', encode: str = 'utf-8') -> TextIO | BinaryIO:
360
+ def open(self, mode: 'OpenTextMode | OpenBinaryMode' = 'wb+', encode: str = 'utf-8') -> TextIO | BinaryIO:
362
361
  """
363
362
  Open file.
364
363
 
@@ -824,7 +823,7 @@ class File(Base):
824
823
  return file_bytes
825
824
 
826
825
 
827
- def __contains__(self, value: str | bytes) -> bool:
826
+ def __contains__(self, value: 'str | bytes') -> bool:
828
827
  """
829
828
  Judge if file text contain value.
830
829
 
reykit/rrand.py CHANGED
@@ -9,7 +9,6 @@
9
9
  """
10
10
 
11
11
 
12
- from __future__ import annotations
13
12
  from typing import Literal, Self, overload
14
13
  from collections.abc import Sequence
15
14
  from string import digits as string_digits, ascii_letters as string_ascii_letters, punctuation as string_punctuation
@@ -39,7 +38,7 @@ class ConfigRandom(Base, metaclass=ConfigMeta):
39
38
  """
40
39
 
41
40
  # RRandom.
42
- _rrandom_dict: dict[int, RandomSeed] = {}
41
+ _rrandom_dict: dict[int, 'RandomSeed'] = {}
43
42
 
44
43
 
45
44
  class RandomSeed(Base):
reykit/rtask.py CHANGED
@@ -45,6 +45,9 @@ __all__ = (
45
45
  )
46
46
 
47
47
 
48
+ type CallableCoroutine = Coroutine | ATask | Callable[[], Coroutine]
49
+
50
+
48
51
  class ThreadPool(Base):
49
52
  """
50
53
  Thread pool type.
@@ -307,26 +310,51 @@ class ThreadPool(Base):
307
310
  def async_run(
308
311
  coroutine: Coroutine[Any, Any, T] | ATask[Any, Any, T] | Callable[[], Coroutine[Any, Any, T]],
309
312
  *,
310
- return_exceptions: bool = False
313
+ before: CallableCoroutine | None = None,
314
+ after: CallableCoroutine | None = None,
315
+ return_exc: bool = False
311
316
  ) -> T: ...
312
317
 
313
318
  @overload
314
319
  def async_run(
315
- *coroutines: Coroutine[Any, Any, T] | ATask[Any, Any, T] | Callable[[], Coroutine[Any, Any, T]],
316
- return_exceptions: bool = False
320
+ *coroutines: Coroutine[Any, Any, T] | ATask[Any, Any, T] | Callable[[], Coroutine[Any, Any, T]],
321
+ before: CallableCoroutine | None = None,
322
+ after: CallableCoroutine | None = None,
323
+ return_exc: bool = False
317
324
  ) -> list[T]: ...
318
325
 
326
+ @overload
319
327
  def async_run(
320
- *coroutines: Coroutine[Any, Any, T] | ATask[Any, Any, T] | Callable[[], Coroutine[Any, Any, T]],
321
- return_exceptions: bool = False
328
+ coroutine: Coroutine[Any, Any, T] | ATask[Any, Any, T] | Callable[[], Coroutine[Any, Any, T]],
329
+ *,
330
+ before: CallableCoroutine | None = None,
331
+ after: CallableCoroutine | None = None,
332
+ return_exc: Literal[True]
333
+ ) -> T | BaseException: ...
334
+
335
+ @overload
336
+ def async_run(
337
+ *coroutines: Coroutine[Any, Any, T] | ATask[Any, Any, T] | Callable[[], Coroutine[Any, Any, T]],
338
+ before: CallableCoroutine | None = None,
339
+ after: CallableCoroutine | None = None,
340
+ return_exc: Literal[True]
341
+ ) -> list[T] | BaseException: ...
342
+
343
+ def async_run(
344
+ *coroutines: Coroutine[Any, Any, T] | ATask[Any, Any, T] | Callable[[], Coroutine[Any, Any, T]],
345
+ before: CallableCoroutine | None = None,
346
+ after: CallableCoroutine | None = None,
347
+ return_exc: bool = False
322
348
  ) -> T | list[T]:
323
349
  """
324
350
  Asynchronous run coroutines.
325
351
 
326
352
  Parameters
327
353
  ----------
328
- coroutines : `Coroutine` instances or `ATask` instances or `Coroutine` function.
329
- return_exceptions : Whether return exception instances, otherwise throw first exception.
354
+ coroutines : `Coroutine` instances or `ATask` instances or `Coroutine` functions.
355
+ before : `Coroutine` instance or `ATask` instance or `Coroutine` function of execute before execute.
356
+ after : `Coroutine` instance or `ATask` instance or `Coroutine` function of execute after execute.
357
+ return_exc : Whether return exception instances, otherwise throw first exception.
330
358
 
331
359
  Returns
332
360
  -------
@@ -340,9 +368,14 @@ def async_run(
340
368
  else coroutine
341
369
  for coroutine in coroutines
342
370
  ]
371
+ if asyncio_iscoroutinefunction(before):
372
+ before = before()
373
+ if asyncio_iscoroutinefunction(after):
374
+ after = after()
375
+
343
376
 
344
377
  # Define.
345
- async def async_run_coroutine() -> list:
378
+ async def async_run_coroutine() -> list[T]:
346
379
  """
347
380
  Asynchronous run coroutines.
348
381
 
@@ -351,8 +384,16 @@ def async_run(
351
384
  Run result list.
352
385
  """
353
386
 
387
+ # Before.
388
+ if before is not None:
389
+ await before
390
+
354
391
  # Gather.
355
- results = await asyncio_gather(*coroutines, return_exceptions=return_exceptions)
392
+ results: list[T] = await asyncio_gather(*coroutines, return_exceptions=return_exc)
393
+
394
+ # After.
395
+ if after is not None:
396
+ await after
356
397
 
357
398
  return results
358
399
 
@@ -488,6 +529,94 @@ async def async_wait(
488
529
  return tm.total_spend
489
530
 
490
531
 
532
+ @overload
533
+ async def async_request(
534
+ url: str,
535
+ params: dict | None = None,
536
+ data: dict | str | bytes | None = None,
537
+ *,
538
+ headers: dict[str, str] = {},
539
+ timeout: float | None = None,
540
+ proxy: str | None = None,
541
+ ssl: bool = False,
542
+ method: Literal['get', 'post', 'put', 'patch', 'delete', 'options', 'head'] | None = None,
543
+ check: bool | int | Iterable[int] = False
544
+ ) -> bytes: ...
545
+
546
+ @overload
547
+ async def async_request(
548
+ url: str,
549
+ params: dict | None = None,
550
+ *,
551
+ json: dict | None = None,
552
+ headers: dict[str, str] = {},
553
+ timeout: float | None = None,
554
+ proxy: str | None = None,
555
+ ssl: bool = False,
556
+ method: Literal['get', 'post', 'put', 'patch', 'delete', 'options', 'head'] | None = None,
557
+ check: bool | int | Iterable[int] = False
558
+ ) -> bytes: ...
559
+
560
+ @overload
561
+ async def async_request(
562
+ url: str,
563
+ params: dict | None = None,
564
+ data: dict | str | bytes | None = None,
565
+ *,
566
+ headers: dict[str, str] = {},
567
+ timeout: float | None = None,
568
+ proxy: str | None = None,
569
+ ssl: bool = False,
570
+ method: Literal['get', 'post', 'put', 'patch', 'delete', 'options', 'head'] | None = None,
571
+ check: bool | int | Iterable[int] = False,
572
+ handler: tuple[str]
573
+ ) -> list: ...
574
+
575
+ @overload
576
+ async def async_request(
577
+ url: str,
578
+ params: dict | None = None,
579
+ *,
580
+ json: dict | None = None,
581
+ headers: dict[str, str] = {},
582
+ timeout: float | None = None,
583
+ proxy: str | None = None,
584
+ ssl: bool = False,
585
+ method: Literal['get', 'post', 'put', 'patch', 'delete', 'options', 'head'] | None = None,
586
+ check: bool | int | Iterable[int] = False,
587
+ handler: tuple[str]
588
+ ) -> list: ...
589
+
590
+ @overload
591
+ async def async_request(
592
+ url: str,
593
+ params: dict | None = None,
594
+ data: dict | str | bytes | None = None,
595
+ *,
596
+ headers: dict[str, str] = {},
597
+ timeout: float | None = None,
598
+ proxy: str | None = None,
599
+ ssl: bool = False,
600
+ method: Literal['get', 'post', 'put', 'patch', 'delete', 'options', 'head'] | None = None,
601
+ check: bool | int | Iterable[int] = False,
602
+ handler: Callable[[ClientResponse], Coroutine[Any, Any, T] | T]
603
+ ) -> T: ...
604
+
605
+ @overload
606
+ async def async_request(
607
+ url: str,
608
+ params: dict | None = None,
609
+ *,
610
+ json: dict | None = None,
611
+ headers: dict[str, str] = {},
612
+ timeout: float | None = None,
613
+ proxy: str | None = None,
614
+ ssl: bool = False,
615
+ method: Literal['get', 'post', 'put', 'patch', 'delete', 'options', 'head'] | None = None,
616
+ check: bool | int | Iterable[int] = False,
617
+ handler: Callable[[ClientResponse], Coroutine[Any, Any, T] | T]
618
+ ) -> T: ...
619
+
491
620
  async def async_request(
492
621
  url: str,
493
622
  params: dict | None = None,
@@ -496,6 +625,7 @@ async def async_request(
496
625
  headers: dict[str, str] = {},
497
626
  timeout: float | None = None,
498
627
  proxy: str | None = None,
628
+ ssl: bool = False,
499
629
  method: Literal['get', 'post', 'put', 'patch', 'delete', 'options', 'head'] | None = None,
500
630
  check: bool | int | Iterable[int] = False,
501
631
  handler: str | tuple[str] | Callable[[ClientResponse], Coroutine | Any] | None = None
@@ -521,6 +651,7 @@ async def async_request(
521
651
  headers : Request header data.
522
652
  timeout : Request maximun waiting time.
523
653
  proxy : Proxy URL.
654
+ ssl : Whether verify SSL certificate.
524
655
  method : Request method.
525
656
  - `None`: Automatic judge.
526
657
  When parameter `data` or `json` not has value, then request method is `get`.
@@ -571,7 +702,8 @@ async def async_request(
571
702
  json=json,
572
703
  headers=headers,
573
704
  timeout=timeout,
574
- proxy=proxy
705
+ proxy=proxy,
706
+ ssl=ssl
575
707
  ) as response:
576
708
 
577
709
  # Check code.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reykit
3
- Version: 1.1.82
3
+ Version: 1.1.84
4
4
  Summary: Kit method set.
5
5
  Project-URL: homepage, https://github.com/reyxbo/reykit/
6
6
  Author-email: Rey <reyxbo@163.com>
@@ -5,24 +5,24 @@ reykit/rdata.py,sha256=NmOY_h4w2PY5xBbYNmOnb55w7PGsvvCzOBnxPjQ08qw,10293
5
5
  reykit/remail.py,sha256=l4HGKXdfHNBxyBT3YxeZyQhfecbElqTqSAGInwWhap8,6723
6
6
  reykit/rimage.py,sha256=lNN2iMpvSMqh-nPTpxrA9yHy43EA5WoYdxKYhqPwMgk,6154
7
7
  reykit/rlog.py,sha256=_opEDQUQfhAuIoDg2iS7wFU3KqL-tdWMvtbnwhsuVk4,25747
8
- reykit/rmonkey.py,sha256=Dj2GBzBDFXbo0Z-5f8Zep4dfbaIw1bo1FUmC31xvDuk,7929
9
- reykit/rnet.py,sha256=YvoLffHcMK43GMoXKQXDTHFP9fiVTH5uzmN-glRBuFY,17772
8
+ reykit/rmonkey.py,sha256=9AeZRVoPuagV8j6Z-f02zbQFAYUUxeoyqYl7cJZ7RAE,7855
9
+ reykit/rnet.py,sha256=McW4fX-omkD4_2BpLISHt2hpwIxK7EfDA5c6j3gn3E4,16874
10
10
  reykit/rnum.py,sha256=VKICD64mEfiStAGWaxg3kzQjf7TTqiSBNe9LCpM9MLo,3623
11
- reykit/ros.py,sha256=O5xAqVR1S5pGU-ryKh6JFN9ztO-GNMl_83fWoh75zOY,47873
12
- reykit/rrand.py,sha256=4VwooITgox54_GonELcJfcIpStDi-UJchpnyWKnyeIA,8606
11
+ reykit/ros.py,sha256=J6YxNbOceMhHwVKDugx5Wd-KFliRtlhFEVVcCAaE_So,47847
12
+ reykit/rrand.py,sha256=fiwxyUMaLtFjPanVwTOiwvEEucmf0t2WiZF9ul9o6pU,8572
13
13
  reykit/rre.py,sha256=1qva7xatKVE9qC2j7IujjXSM59qxHWwTYpiizFFQ8Xo,6024
14
14
  reykit/rschedule.py,sha256=Xh5J8_5js-8yRXqOq4cjIlJEKuVAB4qme65D0zvwpLw,14694
15
15
  reykit/rstdout.py,sha256=yesWo7wIGablpyAu-2J2Gw11Qp3GdQjGICTyIcvLyt4,8200
16
16
  reykit/rsys.py,sha256=AP62KyN40flCeQJBclfJq8shachSAFT0LkVjiKsXkrw,24946
17
17
  reykit/rtable.py,sha256=UQ-JlwjssMR3gY1iY-VGQEKQ5_BZabpJy6TL7Fx19c4,12200
18
- reykit/rtask.py,sha256=NUTngUUDUZy3TqEHiuiKy17FcE0F1zS118KnKTsBjng,22838
18
+ reykit/rtask.py,sha256=TeuHE4BN978AlOu5pcOvem7KK-6L0B50ncxNuS32nBw,27024
19
19
  reykit/rtext.py,sha256=cWHy19lDcJvpX7LU95kmRVsDimpAUaz5TbKC1h83gB4,13254
20
20
  reykit/rtime.py,sha256=lsSKaYFmYXlDN18yj2fLVTKSruzgygl8icW6_Fl42Xk,17807
21
21
  reykit/rwrap.py,sha256=G4TL2GWUaW9DrCFRcsnDE1CwgdWeP2PnjQckheRx4p0,15095
22
22
  reykit/rzip.py,sha256=BGEONswuBZxQ-zcgd_xp2fcvYesC9AmKaaXWvnT3bTI,3456
23
23
  reykit/rdll/__init__.py,sha256=nLSb8onBm2ilyoxzpDzUeGfSCKwkLEesIhzK3LiJ8mk,701
24
24
  reykit/rdll/rdll_core.py,sha256=o6-rKcTQgxZQe0kD3GnwyNb3KL9IogzgCQNOmYLMm7A,5086
25
- reykit-1.1.82.dist-info/METADATA,sha256=nM6ORwzi2NppYsEg2PD0SPzDxuzXWC7tK-y6lxBhMDs,1872
26
- reykit-1.1.82.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
27
- reykit-1.1.82.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
28
- reykit-1.1.82.dist-info/RECORD,,
25
+ reykit-1.1.84.dist-info/METADATA,sha256=a69BSp6U5sm36PR2oqivuytXGSteXkvT7Mem4yKHMFc,1872
26
+ reykit-1.1.84.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
27
+ reykit-1.1.84.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
28
+ reykit-1.1.84.dist-info/RECORD,,