reykit 1.1.25__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/rdata.py +17 -8
- reykit/remail.py +6 -6
- reykit/rexc.py +9 -9
- reykit/rimage.py +9 -9
- reykit/rlog.py +23 -23
- reykit/rmonkey.py +9 -7
- reykit/rnet.py +10 -10
- reykit/ros.py +26 -27
- reykit/rrand.py +16 -16
- reykit/rschedule.py +5 -5
- reykit/rstdout.py +30 -30
- reykit/rsys.py +7 -7
- reykit/rtable.py +2 -2
- reykit/rtask.py +13 -13
- reykit/rtime.py +6 -6
- reykit/rtype.py +17 -17
- reykit/rwrap.py +2 -2
- reykit/rzip.py +4 -4
- {reykit-1.1.25.dist-info → reykit-1.1.26.dist-info}/METADATA +1 -1
- reykit-1.1.26.dist-info/RECORD +29 -0
- reykit-1.1.25.dist-info/RECORD +0 -29
- {reykit-1.1.25.dist-info → reykit-1.1.26.dist-info}/WHEEL +0 -0
- {reykit-1.1.25.dist-info → reykit-1.1.26.dist-info}/licenses/LICENSE +0 -0
reykit/ros.py
CHANGED
@@ -55,7 +55,7 @@ from .rexc import throw
|
|
55
55
|
from .rre import search, sub
|
56
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
|
----------
|
reykit/rrand.py
CHANGED
@@ -21,12 +21,12 @@ from threading import get_ident as threading_get_ident
|
|
21
21
|
|
22
22
|
from .rexc import throw
|
23
23
|
from .rnum import digits
|
24
|
-
from .rtype import T,
|
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
@@ -18,11 +18,11 @@ from os.path import abspath as os_abspath
|
|
18
18
|
|
19
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/rsys.py
CHANGED
@@ -57,11 +57,11 @@ from tkinter.filedialog import (
|
|
57
57
|
)
|
58
58
|
|
59
59
|
from .rexc import throw
|
60
|
-
from .rtype import
|
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]:
|
reykit/rtable.py
CHANGED
@@ -15,7 +15,7 @@ from os.path import abspath as os_abspath
|
|
15
15
|
from pandas import DataFrame, ExcelWriter, isnull
|
16
16
|
from sqlalchemy.engine.cursor import CursorResult
|
17
17
|
|
18
|
-
from .ros import
|
18
|
+
from .ros import File
|
19
19
|
from .rtext import to_json, to_text
|
20
20
|
from .rtime import time_to
|
21
21
|
|
@@ -416,7 +416,7 @@ def to_csv(
|
|
416
416
|
|
417
417
|
# Handle parameter.
|
418
418
|
data_df = to_df(data, fields)
|
419
|
-
rfile =
|
419
|
+
rfile = File(path)
|
420
420
|
if rfile:
|
421
421
|
header = False
|
422
422
|
else:
|
reykit/rtask.py
CHANGED
@@ -31,24 +31,24 @@ from asyncio import (
|
|
31
31
|
from aiohttp import ClientSession, ClientResponse
|
32
32
|
|
33
33
|
from .rexc import throw, check_most_one, check_response_code
|
34
|
-
from .rtime import randn,
|
35
|
-
from .rtype import T,
|
34
|
+
from .rtime import randn, TimeMark
|
35
|
+
from .rtype import T, Base
|
36
36
|
from .rwrap import wrap_thread
|
37
37
|
|
38
38
|
|
39
39
|
__all__ = (
|
40
|
-
'
|
40
|
+
'ThreadPool',
|
41
41
|
'async_run',
|
42
42
|
'async_sleep',
|
43
43
|
'async_wait',
|
44
44
|
'async_request',
|
45
|
-
'
|
45
|
+
'AsyncPool'
|
46
46
|
)
|
47
47
|
|
48
48
|
|
49
|
-
class
|
49
|
+
class ThreadPool(Base):
|
50
50
|
"""
|
51
|
-
|
51
|
+
Thread pool type.
|
52
52
|
|
53
53
|
Attributes
|
54
54
|
----------
|
@@ -68,7 +68,7 @@ class RThreadPool(RBase):
|
|
68
68
|
**kwargs: Any
|
69
69
|
) -> None:
|
70
70
|
"""
|
71
|
-
Build
|
71
|
+
Build instance attributes.
|
72
72
|
|
73
73
|
Parameters
|
74
74
|
----------
|
@@ -157,7 +157,7 @@ class RThreadPool(RBase):
|
|
157
157
|
>>> b = (3, 4, 5)
|
158
158
|
>>> c = (11, 12)
|
159
159
|
>>> d = (13, 14, 15)
|
160
|
-
>>> thread_pool =
|
160
|
+
>>> thread_pool = ThreadPool(func, 0, z=0)
|
161
161
|
>>> thread_pool.batch(a, b, c=c, d=d)
|
162
162
|
(0, 1, 3) {'z': 0, 'c': 11, 'd': 13}
|
163
163
|
(0, 2, 4) {'z': 0, 'c': 12, 'd': 14}
|
@@ -474,7 +474,7 @@ async def async_wait(
|
|
474
474
|
"""
|
475
475
|
|
476
476
|
# Set parameter.
|
477
|
-
rtm =
|
477
|
+
rtm = TimeMark()
|
478
478
|
rtm()
|
479
479
|
|
480
480
|
# Not set timeout.
|
@@ -669,9 +669,9 @@ async def async_request(
|
|
669
669
|
return result
|
670
670
|
|
671
671
|
|
672
|
-
class
|
672
|
+
class AsyncPool(Base):
|
673
673
|
"""
|
674
|
-
|
674
|
+
Asynchronous pool type.
|
675
675
|
|
676
676
|
Attributes
|
677
677
|
----------
|
@@ -690,7 +690,7 @@ class RAsyncPool(RBase):
|
|
690
690
|
**kwargs: Any
|
691
691
|
) -> None:
|
692
692
|
"""
|
693
|
-
Build
|
693
|
+
Build instance attributes.
|
694
694
|
|
695
695
|
Parameters
|
696
696
|
----------
|
@@ -779,7 +779,7 @@ class RAsyncPool(RBase):
|
|
779
779
|
>>> b = (3, 4, 5)
|
780
780
|
>>> c = (11, 12)
|
781
781
|
>>> d = (13, 14, 15)
|
782
|
-
>>> async_pool =
|
782
|
+
>>> async_pool = AsyncPool(func, 0, z=0)
|
783
783
|
>>> async_pool.batch(a, b, c=c, d=d)
|
784
784
|
(0, 1, 3) {'z': 0, 'c': 11, 'd': 13}
|
785
785
|
(0, 2, 4) {'z': 0, 'c': 12, 'd': 14}
|
reykit/rtime.py
CHANGED
@@ -34,7 +34,7 @@ from .rnum import digits, to_number
|
|
34
34
|
from .rrand import randn
|
35
35
|
from .rre import search
|
36
36
|
from .rstdout import echo
|
37
|
-
from .rtype import T
|
37
|
+
from .rtype import T, Base
|
38
38
|
|
39
39
|
|
40
40
|
__all__ = (
|
@@ -44,7 +44,7 @@ __all__ = (
|
|
44
44
|
'to_time',
|
45
45
|
'sleep',
|
46
46
|
'wait',
|
47
|
-
'
|
47
|
+
'TimeMark'
|
48
48
|
)
|
49
49
|
|
50
50
|
|
@@ -482,7 +482,7 @@ def wait(
|
|
482
482
|
"""
|
483
483
|
|
484
484
|
# Set parameter.
|
485
|
-
rtm =
|
485
|
+
rtm = TimeMark()
|
486
486
|
rtm()
|
487
487
|
|
488
488
|
# Not set timeout.
|
@@ -520,15 +520,15 @@ def wait(
|
|
520
520
|
return rtm.total_spend
|
521
521
|
|
522
522
|
|
523
|
-
class
|
523
|
+
class TimeMark(Base):
|
524
524
|
"""
|
525
|
-
|
525
|
+
Time mark type.
|
526
526
|
"""
|
527
527
|
|
528
528
|
|
529
529
|
def __init__(self) -> None:
|
530
530
|
"""
|
531
|
-
Build
|
531
|
+
Build instance attributes.
|
532
532
|
"""
|
533
533
|
|
534
534
|
# Record table.
|