reykit 1.1.24__py3-none-any.whl → 1.1.26__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/__init__.py +8 -8
- reykit/rall.py +7 -7
- reykit/rdata.py +19 -10
- reykit/rdll/__init__.py +31 -3
- reykit/rdll/{rdll_inject_core.py → rdll_core.py} +1 -1
- reykit/remail.py +7 -7
- reykit/{rexception.py → rexc.py} +12 -23
- reykit/rimage.py +13 -16
- reykit/rlog.py +26 -27
- reykit/rmonkey.py +13 -17
- reykit/{rcomm.py → rnet.py} +16 -16
- reykit/{rnumber.py → rnum.py} +2 -2
- reykit/ros.py +30 -32
- reykit/{rrandom.py → rrand.py} +18 -18
- reykit/rschedule.py +5 -5
- reykit/rstdout.py +33 -33
- reykit/{rsystem.py → rsys.py} +9 -9
- reykit/rtable.py +2 -2
- reykit/{rmultitask.py → rtask.py} +14 -15
- reykit/rtext.py +2 -2
- reykit/rtime.py +10 -10
- reykit/rtype.py +17 -17
- reykit/rwrap.py +4 -4
- reykit/rzip.py +4 -5
- {reykit-1.1.24.dist-info → reykit-1.1.26.dist-info}/METADATA +1 -1
- reykit-1.1.26.dist-info/RECORD +29 -0
- reykit/rdll/rdll_inject.py +0 -41
- reykit-1.1.24.dist-info/RECORD +0 -30
- /reykit/{rregex.py → rre.py} +0 -0
- {reykit-1.1.24.dist-info → reykit-1.1.26.dist-info}/WHEEL +0 -0
- {reykit-1.1.24.dist-info → reykit-1.1.26.dist-info}/licenses/LICENSE +0 -0
reykit/{rcomm.py → rnet.py}
RENAMED
@@ -5,7 +5,7 @@
|
|
5
5
|
@Time : 2022-12-08 11:07:25
|
6
6
|
@Author : Rey
|
7
7
|
@Contact : reyxbo@163.com
|
8
|
-
@Explain : Network
|
8
|
+
@Explain : Network methods.
|
9
9
|
"""
|
10
10
|
|
11
11
|
|
@@ -30,10 +30,10 @@ from mimetypes import guess_type
|
|
30
30
|
from filetype import guess as filetype_guess
|
31
31
|
from datetime import datetime
|
32
32
|
|
33
|
-
from .
|
34
|
-
from .ros import
|
35
|
-
from .
|
36
|
-
from .rtype import
|
33
|
+
from .rexc import throw, check_response_code
|
34
|
+
from .ros import File
|
35
|
+
from .rre import search
|
36
|
+
from .rtype import Base
|
37
37
|
|
38
38
|
|
39
39
|
__all__ = (
|
@@ -44,9 +44,9 @@ __all__ = (
|
|
44
44
|
'get_content_type',
|
45
45
|
'request',
|
46
46
|
'download',
|
47
|
-
'
|
47
|
+
'compute_stream_time',
|
48
48
|
'listen_socket',
|
49
|
-
'
|
49
|
+
'RequestCache'
|
50
50
|
)
|
51
51
|
|
52
52
|
|
@@ -276,7 +276,7 @@ def request(
|
|
276
276
|
method = 'post'
|
277
277
|
if files is None:
|
278
278
|
if type(data) == str:
|
279
|
-
rfile =
|
279
|
+
rfile = File(data)
|
280
280
|
data = rfile.bytes
|
281
281
|
if 'Content-Disposition' not in headers:
|
282
282
|
file_name = rfile.name_suffix
|
@@ -291,7 +291,7 @@ def request(
|
|
291
291
|
else:
|
292
292
|
item_data, item_headers = value, {}
|
293
293
|
if type(item_data) == str:
|
294
|
-
rfile =
|
294
|
+
rfile = File(item_data)
|
295
295
|
data = rfile.bytes
|
296
296
|
item_headers.setdefault('filename', rfile.name_suffix)
|
297
297
|
if type(item_data) == bytes:
|
@@ -381,18 +381,18 @@ def download(url: str, path: str | None = None) -> str:
|
|
381
381
|
path = os_abspath(file_name)
|
382
382
|
|
383
383
|
# Save.
|
384
|
-
rfile =
|
384
|
+
rfile = File(path)
|
385
385
|
rfile(content)
|
386
386
|
|
387
387
|
return path
|
388
388
|
|
389
389
|
|
390
|
-
def
|
390
|
+
def compute_stream_time(
|
391
391
|
file: str | bytes | int,
|
392
392
|
bandwidth: float
|
393
393
|
) -> float:
|
394
394
|
"""
|
395
|
-
|
395
|
+
Compute file stream transfer time, unit second.
|
396
396
|
|
397
397
|
Parameters
|
398
398
|
----------
|
@@ -410,7 +410,7 @@ def get_file_stream_time(
|
|
410
410
|
# Get parameter.
|
411
411
|
match file:
|
412
412
|
case str():
|
413
|
-
rfile =
|
413
|
+
rfile = File(file)
|
414
414
|
file_size = rfile.size
|
415
415
|
case bytes() | bytearray():
|
416
416
|
file_size = len(file)
|
@@ -456,9 +456,9 @@ def listen_socket(
|
|
456
456
|
handler(data)
|
457
457
|
|
458
458
|
|
459
|
-
class
|
459
|
+
class RequestCache(Base):
|
460
460
|
"""
|
461
|
-
|
461
|
+
Requests cache type.
|
462
462
|
"""
|
463
463
|
|
464
464
|
|
@@ -471,7 +471,7 @@ class RRequestCache(RBase):
|
|
471
471
|
judge: Callable[[Response | OriginalResponse | CachedResponse], bool] | None = None
|
472
472
|
) -> None:
|
473
473
|
"""
|
474
|
-
Build
|
474
|
+
Build instance attributes.
|
475
475
|
|
476
476
|
Parameters
|
477
477
|
----------
|
reykit/{rnumber.py → rnum.py}
RENAMED
@@ -11,7 +11,7 @@
|
|
11
11
|
|
12
12
|
from typing import Any
|
13
13
|
|
14
|
-
from .
|
14
|
+
from .rexc import throw
|
15
15
|
|
16
16
|
|
17
17
|
__all__ = (
|
@@ -119,7 +119,7 @@ def number_ch(number: int) -> str:
|
|
119
119
|
"""
|
120
120
|
|
121
121
|
# Import.
|
122
|
-
from .
|
122
|
+
from .rre import sub_batch
|
123
123
|
|
124
124
|
# Set parameter.
|
125
125
|
map_digit = {
|
reykit/ros.py
CHANGED
@@ -51,11 +51,11 @@ from docx.oxml.table import CT_Tbl
|
|
51
51
|
from lxml.etree import ElementChildIterator
|
52
52
|
from pdfplumber import open as pdfplumber_open
|
53
53
|
|
54
|
-
from .
|
55
|
-
from .
|
56
|
-
from .
|
54
|
+
from .rexc import throw
|
55
|
+
from .rre import search, sub
|
56
|
+
from .rsys import dos_command
|
57
57
|
from .rtext import to_json
|
58
|
-
from .rtype import
|
58
|
+
from .rtype import Base
|
59
59
|
|
60
60
|
|
61
61
|
__all__ = (
|
@@ -65,10 +65,10 @@ __all__ = (
|
|
65
65
|
'get_file_str',
|
66
66
|
'get_file_bytes',
|
67
67
|
'read_toml',
|
68
|
-
'
|
69
|
-
'
|
70
|
-
'
|
71
|
-
'
|
68
|
+
'File',
|
69
|
+
'Folder',
|
70
|
+
'TempFile',
|
71
|
+
'TempFolder',
|
72
72
|
'doc_to_docx',
|
73
73
|
'extract_docx_content',
|
74
74
|
'extract_pdf_content',
|
@@ -81,7 +81,6 @@ type FileText = str
|
|
81
81
|
type FileData = bytes
|
82
82
|
type FileStr = FilePath | FileText | TextIOBase
|
83
83
|
type FileBytes = FilePath | FileData | BufferedIOBase
|
84
|
-
type File = FileStr | FileBytes
|
85
84
|
|
86
85
|
|
87
86
|
def get_md5(file: str | bytes) -> str:
|
@@ -102,7 +101,7 @@ def get_md5(file: str | bytes) -> str:
|
|
102
101
|
|
103
102
|
## Path.
|
104
103
|
case str():
|
105
|
-
rfile =
|
104
|
+
rfile = File(file)
|
106
105
|
file_bytes = rfile.bytes
|
107
106
|
|
108
107
|
## Bytes.
|
@@ -128,7 +127,7 @@ def create_folder(*paths: str, report: bool = False) -> None:
|
|
128
127
|
|
129
128
|
# Create.
|
130
129
|
for path in paths:
|
131
|
-
rfolder =
|
130
|
+
rfolder = Folder(path)
|
132
131
|
rfolder.create(report)
|
133
132
|
|
134
133
|
|
@@ -205,7 +204,7 @@ def get_file_str(file: FileStr) -> str:
|
|
205
204
|
|
206
205
|
## Path.
|
207
206
|
if exist:
|
208
|
-
rfile =
|
207
|
+
rfile = File(file)
|
209
208
|
file_str = rfile.str
|
210
209
|
|
211
210
|
## String.
|
@@ -250,7 +249,7 @@ def get_file_bytes(file: FileBytes) -> bytes:
|
|
250
249
|
|
251
250
|
## Path.
|
252
251
|
case str():
|
253
|
-
rfile =
|
252
|
+
rfile = File(file)
|
254
253
|
file_bytes = rfile.bytes
|
255
254
|
|
256
255
|
## IO.
|
@@ -264,14 +263,14 @@ def get_file_bytes(file: FileBytes) -> bytes:
|
|
264
263
|
return file_bytes
|
265
264
|
|
266
265
|
|
267
|
-
def read_toml(path: str |
|
266
|
+
def read_toml(path: str | File) -> dict[str, Any]:
|
268
267
|
"""
|
269
268
|
Read and parse TOML file.
|
270
269
|
Treat nan as a None or null value.
|
271
270
|
|
272
271
|
Parameters
|
273
272
|
----------
|
274
|
-
path : File path or
|
273
|
+
path : File path or File object.
|
275
274
|
|
276
275
|
Returns
|
277
276
|
-------
|
@@ -283,11 +282,11 @@ def read_toml(path: str | RFile) -> dict[str, Any]:
|
|
283
282
|
|
284
283
|
## File path.
|
285
284
|
case str():
|
286
|
-
rfile =
|
285
|
+
rfile = File(path)
|
287
286
|
text = rfile.str
|
288
287
|
|
289
|
-
##
|
290
|
-
case
|
288
|
+
## File object.
|
289
|
+
case File():
|
291
290
|
text = rfile.str
|
292
291
|
|
293
292
|
# Parse.
|
@@ -300,9 +299,9 @@ def read_toml(path: str | RFile) -> dict[str, Any]:
|
|
300
299
|
return params
|
301
300
|
|
302
301
|
|
303
|
-
class
|
302
|
+
class File(Base):
|
304
303
|
"""
|
305
|
-
|
304
|
+
File type.
|
306
305
|
"""
|
307
306
|
|
308
307
|
|
@@ -311,7 +310,7 @@ class RFile(RBase):
|
|
311
310
|
path: str
|
312
311
|
) -> None:
|
313
312
|
"""
|
314
|
-
Build
|
313
|
+
Build instance attributes.
|
315
314
|
|
316
315
|
Parameters
|
317
316
|
----------
|
@@ -846,9 +845,9 @@ class RFile(RBase):
|
|
846
845
|
__call__ = write
|
847
846
|
|
848
847
|
|
849
|
-
class
|
848
|
+
class Folder(Base):
|
850
849
|
"""
|
851
|
-
|
850
|
+
Folder type.
|
852
851
|
"""
|
853
852
|
|
854
853
|
|
@@ -857,7 +856,7 @@ class RFolder(RBase):
|
|
857
856
|
path: str | None = None
|
858
857
|
) -> None:
|
859
858
|
"""
|
860
|
-
Build
|
859
|
+
Build instance attributes.
|
861
860
|
|
862
861
|
Parameters
|
863
862
|
----------
|
@@ -1220,9 +1219,9 @@ class RFolder(RBase):
|
|
1220
1219
|
__call__ = paths
|
1221
1220
|
|
1222
1221
|
|
1223
|
-
class
|
1222
|
+
class TempFile(Base):
|
1224
1223
|
"""
|
1225
|
-
|
1224
|
+
Temporary file type.
|
1226
1225
|
"""
|
1227
1226
|
|
1228
1227
|
|
@@ -1233,7 +1232,7 @@ class RTempFile(RBase):
|
|
1233
1232
|
type_: Literal['str', 'bytes'] = 'bytes'
|
1234
1233
|
) -> None:
|
1235
1234
|
"""
|
1236
|
-
Build
|
1235
|
+
Build instance attributes.
|
1237
1236
|
|
1238
1237
|
Parameters
|
1239
1238
|
----------
|
@@ -1505,9 +1504,9 @@ class RTempFile(RBase):
|
|
1505
1504
|
__call__ = write
|
1506
1505
|
|
1507
1506
|
|
1508
|
-
class
|
1507
|
+
class TempFolder(Base):
|
1509
1508
|
"""
|
1510
|
-
|
1509
|
+
Temporary folder type.
|
1511
1510
|
"""
|
1512
1511
|
|
1513
1512
|
|
@@ -1516,7 +1515,7 @@ class RTempFolder(RBase):
|
|
1516
1515
|
dir_: str | None = None
|
1517
1516
|
) -> None:
|
1518
1517
|
"""
|
1519
|
-
Build
|
1518
|
+
Build instance attributes.
|
1520
1519
|
|
1521
1520
|
Parameters
|
1522
1521
|
----------
|
@@ -1857,10 +1856,9 @@ def doc_to_docx(
|
|
1857
1856
|
DOCX file path.
|
1858
1857
|
"""
|
1859
1858
|
|
1860
|
-
|
1859
|
+
# Import.
|
1861
1860
|
from win32com.client import Dispatch, CDispatch
|
1862
1861
|
|
1863
|
-
|
1864
1862
|
# Handle parameter.
|
1865
1863
|
if save_path is None:
|
1866
1864
|
pattern = '.[dD][oO][cC]'
|
reykit/{rrandom.py → rrand.py}
RENAMED
@@ -19,14 +19,14 @@ from random import Random
|
|
19
19
|
from secrets import randbelow as secrets_randbelow
|
20
20
|
from threading import get_ident as threading_get_ident
|
21
21
|
|
22
|
-
from .
|
23
|
-
from .
|
24
|
-
from .rtype import T,
|
22
|
+
from .rexc import throw
|
23
|
+
from .rnum import digits
|
24
|
+
from .rtype import T, Base, ConfigMeta
|
25
25
|
|
26
26
|
|
27
27
|
__all__ = (
|
28
|
-
'
|
29
|
-
'
|
28
|
+
'ConfigRandom',
|
29
|
+
'RandomSeed',
|
30
30
|
'randn',
|
31
31
|
'randb',
|
32
32
|
'randi',
|
@@ -35,37 +35,37 @@ __all__ = (
|
|
35
35
|
)
|
36
36
|
|
37
37
|
|
38
|
-
class
|
38
|
+
class ConfigRandom(Base, metaclass=ConfigMeta):
|
39
39
|
"""
|
40
|
-
|
40
|
+
Config random type.
|
41
41
|
"""
|
42
42
|
|
43
43
|
# RRandom.
|
44
|
-
_rrandom_dict: dict[int,
|
44
|
+
_rrandom_dict: dict[int, RandomSeed] = {}
|
45
45
|
|
46
46
|
|
47
|
-
class
|
47
|
+
class RandomSeed(Base):
|
48
48
|
"""
|
49
|
-
|
49
|
+
Random seed type. set random seed.
|
50
50
|
If set, based on `random` package.
|
51
51
|
If not set, based on `secrets` package.
|
52
52
|
|
53
53
|
Examples
|
54
54
|
--------
|
55
55
|
Use active switch.
|
56
|
-
>>>
|
56
|
+
>>> RandomSeed(seed)
|
57
57
|
>>> randn()
|
58
|
-
>>>
|
58
|
+
>>> RandomSeed()
|
59
59
|
|
60
60
|
Use `with` syntax.
|
61
|
-
>>> with
|
61
|
+
>>> with RandomSeed(seed):
|
62
62
|
>>> randn()
|
63
63
|
"""
|
64
64
|
|
65
65
|
|
66
66
|
def __init__(self, seed: int | float | str | bytes | bytearray | None = None) -> None:
|
67
67
|
"""
|
68
|
-
Build
|
68
|
+
Build instance attributes.
|
69
69
|
|
70
70
|
Parameters
|
71
71
|
----------
|
@@ -85,7 +85,7 @@ class RRandomSeed(RBase):
|
|
85
85
|
|
86
86
|
## Record.
|
87
87
|
thread_id = threading_get_ident()
|
88
|
-
|
88
|
+
ConfigRandom._rrandom_dict[thread_id] = self
|
89
89
|
|
90
90
|
|
91
91
|
def __del__(self) -> None:
|
@@ -95,8 +95,8 @@ class RRandomSeed(RBase):
|
|
95
95
|
|
96
96
|
# Delete.
|
97
97
|
thread_id = threading_get_ident()
|
98
|
-
if thread_id in
|
99
|
-
del
|
98
|
+
if thread_id in ConfigRandom._rrandom_dict:
|
99
|
+
del ConfigRandom._rrandom_dict[thread_id]
|
100
100
|
|
101
101
|
|
102
102
|
def __enter__(self) -> Self:
|
@@ -221,7 +221,7 @@ def randn(
|
|
221
221
|
|
222
222
|
## No seed.
|
223
223
|
thread_id = threading_get_ident()
|
224
|
-
rrandom =
|
224
|
+
rrandom = ConfigRandom._rrandom_dict.get(thread_id)
|
225
225
|
if rrandom is None:
|
226
226
|
range_ = threshold_high - threshold_low + 1
|
227
227
|
number = secrets_randbelow(range_)
|
reykit/rschedule.py
CHANGED
@@ -16,17 +16,17 @@ from apscheduler.schedulers.background import BackgroundScheduler
|
|
16
16
|
from apscheduler.schedulers.blocking import BlockingScheduler
|
17
17
|
from apscheduler.job import Job
|
18
18
|
|
19
|
-
from .rtype import
|
19
|
+
from .rtype import Base
|
20
20
|
|
21
21
|
|
22
22
|
__all__ = (
|
23
|
-
'
|
23
|
+
'Schedule',
|
24
24
|
)
|
25
25
|
|
26
26
|
|
27
|
-
class
|
27
|
+
class Schedule(Base):
|
28
28
|
"""
|
29
|
-
|
29
|
+
Schedule type.
|
30
30
|
"""
|
31
31
|
|
32
32
|
|
@@ -38,7 +38,7 @@ class RSchedule(RBase):
|
|
38
38
|
block: bool = False
|
39
39
|
) -> None:
|
40
40
|
"""
|
41
|
-
Build
|
41
|
+
Build instance attributes.
|
42
42
|
|
43
43
|
Parameters
|
44
44
|
----------
|
reykit/rstdout.py
CHANGED
@@ -5,24 +5,24 @@
|
|
5
5
|
@Time : 2023-10-01 14:47:47
|
6
6
|
@Author : Rey
|
7
7
|
@Contact : reyxbo@163.com
|
8
|
-
@Explain : Standard output methods.
|
8
|
+
@Explain : Standard output and input methods.
|
9
9
|
"""
|
10
10
|
|
11
11
|
|
12
|
-
from typing import Any, Literal, Final
|
12
|
+
from typing import Any, Literal, Final
|
13
13
|
from collections.abc import Callable
|
14
14
|
import sys
|
15
15
|
from io import TextIOWrapper
|
16
16
|
from os import devnull as os_devnull
|
17
17
|
from os.path import abspath as os_abspath
|
18
18
|
|
19
|
-
from .
|
19
|
+
from .rsys import get_first_notnull, get_name, get_stack_param
|
20
20
|
from .rtext import to_text, add_text_frame
|
21
|
-
from .rtype import
|
21
|
+
from .rtype import Base, ConfigMeta
|
22
22
|
|
23
23
|
|
24
24
|
__all__ = (
|
25
|
-
'
|
25
|
+
'ConfigStdout',
|
26
26
|
'beautify_text',
|
27
27
|
'echo',
|
28
28
|
'rinput',
|
@@ -34,9 +34,9 @@ __all__ = (
|
|
34
34
|
)
|
35
35
|
|
36
36
|
|
37
|
-
class
|
37
|
+
class ConfigStdout(Base, metaclass=ConfigMeta):
|
38
38
|
"""
|
39
|
-
|
39
|
+
Config standard output type.
|
40
40
|
|
41
41
|
Attributes
|
42
42
|
----------
|
@@ -81,16 +81,16 @@ def beautify_text(
|
|
81
81
|
- `Literal[False]`: No title.
|
82
82
|
- `str`: Use this value as the title.
|
83
83
|
width : Text width.
|
84
|
-
- `None`: Use attribute `
|
84
|
+
- `None`: Use attribute `ConfigStdout.default_width`.
|
85
85
|
- `int`: Use this value.
|
86
86
|
frame : Text frame type.
|
87
87
|
- `Literal['full']`: Add beautiful four side frame and limit length.
|
88
|
-
When attribute `
|
88
|
+
When attribute `ConfigStdout.is_frame_plain` is True, then frame is `half_plain` type.
|
89
89
|
When throw `exception`, then frame is `half` type.
|
90
90
|
- `Literal['half']`: Add beautiful top and bottom side frame.
|
91
|
-
When attribute `
|
91
|
+
When attribute `ConfigStdout.is_frame_plain` is True, then frame is `half_plain` type.
|
92
92
|
- `Literal['top']`: Add beautiful top side frame.
|
93
|
-
When attribute `
|
93
|
+
When attribute `ConfigStdout.is_frame_plain` is True, then frame is `top_plain` type.
|
94
94
|
- `Literal['half_plain']`: Add plain top and bottom side frame.
|
95
95
|
- `Literal['top_plain']`: Add plain top side frame.
|
96
96
|
|
@@ -112,10 +112,10 @@ def beautify_text(
|
|
112
112
|
title = None
|
113
113
|
|
114
114
|
## Width.
|
115
|
-
width = get_first_notnull(width,
|
115
|
+
width = get_first_notnull(width, ConfigStdout.default_width, default='exception')
|
116
116
|
|
117
117
|
## Frame.
|
118
|
-
if
|
118
|
+
if ConfigStdout.is_frame_plain:
|
119
119
|
match frame:
|
120
120
|
case 'full':
|
121
121
|
frame = 'half_plain'
|
@@ -153,16 +153,16 @@ def echo(
|
|
153
153
|
- `Literal[False]`: No title.
|
154
154
|
- `str`: Use this value as the title.
|
155
155
|
width : Text width.
|
156
|
-
- `None`: Use attribute `
|
156
|
+
- `None`: Use attribute `ConfigStdout.default_width`.
|
157
157
|
- `int`: Use this value.
|
158
158
|
frame : Text frame type.
|
159
159
|
- `Literal['full']`: Add beautiful four side frame and limit length.
|
160
|
-
When attribute `
|
160
|
+
When attribute `ConfigStdout.is_frame_plain` is True, then frame is `half_plain` type.
|
161
161
|
When throw `exception`, then frame is `half` type.
|
162
162
|
- `Literal['half']`: Add beautiful top and bottom side frame.
|
163
|
-
When attribute `
|
163
|
+
When attribute `ConfigStdout.is_frame_plain` is True, then frame is `half_plain` type.
|
164
164
|
- `Literal['top']`: Add beautiful top side frame.
|
165
|
-
When attribute `
|
165
|
+
When attribute `ConfigStdout.is_frame_plain` is True, then frame is `top_plain` type.
|
166
166
|
- `Literal['half_plain']`: Add plain top and bottom side frame.
|
167
167
|
- `Literal['top_plain']`: Add plain top side frame.
|
168
168
|
|
@@ -198,16 +198,16 @@ def rinput(
|
|
198
198
|
- `Literal[False]`: No title.
|
199
199
|
- `str`: Use this value as the title.
|
200
200
|
width : Text width.
|
201
|
-
- `None`: Use attribute `
|
201
|
+
- `None`: Use attribute `ConfigStdout.default_width`.
|
202
202
|
- `int`: Use this value.
|
203
203
|
frame : Text frame type.
|
204
204
|
- `Literal['full']`: Add beautiful four side frame and limit length.
|
205
|
-
When attribute `
|
205
|
+
When attribute `ConfigStdout.is_frame_plain` is True, then frame is `half_plain` type.
|
206
206
|
When throw `exception`, then frame is `half` type.
|
207
207
|
- `Literal['half']`: Add beautiful top and bottom side frame.
|
208
|
-
When attribute `
|
208
|
+
When attribute `ConfigStdout.is_frame_plain` is True, then frame is `half_plain` type.
|
209
209
|
- `Literal['top']`: Add beautiful top side frame.
|
210
|
-
When attribute `
|
210
|
+
When attribute `ConfigStdout.is_frame_plain` is True, then frame is `top_plain` type.
|
211
211
|
- `Literal['half_plain']`: Add plain top and bottom side frame.
|
212
212
|
- `Literal['top_plain']`: Add plain top side frame.
|
213
213
|
extra : Extra print text at the end.
|
@@ -236,10 +236,10 @@ def stop_print() -> None:
|
|
236
236
|
"""
|
237
237
|
|
238
238
|
# Stop.
|
239
|
-
sys.stdout =
|
239
|
+
sys.stdout = ConfigStdout._io_null
|
240
240
|
|
241
241
|
# Update status.
|
242
|
-
|
242
|
+
ConfigStdout._stoped = True
|
243
243
|
|
244
244
|
|
245
245
|
def start_print() -> None:
|
@@ -248,13 +248,13 @@ def start_print() -> None:
|
|
248
248
|
"""
|
249
249
|
|
250
250
|
# Check.
|
251
|
-
if not
|
251
|
+
if not ConfigStdout._stoped: return
|
252
252
|
|
253
253
|
# Start.
|
254
|
-
sys.stdout =
|
254
|
+
sys.stdout = ConfigStdout._io_stdout
|
255
255
|
|
256
256
|
# Update status.
|
257
|
-
|
257
|
+
ConfigStdout._stoped = False
|
258
258
|
|
259
259
|
|
260
260
|
def modify_print(preprocess: Callable[[str], str] | None) -> None:
|
@@ -288,15 +288,15 @@ def modify_print(preprocess: Callable[[str], str] | None) -> None:
|
|
288
288
|
|
289
289
|
# Write.
|
290
290
|
if type(__s) == str:
|
291
|
-
write_len =
|
291
|
+
write_len = ConfigStdout._io_stdout_write(__s)
|
292
292
|
return write_len
|
293
293
|
|
294
294
|
|
295
295
|
# Modify.
|
296
|
-
|
296
|
+
ConfigStdout._io_stdout.write = write
|
297
297
|
|
298
298
|
# Update status.
|
299
|
-
|
299
|
+
ConfigStdout._modified = True
|
300
300
|
|
301
301
|
|
302
302
|
def reset_print() -> None:
|
@@ -305,13 +305,13 @@ def reset_print() -> None:
|
|
305
305
|
"""
|
306
306
|
|
307
307
|
# Check.
|
308
|
-
if not
|
308
|
+
if not ConfigStdout._modified: return
|
309
309
|
|
310
310
|
# Reset.
|
311
|
-
|
311
|
+
ConfigStdout._io_stdout.write = ConfigStdout._io_stdout_write
|
312
312
|
|
313
313
|
# Update status.
|
314
|
-
|
314
|
+
ConfigStdout._modified = False
|
315
315
|
|
316
316
|
|
317
317
|
def add_print_position() -> None:
|
@@ -343,7 +343,7 @@ def add_print_position() -> None:
|
|
343
343
|
|
344
344
|
## Compatible 'echo'.
|
345
345
|
if (
|
346
|
-
stack_floor['filename'] ==
|
346
|
+
stack_floor['filename'] == ConfigStdout._path_rstdout
|
347
347
|
and stack_floor['name'] == 'echo'
|
348
348
|
):
|
349
349
|
stack_floor = stack_params[-2]
|
reykit/{rsystem.py → rsys.py}
RENAMED
@@ -56,12 +56,12 @@ from tkinter.filedialog import (
|
|
56
56
|
askdirectory as tkinter_askdirectory
|
57
57
|
)
|
58
58
|
|
59
|
-
from .
|
60
|
-
from .rtype import
|
59
|
+
from .rexc import throw
|
60
|
+
from .rtype import Base, ConfigMeta
|
61
61
|
|
62
62
|
|
63
63
|
__all__ = (
|
64
|
-
'
|
64
|
+
'ConfigSystem',
|
65
65
|
'add_env_path',
|
66
66
|
'reset_env_path',
|
67
67
|
'del_modules',
|
@@ -127,9 +127,9 @@ NetWorkInfo = TypedDict(
|
|
127
127
|
ProcessInfo = TypedDict('ProcessInfo', {'create_time': datetime, 'id': int, 'name': str, 'ports': list[int] | None})
|
128
128
|
|
129
129
|
|
130
|
-
class
|
130
|
+
class ConfigSystem(Base, metaclass=ConfigMeta):
|
131
131
|
"""
|
132
|
-
|
132
|
+
Config system type.
|
133
133
|
"""
|
134
134
|
|
135
135
|
# Added environment path.
|
@@ -153,7 +153,7 @@ def add_env_path(path: str) -> list[str]:
|
|
153
153
|
abs_path = os_abspath(path)
|
154
154
|
|
155
155
|
# Add.
|
156
|
-
|
156
|
+
ConfigSystem._add_env_paths.append(abs_path)
|
157
157
|
sys_path.append(abs_path)
|
158
158
|
|
159
159
|
return sys_path
|
@@ -165,9 +165,9 @@ def reset_env_path() -> None:
|
|
165
165
|
"""
|
166
166
|
|
167
167
|
# Delete.
|
168
|
-
for path in
|
168
|
+
for path in ConfigSystem._add_env_paths:
|
169
169
|
sys_path.remove(path)
|
170
|
-
|
170
|
+
ConfigSystem._add_env_paths = []
|
171
171
|
|
172
172
|
|
173
173
|
def del_modules(path: str) -> list[str]:
|
@@ -184,7 +184,7 @@ def del_modules(path: str) -> list[str]:
|
|
184
184
|
"""
|
185
185
|
|
186
186
|
# Import.
|
187
|
-
from .
|
187
|
+
from .rre import search
|
188
188
|
|
189
189
|
# Set parameter.
|
190
190
|
deleted_dict = {}
|