reykit 1.1.0__py3-none-any.whl → 1.1.1__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.
- reydb/__init__.py +25 -0
- reydb/rall.py +17 -0
- reydb/rbuild.py +1235 -0
- reydb/rconnection.py +2276 -0
- reydb/rexecute.py +350 -0
- reydb/rfile.py +416 -0
- reydb/rinformation.py +503 -0
- reydb/rparameter.py +243 -0
- reykit/__init__.py +1 -1
- reykit/rcomm.py +12 -12
- reykit/rdata.py +4 -4
- reykit/remail.py +12 -14
- reykit/rexception.py +4 -4
- reykit/rimage.py +9 -9
- reykit/rlog.py +30 -30
- reykit/rmonkey.py +4 -5
- reykit/rmultitask.py +14 -15
- reykit/rnumber.py +2 -2
- reykit/ros.py +21 -21
- reykit/rrandom.py +10 -10
- reykit/rregex.py +10 -13
- reykit/rschedule.py +10 -10
- reykit/rstdout.py +13 -13
- reykit/rsystem.py +54 -54
- reykit/rtable.py +31 -31
- reykit/rtext.py +3 -3
- reykit/rtime.py +11 -31
- reykit/rtype.py +2 -2
- reykit/rwrap.py +16 -16
- reykit/rzip.py +4 -5
- {reykit-1.1.0.dist-info → reykit-1.1.1.dist-info}/METADATA +1 -1
- reykit-1.1.1.dist-info/RECORD +38 -0
- reykit-1.1.0.dist-info/RECORD +0 -30
- {reykit-1.1.0.dist-info → reykit-1.1.1.dist-info}/WHEEL +0 -0
- {reykit-1.1.0.dist-info → reykit-1.1.1.dist-info}/top_level.txt +0 -0
reydb/rparameter.py
ADDED
@@ -0,0 +1,243 @@
|
|
1
|
+
# !/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
"""
|
5
|
+
@Time : 2022-12-05 14:10:02
|
6
|
+
@Author : Rey
|
7
|
+
@Contact : reyxbo@163.com
|
8
|
+
@Explain : Database parameter methods.
|
9
|
+
"""
|
10
|
+
|
11
|
+
|
12
|
+
from typing import overload
|
13
|
+
|
14
|
+
from .rconnection import RDatabase, RDBConnection
|
15
|
+
|
16
|
+
|
17
|
+
__all__ = (
|
18
|
+
'RDBParameter',
|
19
|
+
'RDBPStatus',
|
20
|
+
'RDBPVariable'
|
21
|
+
)
|
22
|
+
|
23
|
+
|
24
|
+
class RDBParameter(object):
|
25
|
+
"""
|
26
|
+
Rey's `database parameters` type.
|
27
|
+
"""
|
28
|
+
|
29
|
+
|
30
|
+
def __init__(
|
31
|
+
self,
|
32
|
+
rdatabase: RDatabase | RDBConnection,
|
33
|
+
global_: bool
|
34
|
+
) -> None:
|
35
|
+
"""
|
36
|
+
Build `database parameters` attributes.
|
37
|
+
|
38
|
+
Parameters
|
39
|
+
----------
|
40
|
+
rdatabase : RDatabase or RDBConnection instance.
|
41
|
+
global_ : Whether base global.
|
42
|
+
"""
|
43
|
+
|
44
|
+
# Set parameter.
|
45
|
+
self.rdatabase = rdatabase
|
46
|
+
self.global_ = global_
|
47
|
+
|
48
|
+
|
49
|
+
def __getitem__(self, key: str) -> str | None:
|
50
|
+
"""
|
51
|
+
Get item of parameter dictionary.
|
52
|
+
|
53
|
+
Parameters
|
54
|
+
----------
|
55
|
+
key : Parameter key.
|
56
|
+
|
57
|
+
Returns
|
58
|
+
-------
|
59
|
+
Parameter value.
|
60
|
+
"""
|
61
|
+
|
62
|
+
# Get.
|
63
|
+
value = self.get(key)
|
64
|
+
|
65
|
+
return value
|
66
|
+
|
67
|
+
|
68
|
+
def __setitem__(self, key: str, value: str | float) -> None:
|
69
|
+
"""
|
70
|
+
Set item of parameter dictionary.
|
71
|
+
|
72
|
+
Parameters
|
73
|
+
----------
|
74
|
+
key : Parameter key.
|
75
|
+
value : Parameter value.
|
76
|
+
"""
|
77
|
+
|
78
|
+
# Set.
|
79
|
+
params = {key: value}
|
80
|
+
|
81
|
+
# Update.
|
82
|
+
self.update(params)
|
83
|
+
|
84
|
+
|
85
|
+
class RDBPStatus(RDBParameter):
|
86
|
+
"""
|
87
|
+
Rey's `database parameter status` type.
|
88
|
+
"""
|
89
|
+
|
90
|
+
|
91
|
+
@overload
|
92
|
+
def get(self, key: None = None) -> dict[str, str]: ...
|
93
|
+
|
94
|
+
@overload
|
95
|
+
def get(self, key: str = None) -> str | None: ...
|
96
|
+
|
97
|
+
def get(self, key: str | None = None) -> dict[str, str] | str | None:
|
98
|
+
"""
|
99
|
+
Get parameter.
|
100
|
+
|
101
|
+
Parameters
|
102
|
+
----------
|
103
|
+
key : Parameter key.
|
104
|
+
- `None`: Return dictionary of all parameters.
|
105
|
+
- `str`: Return value of parameter.
|
106
|
+
|
107
|
+
Returns
|
108
|
+
-------
|
109
|
+
Status of database.
|
110
|
+
"""
|
111
|
+
|
112
|
+
# Generate SQL.
|
113
|
+
|
114
|
+
## Global.
|
115
|
+
if self.global_:
|
116
|
+
sql = 'SHOW GLOBAL STATUS'
|
117
|
+
|
118
|
+
## Not global.
|
119
|
+
else:
|
120
|
+
sql = 'SHOW STATUS'
|
121
|
+
|
122
|
+
# Execute SQL.
|
123
|
+
|
124
|
+
## Dictionary.
|
125
|
+
if key is None:
|
126
|
+
status = result.fetch_dict(val_field=1)
|
127
|
+
|
128
|
+
## Value.
|
129
|
+
else:
|
130
|
+
sql += ' LIKE :key'
|
131
|
+
result = self.rdatabase(sql, key=key)
|
132
|
+
row = result.first()
|
133
|
+
if row is None:
|
134
|
+
status = None
|
135
|
+
else:
|
136
|
+
status = row['Value']
|
137
|
+
|
138
|
+
return status
|
139
|
+
|
140
|
+
|
141
|
+
def update(self, params: dict[str, str | float]) -> None:
|
142
|
+
"""
|
143
|
+
Update parameter.
|
144
|
+
|
145
|
+
Parameters
|
146
|
+
----------
|
147
|
+
params : Update parameter key value pairs.
|
148
|
+
"""
|
149
|
+
|
150
|
+
# Throw exception.
|
151
|
+
raise AssertionError('database status not update')
|
152
|
+
|
153
|
+
|
154
|
+
class RDBPVariable(RDBParameter):
|
155
|
+
"""
|
156
|
+
Rey's `database parameter variable` type.
|
157
|
+
"""
|
158
|
+
|
159
|
+
|
160
|
+
@overload
|
161
|
+
def get(self, key: None = None) -> dict[str, str]: ...
|
162
|
+
|
163
|
+
@overload
|
164
|
+
def get(self, key: str = None) -> str | None: ...
|
165
|
+
|
166
|
+
def get(self, key: str | None = None) -> dict[str, str] | str | None:
|
167
|
+
"""
|
168
|
+
Get parameter.
|
169
|
+
|
170
|
+
Parameters
|
171
|
+
----------
|
172
|
+
key : Parameter key.
|
173
|
+
- `None`: Return dictionary of all parameters.
|
174
|
+
- `str`: Return value of parameter.
|
175
|
+
|
176
|
+
Returns
|
177
|
+
-------
|
178
|
+
Variables of database.
|
179
|
+
"""
|
180
|
+
|
181
|
+
# Generate SQL.
|
182
|
+
|
183
|
+
## Global.
|
184
|
+
if self.global_:
|
185
|
+
sql = 'SHOW GLOBAL VARIABLES'
|
186
|
+
|
187
|
+
## Not global.
|
188
|
+
else:
|
189
|
+
sql = 'SHOW VARIABLES'
|
190
|
+
|
191
|
+
# Execute SQL.
|
192
|
+
|
193
|
+
## Dictionary.
|
194
|
+
if key is None:
|
195
|
+
variables = result.fetch_dict(val_field=1)
|
196
|
+
|
197
|
+
## Value.
|
198
|
+
else:
|
199
|
+
sql += ' LIKE :key'
|
200
|
+
result = self.rdatabase(sql, key=key)
|
201
|
+
row = result.first()
|
202
|
+
if row is None:
|
203
|
+
variables = None
|
204
|
+
else:
|
205
|
+
variables = row['Value']
|
206
|
+
|
207
|
+
return variables
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
def update(self, params: dict[str, str | float]) -> None:
|
212
|
+
"""
|
213
|
+
Update parameter.
|
214
|
+
|
215
|
+
Parameters
|
216
|
+
----------
|
217
|
+
params : Update parameter key value pairs.
|
218
|
+
"""
|
219
|
+
|
220
|
+
# Generate SQL.
|
221
|
+
sql_set_list = [
|
222
|
+
'%s = %s' % (
|
223
|
+
key,
|
224
|
+
(
|
225
|
+
value
|
226
|
+
if value.__class__ in (int, float)
|
227
|
+
else "'%s'" % value
|
228
|
+
)
|
229
|
+
)
|
230
|
+
for key, value in params.items()
|
231
|
+
]
|
232
|
+
sql_set = ',\n '.join(sql_set_list)
|
233
|
+
|
234
|
+
# Global.
|
235
|
+
if self.global_:
|
236
|
+
sql = f'SET GLOBAL {sql_set}'
|
237
|
+
|
238
|
+
## Not global.
|
239
|
+
else:
|
240
|
+
sql = f'SET {sql_set}'
|
241
|
+
|
242
|
+
# Execute SQL.
|
243
|
+
self.rdatabase(sql)
|
reykit/__init__.py
CHANGED
reykit/rcomm.py
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
"""
|
10
10
|
|
11
11
|
|
12
|
-
from typing import Any, Literal
|
12
|
+
from typing import Any, Literal
|
13
13
|
from collections.abc import Callable, Iterable
|
14
14
|
from warnings import filterwarnings
|
15
15
|
from os.path import abspath as os_abspath, isfile as os_isfile
|
@@ -149,7 +149,7 @@ def split_cookie(cookie: str) -> dict[str, str]:
|
|
149
149
|
return params
|
150
150
|
|
151
151
|
|
152
|
-
def get_content_type(file:
|
152
|
+
def get_content_type(file: str | bytes) -> str | None:
|
153
153
|
"""
|
154
154
|
Get HTTP content type of file.
|
155
155
|
|
@@ -184,17 +184,17 @@ def get_content_type(file: Union[str, bytes]) -> Optional[str]:
|
|
184
184
|
|
185
185
|
def request(
|
186
186
|
url: str,
|
187
|
-
params:
|
188
|
-
data:
|
189
|
-
json:
|
190
|
-
files:
|
187
|
+
params: dict | None = None,
|
188
|
+
data: dict | str | bytes | None = None,
|
189
|
+
json: dict | None = None,
|
190
|
+
files: dict[str, str | bytes | tuple[str | bytes, dict]] | None = None,
|
191
191
|
headers: dict[str, str] = {},
|
192
|
-
timeout:
|
192
|
+
timeout: float | None = None,
|
193
193
|
proxies: dict[str, str] = {},
|
194
194
|
stream: bool = False,
|
195
195
|
verify: bool = False,
|
196
|
-
method:
|
197
|
-
check:
|
196
|
+
method: Literal['get', 'post', 'put', 'patch', 'delete', 'options', 'head'] | None = None,
|
197
|
+
check: bool | int | Iterable[int] = False
|
198
198
|
) -> Response:
|
199
199
|
"""
|
200
200
|
Send request.
|
@@ -318,7 +318,7 @@ def request(
|
|
318
318
|
return response
|
319
319
|
|
320
320
|
|
321
|
-
def download(url: str, path:
|
321
|
+
def download(url: str, path: str | None = None) -> str:
|
322
322
|
"""
|
323
323
|
Download file from URL.
|
324
324
|
|
@@ -363,7 +363,7 @@ def download(url: str, path: Optional[str] = None) -> str:
|
|
363
363
|
|
364
364
|
|
365
365
|
def get_file_stream_time(
|
366
|
-
file:
|
366
|
+
file: str | bytes | int,
|
367
367
|
bandwidth: float
|
368
368
|
) -> float:
|
369
369
|
"""
|
@@ -402,7 +402,7 @@ def get_file_stream_time(
|
|
402
402
|
|
403
403
|
def listen_socket(
|
404
404
|
host: str,
|
405
|
-
port:
|
405
|
+
port: str | int,
|
406
406
|
handler: Callable[[bytes], Any]
|
407
407
|
) -> None:
|
408
408
|
"""
|
reykit/rdata.py
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
"""
|
10
10
|
|
11
11
|
|
12
|
-
from typing import Any, TypedDict,
|
12
|
+
from typing import Any, TypedDict, Literal, NoReturn, TypeVar, overload
|
13
13
|
from collections.abc import Callable, Iterable, Generator
|
14
14
|
|
15
15
|
from .rexception import check_least_one, check_most_one
|
@@ -87,7 +87,7 @@ def count(
|
|
87
87
|
return result
|
88
88
|
|
89
89
|
|
90
|
-
def flatten(data: Any, *, _flattern_data:
|
90
|
+
def flatten(data: Any, *, _flattern_data: list | None = None) -> list:
|
91
91
|
"""
|
92
92
|
Flatten data.
|
93
93
|
|
@@ -136,9 +136,9 @@ def split(data: Iterable[Element], share: None = None, bin_size: None = None) ->
|
|
136
136
|
def split(data: Iterable[Element], share: int = None, bin_size: int = None) -> NoReturn: ...
|
137
137
|
|
138
138
|
@overload
|
139
|
-
def split(data: Iterable[Element], share:
|
139
|
+
def split(data: Iterable[Element], share: int | None = None, bin_size: int | None = None) -> list[list[Element]]: ...
|
140
140
|
|
141
|
-
def split(data: Iterable[Element], share:
|
141
|
+
def split(data: Iterable[Element], share: int | None = None, bin_size: int | None = None) -> list[list[Element]]:
|
142
142
|
"""
|
143
143
|
Split data into multiple data.
|
144
144
|
|
reykit/remail.py
CHANGED
@@ -9,8 +9,6 @@
|
|
9
9
|
"""
|
10
10
|
|
11
11
|
|
12
|
-
from typing import Optional, Union
|
13
|
-
from io import BufferedIOBase
|
14
12
|
from smtplib import SMTP
|
15
13
|
from email.mime.multipart import MIMEMultipart
|
16
14
|
from email.mime.text import MIMEText
|
@@ -101,12 +99,12 @@ class REmail(object):
|
|
101
99
|
|
102
100
|
def create_email(
|
103
101
|
self,
|
104
|
-
title:
|
105
|
-
text:
|
102
|
+
title: str | None,
|
103
|
+
text: str | None,
|
106
104
|
attachment: dict[str, bytes],
|
107
|
-
show_from:
|
108
|
-
show_to:
|
109
|
-
show_cc:
|
105
|
+
show_from: str | None,
|
106
|
+
show_to: list[str] | None,
|
107
|
+
show_cc: list[str] | None
|
110
108
|
) -> str:
|
111
109
|
"""
|
112
110
|
create email content.
|
@@ -169,14 +167,14 @@ class REmail(object):
|
|
169
167
|
|
170
168
|
def send_email(
|
171
169
|
self,
|
172
|
-
to:
|
173
|
-
title:
|
174
|
-
text:
|
170
|
+
to: str | list[str],
|
171
|
+
title: str | None = None,
|
172
|
+
text: str | None = None,
|
175
173
|
attachment: dict[str, FileBytes] = {},
|
176
|
-
cc:
|
177
|
-
show_from:
|
178
|
-
show_to:
|
179
|
-
show_cc:
|
174
|
+
cc: str | list[str] | None = None,
|
175
|
+
show_from: str | None = None,
|
176
|
+
show_to: str | list[str] | None = None,
|
177
|
+
show_cc: str | list[str] | None = None
|
180
178
|
) -> None:
|
181
179
|
"""
|
182
180
|
Send email.
|
reykit/rexception.py
CHANGED
@@ -20,7 +20,7 @@
|
|
20
20
|
"""
|
21
21
|
|
22
22
|
|
23
|
-
from typing import Any,
|
23
|
+
from typing import Any, NoReturn
|
24
24
|
from types import TracebackType
|
25
25
|
from collections.abc import Iterable
|
26
26
|
from sys import exc_info as sys_exc_info
|
@@ -61,7 +61,7 @@ def throw(
|
|
61
61
|
exception: type[BaseException] = AssertionError,
|
62
62
|
value: Any = RNull,
|
63
63
|
*values: Any,
|
64
|
-
text:
|
64
|
+
text: str | None = None,
|
65
65
|
frame: int = 2
|
66
66
|
) -> NoReturn:
|
67
67
|
"""
|
@@ -176,7 +176,7 @@ def warn(
|
|
176
176
|
|
177
177
|
|
178
178
|
def catch_exc(
|
179
|
-
title:
|
179
|
+
title: str | None = None
|
180
180
|
) -> tuple[str, type[BaseException], BaseException, TracebackType]:
|
181
181
|
"""
|
182
182
|
Catch exception information and print, must used in `except` syntax.
|
@@ -303,7 +303,7 @@ def check_file_exist(path: str) -> None:
|
|
303
303
|
|
304
304
|
def check_response_code(
|
305
305
|
code: int,
|
306
|
-
range_:
|
306
|
+
range_: int | Iterable[int] | None = None
|
307
307
|
) -> bool:
|
308
308
|
"""
|
309
309
|
Check if the response code is in range.
|
reykit/rimage.py
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
"""
|
10
10
|
|
11
11
|
|
12
|
-
from typing import Any
|
12
|
+
from typing import Any
|
13
13
|
from io import BytesIO
|
14
14
|
from qrcode import make as qrcode_make
|
15
15
|
from qrcode.image.pil import PilImage
|
@@ -42,7 +42,7 @@ monkey_image_type = monkey_path_pil_image_get_bytes()
|
|
42
42
|
RImage = monkey_image_type
|
43
43
|
|
44
44
|
|
45
|
-
def encode_qrcode(text: str, path:
|
45
|
+
def encode_qrcode(text: str, path: str | None = None) -> bytes:
|
46
46
|
"""
|
47
47
|
Encoding text to QR code image.
|
48
48
|
|
@@ -73,7 +73,7 @@ def encode_qrcode(text: str, path: Optional[str] = None) -> bytes:
|
|
73
73
|
return file_bytes
|
74
74
|
|
75
75
|
|
76
|
-
def decode_qrcode(image:
|
76
|
+
def decode_qrcode(image: str | bytes) -> list[str]:
|
77
77
|
"""
|
78
78
|
Decoding QR code or bar code image.
|
79
79
|
|
@@ -108,14 +108,14 @@ def decode_qrcode(image: Union[str, bytes]) -> list[str]:
|
|
108
108
|
|
109
109
|
|
110
110
|
def compress_image(
|
111
|
-
input_image:
|
112
|
-
ouput_image:
|
111
|
+
input_image: str | bytes,
|
112
|
+
ouput_image: str | None = None,
|
113
113
|
target_size: float = 0.5,
|
114
114
|
rate: int = 5,
|
115
115
|
reduce: bool = False,
|
116
116
|
max_quality: int = 75,
|
117
117
|
min_quality: int = 0
|
118
|
-
) ->
|
118
|
+
) -> bytes | None:
|
119
119
|
"""
|
120
120
|
Compress image file.
|
121
121
|
|
@@ -187,7 +187,7 @@ def compress_image(
|
|
187
187
|
rfile(content)
|
188
188
|
|
189
189
|
|
190
|
-
def to_pimage(image:
|
190
|
+
def to_pimage(image: str | bytes) -> RImage:
|
191
191
|
"""
|
192
192
|
Get `Image` instance of `PIL` package.
|
193
193
|
|
@@ -215,8 +215,8 @@ def to_pimage(image: Union[str, bytes]) -> RImage:
|
|
215
215
|
|
216
216
|
|
217
217
|
def generate_captcha_image(
|
218
|
-
text:
|
219
|
-
path:
|
218
|
+
text: int | str | None = None,
|
219
|
+
path: str | None = None,
|
220
220
|
**kwargs: Any
|
221
221
|
) -> bytes:
|
222
222
|
"""
|
reykit/rlog.py
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
|
12
12
|
from __future__ import annotations
|
13
|
-
from typing import Any,
|
13
|
+
from typing import Any, Literal, Final, NoReturn, overload, override
|
14
14
|
from collections.abc import Callable
|
15
15
|
from queue import Queue
|
16
16
|
from os.path import abspath as os_abspath
|
@@ -291,7 +291,7 @@ class RLog(object):
|
|
291
291
|
def get_default_filter_method(
|
292
292
|
self,
|
293
293
|
format_: str,
|
294
|
-
mode :
|
294
|
+
mode : Literal['print', 'file'] | None = None
|
295
295
|
) -> Callable[[LogRecord], Literal[True]]:
|
296
296
|
"""
|
297
297
|
Get default filter method of handler.
|
@@ -397,8 +397,8 @@ class RLog(object):
|
|
397
397
|
def add_print(
|
398
398
|
self,
|
399
399
|
level: int = DEBUG,
|
400
|
-
format_:
|
401
|
-
filter_:
|
400
|
+
format_: str | None = None,
|
401
|
+
filter_: Callable[[LogRecord], bool] | None = None
|
402
402
|
) -> StreamHandler:
|
403
403
|
"""
|
404
404
|
Add print output record handler.
|
@@ -443,56 +443,56 @@ class RLog(object):
|
|
443
443
|
@overload
|
444
444
|
def add_file(
|
445
445
|
self,
|
446
|
-
path:
|
447
|
-
mb:
|
446
|
+
path: str | None = None,
|
447
|
+
mb: float | None = None,
|
448
448
|
time: None = None,
|
449
449
|
level: int = DEBUG,
|
450
|
-
format_:
|
451
|
-
filter_:
|
450
|
+
format_: str | None = None,
|
451
|
+
filter_: Callable[[LogRecord], bool] | None = None
|
452
452
|
) -> ConcurrentRotatingFileHandler: ...
|
453
453
|
|
454
454
|
@overload
|
455
455
|
def add_file(
|
456
456
|
self,
|
457
|
-
path:
|
457
|
+
path: str | None = None,
|
458
458
|
mb: None = None,
|
459
|
-
time:
|
459
|
+
time: float | Literal['m', 'w0', 'w1', 'w2', 'w3', 'w4', 'w5', 'w6'] = None,
|
460
460
|
level: int = DEBUG,
|
461
|
-
format_:
|
462
|
-
filter_:
|
461
|
+
format_: str | None = None,
|
462
|
+
filter_: Callable[[LogRecord], bool] | None = None
|
463
463
|
) -> ConcurrentTimedRotatingFileHandler: ...
|
464
464
|
|
465
465
|
@overload
|
466
466
|
def add_file(
|
467
467
|
self,
|
468
|
-
path:
|
468
|
+
path: str | None = None,
|
469
469
|
mb: None = None,
|
470
470
|
time: Any = None,
|
471
471
|
level: int = DEBUG,
|
472
|
-
format_:
|
473
|
-
filter_:
|
472
|
+
format_: str | None = None,
|
473
|
+
filter_: Callable[[LogRecord], bool] | None = None
|
474
474
|
) -> NoReturn: ...
|
475
475
|
|
476
476
|
@overload
|
477
477
|
def add_file(
|
478
478
|
self,
|
479
|
-
path:
|
479
|
+
path: str | None = None,
|
480
480
|
mb: float = None,
|
481
|
-
time:
|
481
|
+
time: float | Literal['m', 'w0', 'w1', 'w2', 'w3', 'w4', 'w5', 'w6'] = None,
|
482
482
|
level: int = DEBUG,
|
483
|
-
format_:
|
484
|
-
filter_:
|
483
|
+
format_: str | None = None,
|
484
|
+
filter_: Callable[[LogRecord], bool] | None = None
|
485
485
|
) -> NoReturn: ...
|
486
486
|
|
487
487
|
def add_file(
|
488
488
|
self,
|
489
|
-
path:
|
490
|
-
mb:
|
491
|
-
time:
|
489
|
+
path: str | None = None,
|
490
|
+
mb: float | None = None,
|
491
|
+
time: float | Literal['m', 'w0', 'w1', 'w2', 'w3', 'w4', 'w5', 'w6'] | None = None,
|
492
492
|
level: int = DEBUG,
|
493
|
-
format_:
|
494
|
-
filter_:
|
495
|
-
) ->
|
493
|
+
format_: str | None = None,
|
494
|
+
filter_: Callable[[LogRecord], bool] | None = None
|
495
|
+
) -> ConcurrentRotatingFileHandler | ConcurrentTimedRotatingFileHandler:
|
496
496
|
"""
|
497
497
|
Add file output record handler, can split files based on size or time.
|
498
498
|
|
@@ -613,9 +613,9 @@ class RLog(object):
|
|
613
613
|
|
614
614
|
def add_queue(
|
615
615
|
self,
|
616
|
-
queue:
|
616
|
+
queue: Queue | None = None,
|
617
617
|
level: int = DEBUG,
|
618
|
-
filter_:
|
618
|
+
filter_: Callable[[LogRecord], bool] | None = None
|
619
619
|
) -> tuple[QueueHandler, Queue[LogRecord]]:
|
620
620
|
"""
|
621
621
|
Add queue output record handler.
|
@@ -655,7 +655,7 @@ class RLog(object):
|
|
655
655
|
self,
|
656
656
|
method: Callable[[LogRecord], Any],
|
657
657
|
level: int = DEBUG,
|
658
|
-
filter_:
|
658
|
+
filter_: Callable[[LogRecord], bool] | None = None
|
659
659
|
) -> None:
|
660
660
|
"""
|
661
661
|
Add method record handler.
|
@@ -771,7 +771,7 @@ class RLog(object):
|
|
771
771
|
def log(
|
772
772
|
self,
|
773
773
|
*messages: Any,
|
774
|
-
level:
|
774
|
+
level: int | None = None,
|
775
775
|
catch: bool = True,
|
776
776
|
**params: Any
|
777
777
|
) -> None:
|
@@ -970,7 +970,7 @@ class RRecord(object):
|
|
970
970
|
|
971
971
|
def __init__(
|
972
972
|
self,
|
973
|
-
path:
|
973
|
+
path: str | None = '_rrecord'
|
974
974
|
) -> None:
|
975
975
|
"""
|
976
976
|
Build `record` attributes.
|
reykit/rmonkey.py
CHANGED
@@ -29,7 +29,6 @@ def monkey_patch_sqlalchemy_result_more_fetch():
|
|
29
29
|
"""
|
30
30
|
|
31
31
|
|
32
|
-
from typing import Optional
|
33
32
|
from sqlalchemy.engine.cursor import CursorResult
|
34
33
|
from pandas import DataFrame, NA, concat
|
35
34
|
|
@@ -81,7 +80,7 @@ def monkey_patch_sqlalchemy_result_more_fetch():
|
|
81
80
|
|
82
81
|
|
83
82
|
# Print result.
|
84
|
-
def method_show(self: RResult, limit:
|
83
|
+
def method_show(self: RResult, limit: int | None = None) -> None:
|
85
84
|
"""
|
86
85
|
Print result.
|
87
86
|
|
@@ -207,18 +206,18 @@ def monkey_patch_sqlalchemy_row_index_field():
|
|
207
206
|
"""
|
208
207
|
|
209
208
|
|
210
|
-
from typing import Any,
|
209
|
+
from typing import Any, overload
|
211
210
|
from sqlalchemy.engine.row import Row
|
212
211
|
|
213
212
|
|
214
213
|
# Define.
|
215
214
|
@overload
|
216
|
-
def __getitem__(self, index:
|
215
|
+
def __getitem__(self, index: str | int) -> Any: ...
|
217
216
|
|
218
217
|
@overload
|
219
218
|
def __getitem__(self, index: slice) -> tuple: ...
|
220
219
|
|
221
|
-
def __getitem__(self, index:
|
220
|
+
def __getitem__(self, index: str | int | slice) -> Any | tuple:
|
222
221
|
"""
|
223
222
|
Index row value.
|
224
223
|
|