reykit 1.1.60__py3-none-any.whl → 1.1.61__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/rbase.py +14 -32
- reykit/rlog.py +4 -4
- reykit/rrand.py +1 -10
- reykit/rwrap.py +8 -8
- {reykit-1.1.60.dist-info → reykit-1.1.61.dist-info}/METADATA +1 -1
- {reykit-1.1.60.dist-info → reykit-1.1.61.dist-info}/RECORD +8 -8
- {reykit-1.1.60.dist-info → reykit-1.1.61.dist-info}/WHEEL +0 -0
- {reykit-1.1.60.dist-info → reykit-1.1.61.dist-info}/licenses/LICENSE +0 -0
reykit/rbase.py
CHANGED
@@ -10,11 +10,10 @@
|
|
10
10
|
|
11
11
|
|
12
12
|
from typing import Any, Literal, Self, TypeVar, NoReturn, overload
|
13
|
-
from types import TracebackType
|
14
13
|
from collections.abc import Callable, Iterable, Container, Mapping
|
15
14
|
from sys import exc_info as sys_exc_info
|
16
15
|
from os.path import exists as os_exists
|
17
|
-
from traceback import format_exc
|
16
|
+
from traceback import StackSummary, format_exc, extract_tb
|
18
17
|
from warnings import warn as warnings_warn
|
19
18
|
from traceback import format_stack, extract_stack
|
20
19
|
from atexit import register as atexit_register
|
@@ -36,7 +35,7 @@ __all__ = (
|
|
36
35
|
'Singleton',
|
37
36
|
'Null',
|
38
37
|
'null',
|
39
|
-
'
|
38
|
+
'ErrorBase',
|
40
39
|
'Exit',
|
41
40
|
'Error',
|
42
41
|
'throw',
|
@@ -213,19 +212,19 @@ class Null(Singleton):
|
|
213
212
|
null = Null()
|
214
213
|
|
215
214
|
|
216
|
-
class
|
215
|
+
class ErrorBase(Base, BaseException):
|
217
216
|
"""
|
218
217
|
Base error type.
|
219
218
|
"""
|
220
219
|
|
221
220
|
|
222
|
-
class Exit(
|
221
|
+
class Exit(ErrorBase):
|
223
222
|
"""
|
224
223
|
Exit type.
|
225
224
|
"""
|
226
225
|
|
227
226
|
|
228
|
-
class Error(
|
227
|
+
class Error(ErrorBase):
|
229
228
|
"""
|
230
229
|
Error type.
|
231
230
|
"""
|
@@ -337,42 +336,25 @@ def warn(
|
|
337
336
|
warnings_warn(infos, exception, stacklevel)
|
338
337
|
|
339
338
|
|
340
|
-
def catch_exc(
|
341
|
-
title: str | None = None
|
342
|
-
) -> tuple[str, type[BaseException], BaseException, TracebackType]:
|
339
|
+
def catch_exc() -> tuple[str, BaseException, StackSummary]:
|
343
340
|
"""
|
344
|
-
Catch
|
345
|
-
|
346
|
-
Parameters
|
347
|
-
----------
|
348
|
-
title : Print title.
|
349
|
-
- `None`: Not print.
|
350
|
-
- `str`: Print and use this title.
|
341
|
+
Catch or print exception data, must used in `except` syntax.
|
351
342
|
|
352
343
|
Returns
|
353
344
|
-------
|
354
345
|
Exception data.
|
355
|
-
- `str`: Exception
|
356
|
-
- `type[BaseException]`: Exception type.
|
346
|
+
- `str`: Exception traceback text of from `try` to exception.
|
357
347
|
- `BaseException`: Exception instance.
|
358
|
-
- `
|
348
|
+
- `StackSummary`: Exception traceback stack instance.
|
359
349
|
"""
|
360
350
|
|
361
351
|
# Handle parameter.
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
# Print.
|
367
|
-
if title is not None:
|
368
|
-
|
369
|
-
## Import.
|
370
|
-
from .rstdout import echo
|
371
|
-
|
372
|
-
## Execute.
|
373
|
-
echo(exc_report, title=title, frame='half')
|
352
|
+
exc_text = format_exc()
|
353
|
+
exc_text = exc_text.strip()
|
354
|
+
_, exc, traceback = sys_exc_info()
|
355
|
+
stack = extract_tb(traceback)
|
374
356
|
|
375
|
-
return
|
357
|
+
return exc_text, exc, stack
|
376
358
|
|
377
359
|
|
378
360
|
@overload
|
reykit/rlog.py
CHANGED
@@ -771,7 +771,7 @@ class Log(Base):
|
|
771
771
|
level is None
|
772
772
|
or catch
|
773
773
|
):
|
774
|
-
|
774
|
+
exc_text, exc, _ = catch_exc()
|
775
775
|
|
776
776
|
## Messages.
|
777
777
|
messages_len = len(messages)
|
@@ -780,7 +780,7 @@ class Log(Base):
|
|
780
780
|
|
781
781
|
## Level.
|
782
782
|
if level is None:
|
783
|
-
if
|
783
|
+
if exc is None:
|
784
784
|
level = self.INFO
|
785
785
|
else:
|
786
786
|
level = self.ERROR
|
@@ -798,11 +798,11 @@ class Log(Base):
|
|
798
798
|
### Exception.
|
799
799
|
if (
|
800
800
|
catch
|
801
|
-
and
|
801
|
+
and exc is not None
|
802
802
|
):
|
803
803
|
messages = '%s\n%s' % (
|
804
804
|
messages,
|
805
|
-
|
805
|
+
exc_text
|
806
806
|
)
|
807
807
|
|
808
808
|
# Record.
|
reykit/rrand.py
CHANGED
@@ -11,7 +11,6 @@
|
|
11
11
|
|
12
12
|
from __future__ import annotations
|
13
13
|
from typing import Literal, Self, overload
|
14
|
-
from types import TracebackType
|
15
14
|
from collections.abc import Sequence
|
16
15
|
from string import digits as string_digits, ascii_letters as string_ascii_letters, punctuation as string_punctuation
|
17
16
|
from math import ceil as math_ceil
|
@@ -112,18 +111,10 @@ class RandomSeed(Base):
|
|
112
111
|
|
113
112
|
def __exit__(
|
114
113
|
self,
|
115
|
-
|
116
|
-
exc_instance: BaseException | None,
|
117
|
-
exc_traceback: TracebackType | None
|
114
|
+
*_
|
118
115
|
) -> None:
|
119
116
|
"""
|
120
117
|
Exit syntax `with`.
|
121
|
-
|
122
|
-
Parameters
|
123
|
-
----------
|
124
|
-
exc_type : Exception type.
|
125
|
-
exc_instance : Exception instance.
|
126
|
-
exc_traceback : Exception traceback instance.
|
127
118
|
"""
|
128
119
|
|
129
120
|
# Delete.
|
reykit/rwrap.py
CHANGED
@@ -10,9 +10,9 @@
|
|
10
10
|
|
11
11
|
|
12
12
|
from typing import Any, Literal, overload
|
13
|
-
from types import TracebackType
|
14
13
|
from collections.abc import Callable
|
15
14
|
from io import IOBase, StringIO
|
15
|
+
from traceback import StackSummary
|
16
16
|
from inspect import getdoc as inspect_getdoc
|
17
17
|
from functools import wraps as functools_wraps, partial as functools_partial
|
18
18
|
from datetime import datetime as Datetime, timedelta as Timedelta
|
@@ -271,14 +271,14 @@ def wrap_thread(
|
|
271
271
|
@overload
|
272
272
|
def wrap_exc(
|
273
273
|
func: Callable[..., T],
|
274
|
-
handler: Callable[[
|
274
|
+
handler: Callable[[str, BaseException, StackSummary], Any],
|
275
275
|
exception: BaseException | tuple[BaseException, ...] | None = BaseException
|
276
276
|
) -> Callable[..., T | None]: ...
|
277
277
|
|
278
278
|
@overload
|
279
279
|
def wrap_exc(
|
280
280
|
*,
|
281
|
-
handler: Callable[[
|
281
|
+
handler: Callable[[str, BaseException, StackSummary], Any],
|
282
282
|
exception: BaseException | tuple[BaseException, ...] | None = BaseException
|
283
283
|
) -> Callable[[Callable[..., T]], T | None]: ...
|
284
284
|
|
@@ -287,7 +287,7 @@ def wrap_exc(
|
|
287
287
|
func: Callable[..., T],
|
288
288
|
args: Any,
|
289
289
|
kwargs: Any,
|
290
|
-
handler: Callable[[
|
290
|
+
handler: Callable[[str, BaseException, StackSummary], Any],
|
291
291
|
exception: BaseException | tuple[BaseException, ...] | None = BaseException
|
292
292
|
) -> T | None:
|
293
293
|
"""
|
@@ -312,8 +312,8 @@ def wrap_exc(
|
|
312
312
|
|
313
313
|
# Handle exception.
|
314
314
|
except exception:
|
315
|
-
|
316
|
-
handler(
|
315
|
+
exc_text, exc, stack = catch_exc()
|
316
|
+
handler(exc_text, exc, stack)
|
317
317
|
|
318
318
|
else:
|
319
319
|
return result
|
@@ -371,8 +371,8 @@ def wrap_retry(
|
|
371
371
|
## Handle.
|
372
372
|
except exception:
|
373
373
|
if handler is not None:
|
374
|
-
|
375
|
-
handler(
|
374
|
+
exc_text, exc, stack = catch_exc()
|
375
|
+
handler(exc_text, exc, stack)
|
376
376
|
|
377
377
|
else:
|
378
378
|
return result
|
@@ -1,15 +1,15 @@
|
|
1
1
|
reykit/__init__.py,sha256=V86CHqPAAVkooVx3_QIOKpDIFVneQCTTSwfJ-uWgBno,788
|
2
2
|
reykit/rall.py,sha256=7Hip02YOkIDm3_xkoSDjvvYV2LhdBV2r4UKzWWnIfIo,628
|
3
|
-
reykit/rbase.py,sha256=
|
3
|
+
reykit/rbase.py,sha256=lmHLJbkmVOXTac5_zBPPirdjcPBekhswBmCXclIG11A,21684
|
4
4
|
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
|
-
reykit/rlog.py,sha256=
|
7
|
+
reykit/rlog.py,sha256=TRAWaVG9KTgzeNjN-FXkcvBmvq1IhICgawllQEGoUdg,25745
|
8
8
|
reykit/rmonkey.py,sha256=Dj2GBzBDFXbo0Z-5f8Zep4dfbaIw1bo1FUmC31xvDuk,7929
|
9
9
|
reykit/rnet.py,sha256=6uULgoPk8DTKWg9yNQco7gdw4A59F9ygcZR6rgO4eoY,16897
|
10
10
|
reykit/rnum.py,sha256=PhG4V_BkVfCJUsbpMDN1umGZly1Hsus80TW8bpyBtyY,3653
|
11
11
|
reykit/ros.py,sha256=8bLvjt0WkUPF6bkwQnm4xeoZTeKqcwM3a0EFt51WNaU,47006
|
12
|
-
reykit/rrand.py,sha256=
|
12
|
+
reykit/rrand.py,sha256=4VwooITgox54_GonELcJfcIpStDi-UJchpnyWKnyeIA,8606
|
13
13
|
reykit/rre.py,sha256=1qva7xatKVE9qC2j7IujjXSM59qxHWwTYpiizFFQ8Xo,6024
|
14
14
|
reykit/rschedule.py,sha256=E2gRLrCwrAo2CV1sOHrWoaVP99Wq7QjAqeYv04hWsYo,5767
|
15
15
|
reykit/rstdout.py,sha256=yesWo7wIGablpyAu-2J2Gw11Qp3GdQjGICTyIcvLyt4,8200
|
@@ -18,11 +18,11 @@ reykit/rtable.py,sha256=YuDH2GL9Lwr5LljRDm5hzHrsvaXOs4-X89XVwFD-b0g,12221
|
|
18
18
|
reykit/rtask.py,sha256=NUTngUUDUZy3TqEHiuiKy17FcE0F1zS118KnKTsBjng,22838
|
19
19
|
reykit/rtext.py,sha256=cWHy19lDcJvpX7LU95kmRVsDimpAUaz5TbKC1h83gB4,13254
|
20
20
|
reykit/rtime.py,sha256=8QJ6YNiC0JUDiW1xc1tkzQUMPYOFT7d7dKCYRuYt9co,17635
|
21
|
-
reykit/rwrap.py,sha256=
|
21
|
+
reykit/rwrap.py,sha256=tB2UtF8wY7VW5C04AggmRfI67y4l5pDbgqqFO_fwg6g,15126
|
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.
|
26
|
-
reykit-1.1.
|
27
|
-
reykit-1.1.
|
28
|
-
reykit-1.1.
|
25
|
+
reykit-1.1.61.dist-info/METADATA,sha256=QCB9yw4xo648tFbldf6f3GfS3q4-q56QcFPsX_40xhY,1872
|
26
|
+
reykit-1.1.61.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
27
|
+
reykit-1.1.61.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
|
28
|
+
reykit-1.1.61.dist-info/RECORD,,
|
File without changes
|
File without changes
|