reykit 1.1.60__py3-none-any.whl → 1.1.62__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 +15 -33
- reykit/rlog.py +4 -4
- reykit/rrand.py +1 -10
- reykit/rwrap.py +20 -21
- {reykit-1.1.60.dist-info → reykit-1.1.62.dist-info}/METADATA +1 -1
- {reykit-1.1.60.dist-info → reykit-1.1.62.dist-info}/RECORD +8 -8
- {reykit-1.1.60.dist-info → reykit-1.1.62.dist-info}/WHEEL +0 -0
- {reykit-1.1.60.dist-info → reykit-1.1.62.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
|
@@ -919,7 +901,7 @@ def block() -> None:
|
|
919
901
|
print('End blocking.')
|
920
902
|
break
|
921
903
|
|
922
|
-
except:
|
904
|
+
except BaseException:
|
923
905
|
continue
|
924
906
|
|
925
907
|
|
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
|
@@ -42,7 +42,7 @@ type Decorated = Callable
|
|
42
42
|
type Decorator = Callable[..., Decorated]
|
43
43
|
|
44
44
|
|
45
|
-
def wrap_wrap(decorator: Decorator) -> Decorator:
|
45
|
+
def wrap_wrap(decorator: Decorator | None = None) -> Decorator:
|
46
46
|
"""
|
47
47
|
Decorate decorator.
|
48
48
|
|
@@ -102,8 +102,13 @@ def wrap_wrap(decorator: Decorator) -> Decorator:
|
|
102
102
|
Decorated function or decorated self.
|
103
103
|
"""
|
104
104
|
|
105
|
-
#
|
106
|
-
if func is
|
105
|
+
# Has decorator parameter.
|
106
|
+
if func is None:
|
107
|
+
__wrap = functools_partial(_wrap, **wrap_kwargs)
|
108
|
+
return __wrap
|
109
|
+
|
110
|
+
# No decorator parameter.
|
111
|
+
else:
|
107
112
|
|
108
113
|
|
109
114
|
@functools_wraps(func)
|
@@ -121,7 +126,7 @@ def wrap_wrap(decorator: Decorator) -> Decorator:
|
|
121
126
|
Function return.
|
122
127
|
"""
|
123
128
|
|
124
|
-
#
|
129
|
+
# Excute.
|
125
130
|
result = decorator(func, args, kwargs, **wrap_kwargs)
|
126
131
|
|
127
132
|
return result
|
@@ -130,12 +135,6 @@ def wrap_wrap(decorator: Decorator) -> Decorator:
|
|
130
135
|
return _func
|
131
136
|
|
132
137
|
|
133
|
-
# Method two and four.
|
134
|
-
else:
|
135
|
-
__wrap = functools_partial(_wrap, **wrap_kwargs)
|
136
|
-
return __wrap
|
137
|
-
|
138
|
-
|
139
138
|
return _wrap
|
140
139
|
|
141
140
|
|
@@ -271,14 +270,14 @@ def wrap_thread(
|
|
271
270
|
@overload
|
272
271
|
def wrap_exc(
|
273
272
|
func: Callable[..., T],
|
274
|
-
handler: Callable[[
|
273
|
+
handler: Callable[[str, BaseException, StackSummary], Any],
|
275
274
|
exception: BaseException | tuple[BaseException, ...] | None = BaseException
|
276
275
|
) -> Callable[..., T | None]: ...
|
277
276
|
|
278
277
|
@overload
|
279
278
|
def wrap_exc(
|
280
279
|
*,
|
281
|
-
handler: Callable[[
|
280
|
+
handler: Callable[[str, BaseException, StackSummary], Any],
|
282
281
|
exception: BaseException | tuple[BaseException, ...] | None = BaseException
|
283
282
|
) -> Callable[[Callable[..., T]], T | None]: ...
|
284
283
|
|
@@ -287,7 +286,7 @@ def wrap_exc(
|
|
287
286
|
func: Callable[..., T],
|
288
287
|
args: Any,
|
289
288
|
kwargs: Any,
|
290
|
-
handler: Callable[[
|
289
|
+
handler: Callable[[str, BaseException, StackSummary], Any],
|
291
290
|
exception: BaseException | tuple[BaseException, ...] | None = BaseException
|
292
291
|
) -> T | None:
|
293
292
|
"""
|
@@ -312,8 +311,8 @@ def wrap_exc(
|
|
312
311
|
|
313
312
|
# Handle exception.
|
314
313
|
except exception:
|
315
|
-
|
316
|
-
handler(
|
314
|
+
exc_text, exc, stack = catch_exc()
|
315
|
+
handler(exc_text, exc, stack)
|
317
316
|
|
318
317
|
else:
|
319
318
|
return result
|
@@ -323,7 +322,7 @@ def wrap_exc(
|
|
323
322
|
def wrap_retry(
|
324
323
|
func: Callable[..., T],
|
325
324
|
total: int = 1,
|
326
|
-
handler: Callable[[tuple[str,
|
325
|
+
handler: Callable[[tuple[str, BaseException, StackSummary]], Any] | None = None,
|
327
326
|
exception: BaseException | tuple[BaseException, ...] = BaseException
|
328
327
|
) -> Callable[..., T]: ...
|
329
328
|
|
@@ -331,7 +330,7 @@ def wrap_retry(
|
|
331
330
|
def wrap_retry(
|
332
331
|
*,
|
333
332
|
total: int = 1,
|
334
|
-
handler: Callable[[tuple[str,
|
333
|
+
handler: Callable[[tuple[str, BaseException, StackSummary]], Any] | None = None,
|
335
334
|
exception: BaseException | tuple[BaseException, ...] = BaseException
|
336
335
|
) -> Callable[[Callable[..., T]], T]: ...
|
337
336
|
|
@@ -341,7 +340,7 @@ def wrap_retry(
|
|
341
340
|
args: Any,
|
342
341
|
kwargs: Any,
|
343
342
|
total: int = 2,
|
344
|
-
handler: Callable[[tuple[str,
|
343
|
+
handler: Callable[[tuple[str, BaseException, StackSummary]], Any] | None = None,
|
345
344
|
exception: BaseException | tuple[BaseException, ...] = BaseException
|
346
345
|
) -> T:
|
347
346
|
"""
|
@@ -371,8 +370,8 @@ def wrap_retry(
|
|
371
370
|
## Handle.
|
372
371
|
except exception:
|
373
372
|
if handler is not None:
|
374
|
-
|
375
|
-
handler(
|
373
|
+
exc_text, exc, stack = catch_exc()
|
374
|
+
handler(exc_text, exc, stack)
|
376
375
|
|
377
376
|
else:
|
378
377
|
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=tMLDwFACHQN9SDK-1dsGIAXZGw6FSnKf_5-aZUFCFpg,21698
|
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=FEmeK_fboJ-OyXeJf8bilc7U2ph8xIbZGNHb6fLCy2c,15063
|
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.62.dist-info/METADATA,sha256=s4p04lHvez_YiMGAV6x3pttHztluRZcZ86SbzxcjATg,1872
|
26
|
+
reykit-1.1.62.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
27
|
+
reykit-1.1.62.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
|
28
|
+
reykit-1.1.62.dist-info/RECORD,,
|
File without changes
|
File without changes
|