reykit 1.1.25__py3-none-any.whl → 1.1.27__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 +1 -2
- reykit/rall.py +1 -2
- reykit/rbase.py +973 -0
- reykit/rdata.py +19 -12
- reykit/remail.py +6 -7
- reykit/rimage.py +10 -10
- reykit/rlog.py +27 -29
- reykit/rmonkey.py +9 -7
- reykit/rnet.py +10 -11
- reykit/rnum.py +2 -1
- reykit/ros.py +61 -52
- reykit/rrand.py +25 -50
- reykit/rre.py +1 -1
- reykit/rschedule.py +5 -5
- reykit/rstdout.py +30 -31
- reykit/rsys.py +34 -501
- reykit/rtable.py +5 -5
- reykit/rtask.py +21 -46
- reykit/rtext.py +1 -2
- reykit/rtime.py +33 -54
- reykit/rwrap.py +7 -8
- reykit/rzip.py +4 -4
- {reykit-1.1.25.dist-info → reykit-1.1.27.dist-info}/METADATA +1 -1
- reykit-1.1.27.dist-info/RECORD +28 -0
- reykit/rexc.py +0 -335
- reykit/rtype.py +0 -130
- reykit-1.1.25.dist-info/RECORD +0 -29
- {reykit-1.1.25.dist-info → reykit-1.1.27.dist-info}/WHEEL +0 -0
- {reykit-1.1.25.dist-info → reykit-1.1.27.dist-info}/licenses/LICENSE +0 -0
reykit/ros.py
CHANGED
@@ -51,11 +51,10 @@ 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 .
|
54
|
+
from .rbase import Base, throw
|
55
55
|
from .rre import search, sub
|
56
|
-
from .rsys import
|
56
|
+
from .rsys import run_cmd
|
57
57
|
from .rtext import to_json
|
58
|
-
from .rtype import RBase
|
59
58
|
|
60
59
|
|
61
60
|
__all__ = (
|
@@ -65,10 +64,10 @@ __all__ = (
|
|
65
64
|
'get_file_str',
|
66
65
|
'get_file_bytes',
|
67
66
|
'read_toml',
|
68
|
-
'
|
69
|
-
'
|
70
|
-
'
|
71
|
-
'
|
67
|
+
'File',
|
68
|
+
'Folder',
|
69
|
+
'TempFile',
|
70
|
+
'TempFolder',
|
72
71
|
'doc_to_docx',
|
73
72
|
'extract_docx_content',
|
74
73
|
'extract_pdf_content',
|
@@ -81,7 +80,6 @@ type FileText = str
|
|
81
80
|
type FileData = bytes
|
82
81
|
type FileStr = FilePath | FileText | TextIOBase
|
83
82
|
type FileBytes = FilePath | FileData | BufferedIOBase
|
84
|
-
type File = FileStr | FileBytes
|
85
83
|
|
86
84
|
|
87
85
|
def get_md5(file: str | bytes) -> str:
|
@@ -102,7 +100,7 @@ def get_md5(file: str | bytes) -> str:
|
|
102
100
|
|
103
101
|
## Path.
|
104
102
|
case str():
|
105
|
-
rfile =
|
103
|
+
rfile = File(file)
|
106
104
|
file_bytes = rfile.bytes
|
107
105
|
|
108
106
|
## Bytes.
|
@@ -128,7 +126,7 @@ def create_folder(*paths: str, report: bool = False) -> None:
|
|
128
126
|
|
129
127
|
# Create.
|
130
128
|
for path in paths:
|
131
|
-
rfolder =
|
129
|
+
rfolder = Folder(path)
|
132
130
|
rfolder.create(report)
|
133
131
|
|
134
132
|
|
@@ -205,7 +203,7 @@ def get_file_str(file: FileStr) -> str:
|
|
205
203
|
|
206
204
|
## Path.
|
207
205
|
if exist:
|
208
|
-
rfile =
|
206
|
+
rfile = File(file)
|
209
207
|
file_str = rfile.str
|
210
208
|
|
211
209
|
## String.
|
@@ -250,7 +248,7 @@ def get_file_bytes(file: FileBytes) -> bytes:
|
|
250
248
|
|
251
249
|
## Path.
|
252
250
|
case str():
|
253
|
-
rfile =
|
251
|
+
rfile = File(file)
|
254
252
|
file_bytes = rfile.bytes
|
255
253
|
|
256
254
|
## IO.
|
@@ -264,14 +262,14 @@ def get_file_bytes(file: FileBytes) -> bytes:
|
|
264
262
|
return file_bytes
|
265
263
|
|
266
264
|
|
267
|
-
def read_toml(path: str |
|
265
|
+
def read_toml(path: str | File) -> dict[str, Any]:
|
268
266
|
"""
|
269
267
|
Read and parse TOML file.
|
270
268
|
Treat nan as a None or null value.
|
271
269
|
|
272
270
|
Parameters
|
273
271
|
----------
|
274
|
-
path : File path or
|
272
|
+
path : File path or File object.
|
275
273
|
|
276
274
|
Returns
|
277
275
|
-------
|
@@ -283,11 +281,11 @@ def read_toml(path: str | RFile) -> dict[str, Any]:
|
|
283
281
|
|
284
282
|
## File path.
|
285
283
|
case str():
|
286
|
-
rfile =
|
284
|
+
rfile = File(path)
|
287
285
|
text = rfile.str
|
288
286
|
|
289
|
-
##
|
290
|
-
case
|
287
|
+
## File object.
|
288
|
+
case File():
|
291
289
|
text = rfile.str
|
292
290
|
|
293
291
|
# Parse.
|
@@ -300,9 +298,9 @@ def read_toml(path: str | RFile) -> dict[str, Any]:
|
|
300
298
|
return params
|
301
299
|
|
302
300
|
|
303
|
-
class
|
301
|
+
class File(Base):
|
304
302
|
"""
|
305
|
-
|
303
|
+
File type.
|
306
304
|
"""
|
307
305
|
|
308
306
|
|
@@ -311,7 +309,7 @@ class RFile(RBase):
|
|
311
309
|
path: str
|
312
310
|
) -> None:
|
313
311
|
"""
|
314
|
-
Build
|
312
|
+
Build instance attributes.
|
315
313
|
|
316
314
|
Parameters
|
317
315
|
----------
|
@@ -325,14 +323,14 @@ class RFile(RBase):
|
|
325
323
|
@overload
|
326
324
|
def open(
|
327
325
|
self,
|
328
|
-
mode:
|
329
|
-
) ->
|
326
|
+
mode: OpenBinaryMode = 'wb+'
|
327
|
+
) -> BinaryIO: ...
|
330
328
|
|
331
329
|
@overload
|
332
330
|
def open(
|
333
331
|
self,
|
334
|
-
mode:
|
335
|
-
) ->
|
332
|
+
mode: OpenTextMode
|
333
|
+
) -> TextIO: ...
|
336
334
|
|
337
335
|
def open(
|
338
336
|
self,
|
@@ -369,22 +367,10 @@ class RFile(RBase):
|
|
369
367
|
|
370
368
|
|
371
369
|
@overload
|
372
|
-
def
|
373
|
-
|
374
|
-
@overload
|
375
|
-
def w(self) -> TextIO: ...
|
370
|
+
def __getattr__(self, name: Literal['r', 'w', 'a']) -> TextIO: ...
|
376
371
|
|
377
372
|
@overload
|
378
|
-
def
|
379
|
-
|
380
|
-
@overload
|
381
|
-
def rb(self) -> BinaryIO: ...
|
382
|
-
|
383
|
-
@overload
|
384
|
-
def wb(self) -> BinaryIO: ...
|
385
|
-
|
386
|
-
@overload
|
387
|
-
def ab(self) -> BinaryIO: ...
|
373
|
+
def __getattr__(self, name: Literal['rb', 'wb', 'ab']) -> BinaryIO: ...
|
388
374
|
|
389
375
|
def __getattr__(self, name: Literal['r', 'w', 'a', 'rb', 'wb', 'ab']) -> TextIO | BinaryIO:
|
390
376
|
"""
|
@@ -399,10 +385,14 @@ class RFile(RBase):
|
|
399
385
|
IO object.
|
400
386
|
"""
|
401
387
|
|
388
|
+
# Open.
|
402
389
|
if name in ('r', 'w', 'a', 'rb', 'wb', 'ab'):
|
403
390
|
io = self.open(name)
|
404
391
|
return io
|
405
392
|
|
393
|
+
# Throw exception.
|
394
|
+
throw(AttributeError, name)
|
395
|
+
|
406
396
|
|
407
397
|
@overload
|
408
398
|
def read(
|
@@ -413,7 +403,7 @@ class RFile(RBase):
|
|
413
403
|
@overload
|
414
404
|
def read(
|
415
405
|
self,
|
416
|
-
type_: Literal['str']
|
406
|
+
type_: Literal['str']
|
417
407
|
) -> str: ...
|
418
408
|
|
419
409
|
def read(
|
@@ -539,7 +529,7 @@ class RFile(RBase):
|
|
539
529
|
# Read only.
|
540
530
|
except PermissionError:
|
541
531
|
command = f'attrib -r "{self.path}"'
|
542
|
-
|
532
|
+
run_cmd(command)
|
543
533
|
os_remove(self.path)
|
544
534
|
|
545
535
|
|
@@ -846,9 +836,9 @@ class RFile(RBase):
|
|
846
836
|
__call__ = write
|
847
837
|
|
848
838
|
|
849
|
-
class
|
839
|
+
class Folder(Base):
|
850
840
|
"""
|
851
|
-
|
841
|
+
Folder type.
|
852
842
|
"""
|
853
843
|
|
854
844
|
|
@@ -857,7 +847,7 @@ class RFolder(RBase):
|
|
857
847
|
path: str | None = None
|
858
848
|
) -> None:
|
859
849
|
"""
|
860
|
-
Build
|
850
|
+
Build instance attributes.
|
861
851
|
|
862
852
|
Parameters
|
863
853
|
----------
|
@@ -959,7 +949,8 @@ class RFolder(RBase):
|
|
959
949
|
self,
|
960
950
|
pattern: str,
|
961
951
|
recursion: bool = False,
|
962
|
-
|
952
|
+
*,
|
953
|
+
all_ : Literal[True]
|
963
954
|
) -> list[str]: ...
|
964
955
|
|
965
956
|
def search(
|
@@ -967,7 +958,7 @@ class RFolder(RBase):
|
|
967
958
|
pattern: str,
|
968
959
|
recursion: bool = False,
|
969
960
|
all_ : bool = False
|
970
|
-
) -> str | None:
|
961
|
+
) -> str | list[str] | None:
|
971
962
|
"""
|
972
963
|
Search file by name.
|
973
964
|
|
@@ -1220,9 +1211,9 @@ class RFolder(RBase):
|
|
1220
1211
|
__call__ = paths
|
1221
1212
|
|
1222
1213
|
|
1223
|
-
class
|
1214
|
+
class TempFile(Base):
|
1224
1215
|
"""
|
1225
|
-
|
1216
|
+
Temporary file type.
|
1226
1217
|
"""
|
1227
1218
|
|
1228
1219
|
|
@@ -1233,7 +1224,7 @@ class RTempFile(RBase):
|
|
1233
1224
|
type_: Literal['str', 'bytes'] = 'bytes'
|
1234
1225
|
) -> None:
|
1235
1226
|
"""
|
1236
|
-
Build
|
1227
|
+
Build instance attributes.
|
1237
1228
|
|
1238
1229
|
Parameters
|
1239
1230
|
----------
|
@@ -1453,6 +1444,23 @@ class RTempFile(RBase):
|
|
1453
1444
|
return file_md5
|
1454
1445
|
|
1455
1446
|
|
1447
|
+
@property
|
1448
|
+
def toml(self) -> dict[str, Any]:
|
1449
|
+
"""
|
1450
|
+
Read and parse TOML file.
|
1451
|
+
Treat nan as a None or null value.
|
1452
|
+
|
1453
|
+
Returns
|
1454
|
+
-------
|
1455
|
+
Parameter dictionary.
|
1456
|
+
"""
|
1457
|
+
|
1458
|
+
# Read and parse.
|
1459
|
+
params = read_toml(self.path)
|
1460
|
+
|
1461
|
+
return params
|
1462
|
+
|
1463
|
+
|
1456
1464
|
def __len__(self) -> int:
|
1457
1465
|
"""
|
1458
1466
|
Return file byte size.
|
@@ -1505,9 +1513,9 @@ class RTempFile(RBase):
|
|
1505
1513
|
__call__ = write
|
1506
1514
|
|
1507
1515
|
|
1508
|
-
class
|
1516
|
+
class TempFolder(Base):
|
1509
1517
|
"""
|
1510
|
-
|
1518
|
+
Temporary folder type.
|
1511
1519
|
"""
|
1512
1520
|
|
1513
1521
|
|
@@ -1516,7 +1524,7 @@ class RTempFolder(RBase):
|
|
1516
1524
|
dir_: str | None = None
|
1517
1525
|
) -> None:
|
1518
1526
|
"""
|
1519
|
-
Build
|
1527
|
+
Build instance attributes.
|
1520
1528
|
|
1521
1529
|
Parameters
|
1522
1530
|
----------
|
@@ -1615,7 +1623,8 @@ class RTempFolder(RBase):
|
|
1615
1623
|
self,
|
1616
1624
|
pattern: str,
|
1617
1625
|
recursion: bool = False,
|
1618
|
-
|
1626
|
+
*,
|
1627
|
+
all_ : Literal[True]
|
1619
1628
|
) -> list[str]: ...
|
1620
1629
|
|
1621
1630
|
def search(
|
reykit/rrand.py
CHANGED
@@ -19,14 +19,13 @@ 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 .
|
22
|
+
from .rbase import T, Base, ConfigMeta, throw
|
23
23
|
from .rnum import digits
|
24
|
-
from .rtype import T, RBase, RConfigMeta
|
25
24
|
|
26
25
|
|
27
26
|
__all__ = (
|
28
|
-
'
|
29
|
-
'
|
27
|
+
'ConfigRandom',
|
28
|
+
'RandomSeed',
|
30
29
|
'randn',
|
31
30
|
'randb',
|
32
31
|
'randi',
|
@@ -35,37 +34,37 @@ __all__ = (
|
|
35
34
|
)
|
36
35
|
|
37
36
|
|
38
|
-
class
|
37
|
+
class ConfigRandom(Base, metaclass=ConfigMeta):
|
39
38
|
"""
|
40
|
-
|
39
|
+
Config random type.
|
41
40
|
"""
|
42
41
|
|
43
42
|
# RRandom.
|
44
|
-
_rrandom_dict: dict[int,
|
43
|
+
_rrandom_dict: dict[int, RandomSeed] = {}
|
45
44
|
|
46
45
|
|
47
|
-
class
|
46
|
+
class RandomSeed(Base):
|
48
47
|
"""
|
49
|
-
|
48
|
+
Random seed type. set random seed.
|
50
49
|
If set, based on `random` package.
|
51
50
|
If not set, based on `secrets` package.
|
52
51
|
|
53
52
|
Examples
|
54
53
|
--------
|
55
54
|
Use active switch.
|
56
|
-
>>>
|
55
|
+
>>> RandomSeed(seed)
|
57
56
|
>>> randn()
|
58
|
-
>>>
|
57
|
+
>>> RandomSeed()
|
59
58
|
|
60
59
|
Use `with` syntax.
|
61
|
-
>>> with
|
60
|
+
>>> with RandomSeed(seed):
|
62
61
|
>>> randn()
|
63
62
|
"""
|
64
63
|
|
65
64
|
|
66
65
|
def __init__(self, seed: int | float | str | bytes | bytearray | None = None) -> None:
|
67
66
|
"""
|
68
|
-
Build
|
67
|
+
Build instance attributes.
|
69
68
|
|
70
69
|
Parameters
|
71
70
|
----------
|
@@ -85,7 +84,7 @@ class RRandomSeed(RBase):
|
|
85
84
|
|
86
85
|
## Record.
|
87
86
|
thread_id = threading_get_ident()
|
88
|
-
|
87
|
+
ConfigRandom._rrandom_dict[thread_id] = self
|
89
88
|
|
90
89
|
|
91
90
|
def __del__(self) -> None:
|
@@ -95,8 +94,8 @@ class RRandomSeed(RBase):
|
|
95
94
|
|
96
95
|
# Delete.
|
97
96
|
thread_id = threading_get_ident()
|
98
|
-
if thread_id in
|
99
|
-
del
|
97
|
+
if thread_id in ConfigRandom._rrandom_dict:
|
98
|
+
del ConfigRandom._rrandom_dict[thread_id]
|
100
99
|
|
101
100
|
|
102
101
|
def __enter__(self) -> Self:
|
@@ -132,48 +131,24 @@ class RRandomSeed(RBase):
|
|
132
131
|
|
133
132
|
|
134
133
|
@overload
|
135
|
-
def randn(
|
136
|
-
*,
|
137
|
-
precision: None = None
|
138
|
-
) -> int: ...
|
134
|
+
def randn() -> int: ...
|
139
135
|
|
140
136
|
@overload
|
141
|
-
def randn(
|
142
|
-
high: int = 10,
|
143
|
-
*,
|
144
|
-
precision: None = None
|
145
|
-
) -> int: ...
|
137
|
+
def randn(high: int = 10) -> int: ...
|
146
138
|
|
147
139
|
@overload
|
148
|
-
def randn(
|
149
|
-
low: int = 0,
|
150
|
-
high: int = 10,
|
151
|
-
*,
|
152
|
-
precision: None = None
|
153
|
-
) -> int: ...
|
140
|
+
def randn(low: int = 0, high: int = 10) -> int: ...
|
154
141
|
|
155
142
|
@overload
|
156
|
-
def randn(
|
157
|
-
*thresholds: float,
|
158
|
-
precision: None = None
|
159
|
-
) -> float: ...
|
143
|
+
def randn(*thresholds: float) -> float: ...
|
160
144
|
|
161
145
|
@overload
|
162
|
-
def randn(
|
163
|
-
*thresholds: float,
|
164
|
-
precision: Literal[0] = None
|
165
|
-
) -> int: ...
|
146
|
+
def randn(*thresholds: float, precision: Literal[0]) -> int: ...
|
166
147
|
|
167
148
|
@overload
|
168
|
-
def randn(
|
169
|
-
|
170
|
-
|
171
|
-
) -> float: ...
|
172
|
-
|
173
|
-
def randn(
|
174
|
-
*thresholds: float,
|
175
|
-
precision: int | None = None
|
176
|
-
) -> int | float:
|
149
|
+
def randn(*thresholds: float, precision: int) -> float: ...
|
150
|
+
|
151
|
+
def randn(*thresholds: float, precision: int | None = None) -> int | float:
|
177
152
|
"""
|
178
153
|
Random number.
|
179
154
|
|
@@ -221,7 +196,7 @@ def randn(
|
|
221
196
|
|
222
197
|
## No seed.
|
223
198
|
thread_id = threading_get_ident()
|
224
|
-
rrandom =
|
199
|
+
rrandom = ConfigRandom._rrandom_dict.get(thread_id)
|
225
200
|
if rrandom is None:
|
226
201
|
range_ = threshold_high - threshold_low + 1
|
227
202
|
number = secrets_randbelow(range_)
|
@@ -281,7 +256,7 @@ def randi(
|
|
281
256
|
@overload
|
282
257
|
def randi(
|
283
258
|
data: Sequence,
|
284
|
-
multi: int
|
259
|
+
multi: int,
|
285
260
|
unique: bool = True
|
286
261
|
) -> list[T]: ...
|
287
262
|
|
reykit/rre.py
CHANGED
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 .
|
19
|
+
from .rbase 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
@@ -16,13 +16,12 @@ 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 .rbase import Base, ConfigMeta, get_first_notnone, get_name, get_stack_param
|
20
20
|
from .rtext import to_text, add_text_frame
|
21
|
-
from .rtype import RBase, RConfigMeta
|
22
21
|
|
23
22
|
|
24
23
|
__all__ = (
|
25
|
-
'
|
24
|
+
'ConfigStdout',
|
26
25
|
'beautify_text',
|
27
26
|
'echo',
|
28
27
|
'rinput',
|
@@ -34,9 +33,9 @@ __all__ = (
|
|
34
33
|
)
|
35
34
|
|
36
35
|
|
37
|
-
class
|
36
|
+
class ConfigStdout(Base, metaclass=ConfigMeta):
|
38
37
|
"""
|
39
|
-
|
38
|
+
Config standard output type.
|
40
39
|
|
41
40
|
Attributes
|
42
41
|
----------
|
@@ -81,16 +80,16 @@ def beautify_text(
|
|
81
80
|
- `Literal[False]`: No title.
|
82
81
|
- `str`: Use this value as the title.
|
83
82
|
width : Text width.
|
84
|
-
- `None`: Use attribute `
|
83
|
+
- `None`: Use attribute `ConfigStdout.default_width`.
|
85
84
|
- `int`: Use this value.
|
86
85
|
frame : Text frame type.
|
87
86
|
- `Literal['full']`: Add beautiful four side frame and limit length.
|
88
|
-
When attribute `
|
87
|
+
When attribute `ConfigStdout.is_frame_plain` is True, then frame is `half_plain` type.
|
89
88
|
When throw `exception`, then frame is `half` type.
|
90
89
|
- `Literal['half']`: Add beautiful top and bottom side frame.
|
91
|
-
When attribute `
|
90
|
+
When attribute `ConfigStdout.is_frame_plain` is True, then frame is `half_plain` type.
|
92
91
|
- `Literal['top']`: Add beautiful top side frame.
|
93
|
-
When attribute `
|
92
|
+
When attribute `ConfigStdout.is_frame_plain` is True, then frame is `top_plain` type.
|
94
93
|
- `Literal['half_plain']`: Add plain top and bottom side frame.
|
95
94
|
- `Literal['top_plain']`: Add plain top side frame.
|
96
95
|
|
@@ -112,10 +111,10 @@ def beautify_text(
|
|
112
111
|
title = None
|
113
112
|
|
114
113
|
## Width.
|
115
|
-
width =
|
114
|
+
width = get_first_notnone(width, ConfigStdout.default_width)
|
116
115
|
|
117
116
|
## Frame.
|
118
|
-
if
|
117
|
+
if ConfigStdout.is_frame_plain:
|
119
118
|
match frame:
|
120
119
|
case 'full':
|
121
120
|
frame = 'half_plain'
|
@@ -153,16 +152,16 @@ def echo(
|
|
153
152
|
- `Literal[False]`: No title.
|
154
153
|
- `str`: Use this value as the title.
|
155
154
|
width : Text width.
|
156
|
-
- `None`: Use attribute `
|
155
|
+
- `None`: Use attribute `ConfigStdout.default_width`.
|
157
156
|
- `int`: Use this value.
|
158
157
|
frame : Text frame type.
|
159
158
|
- `Literal['full']`: Add beautiful four side frame and limit length.
|
160
|
-
When attribute `
|
159
|
+
When attribute `ConfigStdout.is_frame_plain` is True, then frame is `half_plain` type.
|
161
160
|
When throw `exception`, then frame is `half` type.
|
162
161
|
- `Literal['half']`: Add beautiful top and bottom side frame.
|
163
|
-
When attribute `
|
162
|
+
When attribute `ConfigStdout.is_frame_plain` is True, then frame is `half_plain` type.
|
164
163
|
- `Literal['top']`: Add beautiful top side frame.
|
165
|
-
When attribute `
|
164
|
+
When attribute `ConfigStdout.is_frame_plain` is True, then frame is `top_plain` type.
|
166
165
|
- `Literal['half_plain']`: Add plain top and bottom side frame.
|
167
166
|
- `Literal['top_plain']`: Add plain top side frame.
|
168
167
|
|
@@ -198,16 +197,16 @@ def rinput(
|
|
198
197
|
- `Literal[False]`: No title.
|
199
198
|
- `str`: Use this value as the title.
|
200
199
|
width : Text width.
|
201
|
-
- `None`: Use attribute `
|
200
|
+
- `None`: Use attribute `ConfigStdout.default_width`.
|
202
201
|
- `int`: Use this value.
|
203
202
|
frame : Text frame type.
|
204
203
|
- `Literal['full']`: Add beautiful four side frame and limit length.
|
205
|
-
When attribute `
|
204
|
+
When attribute `ConfigStdout.is_frame_plain` is True, then frame is `half_plain` type.
|
206
205
|
When throw `exception`, then frame is `half` type.
|
207
206
|
- `Literal['half']`: Add beautiful top and bottom side frame.
|
208
|
-
When attribute `
|
207
|
+
When attribute `ConfigStdout.is_frame_plain` is True, then frame is `half_plain` type.
|
209
208
|
- `Literal['top']`: Add beautiful top side frame.
|
210
|
-
When attribute `
|
209
|
+
When attribute `ConfigStdout.is_frame_plain` is True, then frame is `top_plain` type.
|
211
210
|
- `Literal['half_plain']`: Add plain top and bottom side frame.
|
212
211
|
- `Literal['top_plain']`: Add plain top side frame.
|
213
212
|
extra : Extra print text at the end.
|
@@ -236,10 +235,10 @@ def stop_print() -> None:
|
|
236
235
|
"""
|
237
236
|
|
238
237
|
# Stop.
|
239
|
-
sys.stdout =
|
238
|
+
sys.stdout = ConfigStdout._io_null
|
240
239
|
|
241
240
|
# Update status.
|
242
|
-
|
241
|
+
ConfigStdout._stoped = True
|
243
242
|
|
244
243
|
|
245
244
|
def start_print() -> None:
|
@@ -248,13 +247,13 @@ def start_print() -> None:
|
|
248
247
|
"""
|
249
248
|
|
250
249
|
# Check.
|
251
|
-
if not
|
250
|
+
if not ConfigStdout._stoped: return
|
252
251
|
|
253
252
|
# Start.
|
254
|
-
sys.stdout =
|
253
|
+
sys.stdout = ConfigStdout._io_stdout
|
255
254
|
|
256
255
|
# Update status.
|
257
|
-
|
256
|
+
ConfigStdout._stoped = False
|
258
257
|
|
259
258
|
|
260
259
|
def modify_print(preprocess: Callable[[str], str] | None) -> None:
|
@@ -288,15 +287,15 @@ def modify_print(preprocess: Callable[[str], str] | None) -> None:
|
|
288
287
|
|
289
288
|
# Write.
|
290
289
|
if type(__s) == str:
|
291
|
-
write_len =
|
290
|
+
write_len = ConfigStdout._io_stdout_write(__s)
|
292
291
|
return write_len
|
293
292
|
|
294
293
|
|
295
294
|
# Modify.
|
296
|
-
|
295
|
+
ConfigStdout._io_stdout.write = write
|
297
296
|
|
298
297
|
# Update status.
|
299
|
-
|
298
|
+
ConfigStdout._modified = True
|
300
299
|
|
301
300
|
|
302
301
|
def reset_print() -> None:
|
@@ -305,13 +304,13 @@ def reset_print() -> None:
|
|
305
304
|
"""
|
306
305
|
|
307
306
|
# Check.
|
308
|
-
if not
|
307
|
+
if not ConfigStdout._modified: return
|
309
308
|
|
310
309
|
# Reset.
|
311
|
-
|
310
|
+
ConfigStdout._io_stdout.write = ConfigStdout._io_stdout_write
|
312
311
|
|
313
312
|
# Update status.
|
314
|
-
|
313
|
+
ConfigStdout._modified = False
|
315
314
|
|
316
315
|
|
317
316
|
def add_print_position() -> None:
|
@@ -343,7 +342,7 @@ def add_print_position() -> None:
|
|
343
342
|
|
344
343
|
## Compatible 'echo'.
|
345
344
|
if (
|
346
|
-
stack_floor['filename'] ==
|
345
|
+
stack_floor['filename'] == ConfigStdout._path_rstdout
|
347
346
|
and stack_floor['name'] == 'echo'
|
348
347
|
):
|
349
348
|
stack_floor = stack_params[-2]
|