reykit 1.0.1__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 +1 -1
- reydb/rbuild.py +44 -44
- reydb/rconnection.py +107 -107
- reydb/rexecute.py +9 -13
- reydb/rfile.py +8 -8
- reydb/rinformation.py +13 -25
- reydb/rparameter.py +10 -10
- 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 +11 -11
- reykit/rregex.py +10 -13
- reykit/rschedule.py +10 -10
- reykit/rstdout.py +13 -13
- reykit/rsystem.py +224 -30
- 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.0.1.dist-info → reykit-1.1.1.dist-info}/METADATA +1 -1
- reykit-1.1.1.dist-info/RECORD +38 -0
- reykit-1.0.1.dist-info/RECORD +0 -64
- reyweb/__init__.py +0 -19
- reyweb/rall.py +0 -12
- reyweb/rbaidu/__init__.py +0 -21
- reyweb/rbaidu/rbaidu_base.py +0 -186
- reyweb/rbaidu/rbaidu_chat.py +0 -299
- reyweb/rbaidu/rbaidu_image.py +0 -183
- reyweb/rbaidu/rbaidu_voice.py +0 -256
- reywechat/__init__.py +0 -32
- reywechat/data/client_api.dll +0 -0
- reywechat/rall.py +0 -20
- reywechat/rclient.py +0 -912
- reywechat/rdatabase.py +0 -1189
- reywechat/rexception.py +0 -65
- reywechat/rexecute.py +0 -201
- reywechat/rlog.py +0 -198
- reywechat/rreceive.py +0 -1232
- reywechat/rschedule.py +0 -136
- reywechat/rsend.py +0 -630
- reywechat/rwechat.py +0 -201
- reyworm/__init__.py +0 -24
- reyworm/rall.py +0 -16
- reyworm/rbrowser.py +0 -134
- reyworm/rcalendar.py +0 -159
- reyworm/rnews.py +0 -126
- reyworm/rsecurity.py +0 -239
- reyworm/rtranslate.py +0 -75
- {reykit-1.0.1.dist-info → reykit-1.1.1.dist-info}/WHEEL +0 -0
- {reykit-1.0.1.dist-info → reykit-1.1.1.dist-info}/top_level.txt +0 -0
reykit/rsystem.py
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
"""
|
10
10
|
|
11
11
|
|
12
|
-
from typing import Any, TypedDict, Literal,
|
12
|
+
from typing import Any, TypedDict, Literal, overload
|
13
13
|
from collections.abc import Callable, Iterable, Sequence
|
14
14
|
from inspect import signature as inspect_signature, _ParameterKind, _empty
|
15
15
|
from sys import path as sys_path, modules as sys_modules
|
@@ -39,6 +39,21 @@ from time import sleep as time_sleep
|
|
39
39
|
from datetime import datetime
|
40
40
|
from varname import VarnameRetrievingError, argname
|
41
41
|
from webbrowser import open as webbrowser_open
|
42
|
+
from tkinter.messagebox import (
|
43
|
+
showinfo as tkinter_showinfo,
|
44
|
+
showwarning as tkinter_showwarning,
|
45
|
+
showerror as tkinter_showerror,
|
46
|
+
askyesno as tkinter_askyesno,
|
47
|
+
askyesnocancel as tkinter_askyesnocancel,
|
48
|
+
askokcancel as tkinter_askokcancel,
|
49
|
+
askretrycancel as tkinter_askretrycancel
|
50
|
+
)
|
51
|
+
from tkinter.filedialog import (
|
52
|
+
askopenfilename as tkinter_askopenfilename,
|
53
|
+
askopenfilenames as tkinter_askopenfilenames,
|
54
|
+
asksaveasfilename as tkinter_asksaveasfilename,
|
55
|
+
askdirectory as tkinter_askdirectory
|
56
|
+
)
|
42
57
|
|
43
58
|
from .rexception import throw
|
44
59
|
from .rtype import RConfigMeta
|
@@ -68,7 +83,10 @@ __all__ = (
|
|
68
83
|
'stop_process',
|
69
84
|
'start_process',
|
70
85
|
'get_idle_port',
|
71
|
-
'open_browser'
|
86
|
+
'open_browser',
|
87
|
+
'popup_message',
|
88
|
+
'popup_ask',
|
89
|
+
'popup_select'
|
72
90
|
)
|
73
91
|
|
74
92
|
|
@@ -92,17 +110,17 @@ ComputerInfo = TypedDict(
|
|
92
110
|
NetWorkInfo = TypedDict(
|
93
111
|
'NetWorkTable',
|
94
112
|
{
|
95
|
-
'family':
|
96
|
-
'socket':
|
113
|
+
'family': str | None,
|
114
|
+
'socket': str | None,
|
97
115
|
'local_ip': str,
|
98
116
|
'local_port': int,
|
99
|
-
'remote_ip':
|
100
|
-
'remote_port':
|
101
|
-
'status':
|
102
|
-
'pid':
|
117
|
+
'remote_ip': str | None,
|
118
|
+
'remote_port': int | None,
|
119
|
+
'status': str | None,
|
120
|
+
'pid': int | None
|
103
121
|
}
|
104
122
|
)
|
105
|
-
ProcessInfo = TypedDict('ProcessInfo', {'create_time': datetime, 'id': int, 'name': str, 'ports':
|
123
|
+
ProcessInfo = TypedDict('ProcessInfo', {'create_time': datetime, 'id': int, 'name': str, 'ports': list[int] | None})
|
106
124
|
|
107
125
|
|
108
126
|
class RConfigSystem(object, metaclass=RConfigMeta):
|
@@ -190,7 +208,7 @@ def del_modules(path: str) -> list[str]:
|
|
190
208
|
return deleted_dict
|
191
209
|
|
192
210
|
|
193
|
-
def dos_command(command:
|
211
|
+
def dos_command(command: str | Iterable[str]) -> str:
|
194
212
|
"""
|
195
213
|
Execute DOS command.
|
196
214
|
|
@@ -426,7 +444,7 @@ def is_number_str(
|
|
426
444
|
|
427
445
|
def get_first_notnull(
|
428
446
|
*values: Any,
|
429
|
-
default:
|
447
|
+
default: Any | Literal['exception'] | None = None,
|
430
448
|
nulls: tuple = (None,)) -> Any:
|
431
449
|
"""
|
432
450
|
Get the first value that is not null.
|
@@ -464,12 +482,12 @@ def get_first_notnull(
|
|
464
482
|
|
465
483
|
|
466
484
|
@overload
|
467
|
-
def get_name(obj: tuple, frame: int = 2) ->
|
485
|
+
def get_name(obj: tuple, frame: int = 2) -> tuple[str, ...] | None: ...
|
468
486
|
|
469
487
|
@overload
|
470
|
-
def get_name(obj: Any, frame: int = 2) ->
|
488
|
+
def get_name(obj: Any, frame: int = 2) -> str | None: ...
|
471
489
|
|
472
|
-
def get_name(obj: Any, frame: int = 2) ->
|
490
|
+
def get_name(obj: Any, frame: int = 2) -> str | tuple[str, ...] | None:
|
473
491
|
"""
|
474
492
|
Get name of object or variable.
|
475
493
|
|
@@ -570,7 +588,7 @@ def get_stack_param(format_: Literal['floor'] = 'floor', limit: int = 2) -> dict
|
|
570
588
|
@overload
|
571
589
|
def get_stack_param(format_: Literal['full'] = 'floor', limit: int = 2) -> list[dict]: ...
|
572
590
|
|
573
|
-
def get_stack_param(format_: Literal['floor', 'full'] = 'floor', limit: int = 2) ->
|
591
|
+
def get_stack_param(format_: Literal['floor', 'full'] = 'floor', limit: int = 2) -> dict | list[dict]:
|
574
592
|
"""
|
575
593
|
Get code stack parameters.
|
576
594
|
|
@@ -626,7 +644,7 @@ def get_stack_param(format_: Literal['floor', 'full'] = 'floor', limit: int = 2)
|
|
626
644
|
def get_arg_info(func: Callable) -> list[
|
627
645
|
dict[
|
628
646
|
Literal['name', 'type', 'annotation', 'default'],
|
629
|
-
|
647
|
+
str | None
|
630
648
|
]
|
631
649
|
]:
|
632
650
|
"""
|
@@ -872,9 +890,9 @@ def get_process_table() -> list[ProcessInfo]:
|
|
872
890
|
|
873
891
|
|
874
892
|
def search_process(
|
875
|
-
id_:
|
876
|
-
name:
|
877
|
-
port:
|
893
|
+
id_: int | Sequence[int] | None = None,
|
894
|
+
name: str | Sequence[str] | None = None,
|
895
|
+
port: str | int | Sequence[str | int] | None = None,
|
878
896
|
) -> list[Process]:
|
879
897
|
"""
|
880
898
|
Search process by ID or name or port.
|
@@ -958,9 +976,9 @@ def search_process(
|
|
958
976
|
|
959
977
|
|
960
978
|
def kill_process(
|
961
|
-
id_:
|
962
|
-
name:
|
963
|
-
port:
|
979
|
+
id_: int | Sequence[int] | None = None,
|
980
|
+
name: str | Sequence[str] | None = None,
|
981
|
+
port: str | int | Sequence[str | int] | None = None,
|
964
982
|
) -> list[Process]:
|
965
983
|
"""
|
966
984
|
Search and kill process by ID or name or port.
|
@@ -996,9 +1014,9 @@ def kill_process(
|
|
996
1014
|
|
997
1015
|
|
998
1016
|
def stop_process(
|
999
|
-
id_:
|
1000
|
-
name:
|
1001
|
-
port:
|
1017
|
+
id_: int | Sequence[int] | None = None,
|
1018
|
+
name: str | Sequence[str] | None = None,
|
1019
|
+
port: str | int | Sequence[str | int] | None = None,
|
1002
1020
|
) -> list[Process]:
|
1003
1021
|
"""
|
1004
1022
|
Search and stop process by ID or name or port.
|
@@ -1034,9 +1052,9 @@ def stop_process(
|
|
1034
1052
|
|
1035
1053
|
|
1036
1054
|
def start_process(
|
1037
|
-
id_:
|
1038
|
-
name:
|
1039
|
-
port:
|
1055
|
+
id_: int | Sequence[int] | None = None,
|
1056
|
+
name: str | Sequence[str] | None = None,
|
1057
|
+
port: str | int | Sequence[str | int] | None = None,
|
1040
1058
|
) -> list[Process]:
|
1041
1059
|
"""
|
1042
1060
|
Search and start process by ID or name or port.
|
@@ -1092,7 +1110,7 @@ def get_idle_port(min: int = 49152) -> int:
|
|
1092
1110
|
|
1093
1111
|
|
1094
1112
|
def memory_read(
|
1095
|
-
process:
|
1113
|
+
process: int | str,
|
1096
1114
|
dll: str,
|
1097
1115
|
offset: int
|
1098
1116
|
) -> int:
|
@@ -1131,7 +1149,7 @@ def memory_read(
|
|
1131
1149
|
|
1132
1150
|
|
1133
1151
|
def memory_write(
|
1134
|
-
process:
|
1152
|
+
process: int | str,
|
1135
1153
|
dll: str,
|
1136
1154
|
offset: int,
|
1137
1155
|
value: int
|
@@ -1178,3 +1196,179 @@ def open_browser(url: str) -> bool:
|
|
1178
1196
|
succeeded = webbrowser_open(url)
|
1179
1197
|
|
1180
1198
|
return succeeded
|
1199
|
+
|
1200
|
+
|
1201
|
+
def popup_message(
|
1202
|
+
style: Literal['info', 'warn', 'error'] = 'info',
|
1203
|
+
message: str | None = None,
|
1204
|
+
title: str | None = None
|
1205
|
+
) -> None:
|
1206
|
+
"""
|
1207
|
+
Pop up system message box.
|
1208
|
+
|
1209
|
+
Parameters
|
1210
|
+
----------
|
1211
|
+
style : Message box style.
|
1212
|
+
- `Literal['info']`: Information box.
|
1213
|
+
- `Literal['warn']`: Warning box.
|
1214
|
+
- `Literal['error']`: Error box.
|
1215
|
+
message : Message box content.
|
1216
|
+
title : Message box title.
|
1217
|
+
"""
|
1218
|
+
|
1219
|
+
# Pop up.
|
1220
|
+
match style:
|
1221
|
+
|
1222
|
+
## Information.
|
1223
|
+
case 'info':
|
1224
|
+
method = tkinter_showinfo
|
1225
|
+
|
1226
|
+
## Warning.
|
1227
|
+
case 'warn':
|
1228
|
+
method = tkinter_showwarning
|
1229
|
+
|
1230
|
+
## Error.
|
1231
|
+
case 'error':
|
1232
|
+
method = tkinter_showerror
|
1233
|
+
|
1234
|
+
method(title, message)
|
1235
|
+
|
1236
|
+
|
1237
|
+
@overload
|
1238
|
+
def popup_ask(
|
1239
|
+
style: Literal['yes_no_cancel'] = 'yes_no',
|
1240
|
+
message: str | None = None,
|
1241
|
+
title: str | None = None
|
1242
|
+
) -> bool | None: ...
|
1243
|
+
|
1244
|
+
@overload
|
1245
|
+
def popup_ask(
|
1246
|
+
style: Literal['yes_no', 'ok_cancel', 'retry_cancel'] = 'yes_no',
|
1247
|
+
message: str | None = None,
|
1248
|
+
title: str | None = None
|
1249
|
+
) -> bool: ...
|
1250
|
+
|
1251
|
+
def popup_ask(
|
1252
|
+
style: Literal['yes_no', 'ok_cancel', 'retry_cancel', 'yes_no_cancel'] = 'yes_no',
|
1253
|
+
message: str | None = None,
|
1254
|
+
title: str | None = None
|
1255
|
+
) -> bool | None:
|
1256
|
+
"""
|
1257
|
+
Pop up system ask box.
|
1258
|
+
|
1259
|
+
Parameters
|
1260
|
+
----------
|
1261
|
+
style : Ask box style.
|
1262
|
+
- `Literal['yes_no']`: Buttons are `yes` and `no`.
|
1263
|
+
- `Literal['ok_cancel']`: Buttons are `ok` and `cancel`.
|
1264
|
+
- `Literal['retry_cancel']`: Buttons are `retry` and `cancel`.
|
1265
|
+
- `Literal['yes_no_cancel']`: Buttons are `yes` and `no` and `cancel`.
|
1266
|
+
message : Ask box content.
|
1267
|
+
title : Ask box title.
|
1268
|
+
"""
|
1269
|
+
|
1270
|
+
# Pop up.
|
1271
|
+
match style:
|
1272
|
+
|
1273
|
+
## Yes and no.
|
1274
|
+
case 'yes_no':
|
1275
|
+
method = tkinter_askyesno
|
1276
|
+
|
1277
|
+
## Ok and cancel.
|
1278
|
+
case 'ok_cancel':
|
1279
|
+
method = tkinter_askokcancel
|
1280
|
+
|
1281
|
+
## Retry and cancel.
|
1282
|
+
case 'retry_cancel':
|
1283
|
+
method = tkinter_askretrycancel
|
1284
|
+
|
1285
|
+
## Yes and no and cancel.
|
1286
|
+
case 'yes_no_cancel':
|
1287
|
+
method = tkinter_askyesnocancel
|
1288
|
+
|
1289
|
+
method(title, message)
|
1290
|
+
|
1291
|
+
|
1292
|
+
@overload
|
1293
|
+
def popup_select(
|
1294
|
+
style: Literal['file', 'save'] = 'file',
|
1295
|
+
title : str | None = None,
|
1296
|
+
init_folder : str | None = None,
|
1297
|
+
init_file : str | None = None,
|
1298
|
+
filter_file : list[tuple[str, str | list[str]]] | None = None
|
1299
|
+
) -> str: ...
|
1300
|
+
|
1301
|
+
@overload
|
1302
|
+
def popup_select(
|
1303
|
+
style: Literal['files'] = 'file',
|
1304
|
+
title : str | None = None,
|
1305
|
+
init_folder : str | None = None,
|
1306
|
+
init_file : str | None = None,
|
1307
|
+
filter_file : list[tuple[str, str | list[str]]] | None = None
|
1308
|
+
) -> tuple[str, ...]: ...
|
1309
|
+
|
1310
|
+
@overload
|
1311
|
+
def popup_select(
|
1312
|
+
style: Literal['folder'] = 'file',
|
1313
|
+
title : str | None = None,
|
1314
|
+
init_folder : str | None = None
|
1315
|
+
) -> str: ...
|
1316
|
+
|
1317
|
+
def popup_select(
|
1318
|
+
style: Literal['file', 'files', 'folder', 'save'] = 'file',
|
1319
|
+
title : str | None = None,
|
1320
|
+
init_folder : str | None = None,
|
1321
|
+
init_file : str | None = None,
|
1322
|
+
filter_file : list[tuple[str, str | list[str]]] | None = None
|
1323
|
+
) -> str | tuple[str, ...]:
|
1324
|
+
"""
|
1325
|
+
Pop up system select box.
|
1326
|
+
|
1327
|
+
Parameters
|
1328
|
+
----------
|
1329
|
+
style : Select box style.
|
1330
|
+
- `Literal['file']`: Select file box.
|
1331
|
+
- `Literal['files']`: Select multiple files box.
|
1332
|
+
- `Literal['folder']`: Select folder box.
|
1333
|
+
- `Literal['save']`: Select save file box.
|
1334
|
+
title : Select box title.
|
1335
|
+
init_folder : Initial folder path.
|
1336
|
+
init_file : Initial file name.
|
1337
|
+
filter_file : Filter file.
|
1338
|
+
- `tuple[str, str]`: Filter name and filter pattern.
|
1339
|
+
- `tuple[str, list[str]]`: Filter name and multiple filter patterns (or).
|
1340
|
+
"""
|
1341
|
+
|
1342
|
+
# Pop up.
|
1343
|
+
kwargs = {
|
1344
|
+
'filetypes': filter_file,
|
1345
|
+
'initialdir': init_folder,
|
1346
|
+
'initialfile': init_file,
|
1347
|
+
'title': title
|
1348
|
+
}
|
1349
|
+
kwargs = {
|
1350
|
+
key: value
|
1351
|
+
for key, value in kwargs.items()
|
1352
|
+
if value is not None
|
1353
|
+
}
|
1354
|
+
match style:
|
1355
|
+
|
1356
|
+
## File.
|
1357
|
+
case 'file':
|
1358
|
+
method = tkinter_askopenfilename
|
1359
|
+
|
1360
|
+
## Files.
|
1361
|
+
case 'files':
|
1362
|
+
method = tkinter_askopenfilenames
|
1363
|
+
|
1364
|
+
## Folder.
|
1365
|
+
case 'folder':
|
1366
|
+
method = tkinter_askdirectory
|
1367
|
+
|
1368
|
+
## Save.
|
1369
|
+
case 'save':
|
1370
|
+
method = tkinter_asksaveasfilename
|
1371
|
+
|
1372
|
+
path = method(**kwargs)
|
1373
|
+
|
1374
|
+
return path
|
reykit/rtable.py
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
"""
|
10
10
|
|
11
11
|
|
12
|
-
from typing import Any, TypedDict,
|
12
|
+
from typing import Any, TypedDict, overload
|
13
13
|
from collections.abc import Iterable
|
14
14
|
from os.path import abspath as os_abspath
|
15
15
|
from pandas import DataFrame, ExcelWriter, isnull
|
@@ -34,13 +34,13 @@ __all__ = (
|
|
34
34
|
)
|
35
35
|
|
36
36
|
|
37
|
-
type Table =
|
38
|
-
SheetSet = TypedDict('SheetsSet', {'name': str, 'index': int, 'fields':
|
37
|
+
type Table = list[dict] | dict | CursorResult | DataFrame
|
38
|
+
SheetSet = TypedDict('SheetsSet', {'name': str, 'index': int, 'fields': str | list[str]})
|
39
39
|
|
40
40
|
|
41
41
|
def to_table(
|
42
|
-
data:
|
43
|
-
fields:
|
42
|
+
data: Table | Iterable[Iterable],
|
43
|
+
fields: Iterable | None = None
|
44
44
|
) -> list[dict]:
|
45
45
|
"""
|
46
46
|
Convert data to table in `list[dict]` format, keys and keys sort of the dictionary are the same.
|
@@ -95,23 +95,23 @@ def to_table(
|
|
95
95
|
|
96
96
|
@overload
|
97
97
|
def to_dict(
|
98
|
-
data:
|
99
|
-
key_field:
|
98
|
+
data: Table | Iterable[Iterable],
|
99
|
+
key_field: int | str = 0,
|
100
100
|
val_field: None = None
|
101
101
|
) -> dict[Any, dict]: ...
|
102
102
|
|
103
103
|
@overload
|
104
104
|
def to_dict(
|
105
|
-
data:
|
106
|
-
key_field:
|
107
|
-
val_field:
|
105
|
+
data: Table | Iterable[Iterable],
|
106
|
+
key_field: int | str = 0,
|
107
|
+
val_field: int | str = None
|
108
108
|
) -> dict: ...
|
109
109
|
|
110
110
|
def to_dict(
|
111
|
-
data:
|
112
|
-
key_field:
|
113
|
-
val_field:
|
114
|
-
) ->
|
111
|
+
data: Table | Iterable[Iterable],
|
112
|
+
key_field: int | str = 0,
|
113
|
+
val_field: int | str | None = None
|
114
|
+
) -> dict[Any, dict] | dict:
|
115
115
|
"""
|
116
116
|
Convert data as dictionary.
|
117
117
|
|
@@ -169,8 +169,8 @@ def to_dict(
|
|
169
169
|
|
170
170
|
|
171
171
|
def to_list(
|
172
|
-
data:
|
173
|
-
field:
|
172
|
+
data: Table | Iterable[Iterable],
|
173
|
+
field: int | str = 0,
|
174
174
|
) -> list:
|
175
175
|
"""
|
176
176
|
Convert data as list.
|
@@ -209,8 +209,8 @@ def to_list(
|
|
209
209
|
|
210
210
|
|
211
211
|
def to_df(
|
212
|
-
data:
|
213
|
-
fields:
|
212
|
+
data: Table | Iterable[Iterable],
|
213
|
+
fields: Iterable | None = None
|
214
214
|
) -> DataFrame:
|
215
215
|
"""
|
216
216
|
Convert data to table of `DataFrame` object.
|
@@ -253,8 +253,8 @@ def to_df(
|
|
253
253
|
|
254
254
|
|
255
255
|
def to_json(
|
256
|
-
data:
|
257
|
-
fields:
|
256
|
+
data: Table | Iterable[Iterable],
|
257
|
+
fields: Iterable | None = None,
|
258
258
|
compact: bool = True
|
259
259
|
) -> str:
|
260
260
|
"""
|
@@ -283,8 +283,8 @@ def to_json(
|
|
283
283
|
|
284
284
|
|
285
285
|
def to_text(
|
286
|
-
data:
|
287
|
-
fields:
|
286
|
+
data: Table | Iterable[Iterable],
|
287
|
+
fields: Iterable | None = None,
|
288
288
|
width: int = 100
|
289
289
|
) -> str:
|
290
290
|
"""
|
@@ -313,8 +313,8 @@ def to_text(
|
|
313
313
|
|
314
314
|
|
315
315
|
def to_sql(
|
316
|
-
data:
|
317
|
-
fields:
|
316
|
+
data: Table | Iterable[Iterable],
|
317
|
+
fields: Iterable | None = None
|
318
318
|
) -> str:
|
319
319
|
"""
|
320
320
|
Convert data to SQL string.
|
@@ -365,8 +365,8 @@ def to_sql(
|
|
365
365
|
|
366
366
|
|
367
367
|
def to_html(
|
368
|
-
data:
|
369
|
-
fields:
|
368
|
+
data: Table | Iterable[Iterable],
|
369
|
+
fields: Iterable | None = None
|
370
370
|
) -> str:
|
371
371
|
"""
|
372
372
|
Convert data to HTML string.
|
@@ -393,9 +393,9 @@ def to_html(
|
|
393
393
|
|
394
394
|
|
395
395
|
def to_csv(
|
396
|
-
data:
|
396
|
+
data: Table | Iterable[Iterable],
|
397
397
|
path: str = 'data.csv',
|
398
|
-
fields:
|
398
|
+
fields: Iterable | None = None
|
399
399
|
) -> str:
|
400
400
|
"""
|
401
401
|
Convert data to save CSV format file.
|
@@ -429,10 +429,10 @@ def to_csv(
|
|
429
429
|
|
430
430
|
|
431
431
|
def to_excel(
|
432
|
-
data:
|
432
|
+
data: Table | Iterable[Iterable],
|
433
433
|
path: str = 'data.xlsx',
|
434
|
-
group_field:
|
435
|
-
sheets_set: dict[
|
434
|
+
group_field: str | None = None,
|
435
|
+
sheets_set: dict[str | int, SheetSet] = {}
|
436
436
|
) -> str:
|
437
437
|
"""
|
438
438
|
Convert data to save Excel format file and return sheet name and sheet data.
|
reykit/rtext.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 Iterable
|
14
14
|
from decimal import Decimal
|
15
15
|
from pprint import pformat as pprint_pformat
|
@@ -278,7 +278,7 @@ def join_filter_text(data: Iterable, char: str = ',', filter_: tuple = (None, ''
|
|
278
278
|
|
279
279
|
def add_text_frame(
|
280
280
|
*texts: str,
|
281
|
-
title:
|
281
|
+
title: str | None,
|
282
282
|
width: int,
|
283
283
|
frame: Literal['full', 'half', 'top', 'half_plain', 'top_plain']
|
284
284
|
) -> str:
|
@@ -289,7 +289,7 @@ def add_text_frame(
|
|
289
289
|
----------
|
290
290
|
texts : Texts.
|
291
291
|
title : Frame title.
|
292
|
-
- `
|
292
|
+
- `None | Literal['']`: No title.
|
293
293
|
- `str`: Use this value as the title.
|
294
294
|
width : Frame width.
|
295
295
|
frame : Frame type.
|
reykit/rtime.py
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
"""
|
10
10
|
|
11
11
|
|
12
|
-
from typing import Any, TypedDict, Literal,
|
12
|
+
from typing import Any, TypedDict, Literal, overload, NoReturn
|
13
13
|
from collections.abc import Callable
|
14
14
|
from pandas import (
|
15
15
|
DataFrame,
|
@@ -47,7 +47,7 @@ __all__ = (
|
|
47
47
|
)
|
48
48
|
|
49
49
|
|
50
|
-
RecordData = TypedDict('RecordData', {'timestamp': int, 'datetime': datetime_datetime, 'timedelta':
|
50
|
+
RecordData = TypedDict('RecordData', {'timestamp': int, 'datetime': datetime_datetime, 'timedelta': datetime_timedelta | None, 'note': str | None})
|
51
51
|
|
52
52
|
|
53
53
|
@overload
|
@@ -78,13 +78,7 @@ def now(
|
|
78
78
|
'time_str',
|
79
79
|
'timestamp'
|
80
80
|
] = 'datetime'
|
81
|
-
) ->
|
82
|
-
datetime_datetime,
|
83
|
-
datetime_date,
|
84
|
-
datetime_time,
|
85
|
-
str,
|
86
|
-
int
|
87
|
-
]:
|
81
|
+
) -> datetime_datetime | datetime_date | datetime_time | str | int:
|
88
82
|
"""
|
89
83
|
Get the now time.
|
90
84
|
|
@@ -126,15 +120,7 @@ def now(
|
|
126
120
|
|
127
121
|
@overload
|
128
122
|
def time_to(
|
129
|
-
obj:
|
130
|
-
datetime_datetime,
|
131
|
-
datetime_date,
|
132
|
-
datetime_time,
|
133
|
-
datetime_timedelta,
|
134
|
-
time_struct_time,
|
135
|
-
pd_timestamp,
|
136
|
-
pd_timedelta
|
137
|
-
],
|
123
|
+
obj: datetime_datetime | datetime_date | datetime_time | datetime_timedelta | time_struct_time | pd_timestamp | pd_timedelta,
|
138
124
|
decimal: bool = False,
|
139
125
|
raising: bool = True
|
140
126
|
) -> str: ...
|
@@ -241,13 +227,7 @@ def time_to(
|
|
241
227
|
|
242
228
|
def text_to_time(
|
243
229
|
string: str
|
244
|
-
) ->
|
245
|
-
Union[
|
246
|
-
datetime_datetime,
|
247
|
-
datetime_date,
|
248
|
-
datetime_time
|
249
|
-
]
|
250
|
-
]:
|
230
|
+
) -> datetime_datetime | datetime_date | datetime_time | None:
|
251
231
|
"""
|
252
232
|
Convert text to time object.
|
253
233
|
|
@@ -332,11 +312,11 @@ def text_to_time(
|
|
332
312
|
def to_time(
|
333
313
|
obj: str,
|
334
314
|
raising: bool = True
|
335
|
-
) ->
|
315
|
+
) -> datetime_datetime | datetime_date | datetime_time: ...
|
336
316
|
|
337
317
|
@overload
|
338
318
|
def to_time(
|
339
|
-
obj:
|
319
|
+
obj: time_struct_time | float,
|
340
320
|
raising: bool = True
|
341
321
|
) -> datetime_datetime: ...
|
342
322
|
|
@@ -413,7 +393,7 @@ def to_time(
|
|
413
393
|
|
414
394
|
def sleep(
|
415
395
|
*thresholds: float,
|
416
|
-
precision:
|
396
|
+
precision: int | None = None
|
417
397
|
) -> float:
|
418
398
|
"""
|
419
399
|
Sleep random seconds.
|
@@ -452,7 +432,7 @@ def wait(
|
|
452
432
|
func: Callable[..., bool],
|
453
433
|
*args: Any,
|
454
434
|
_interval: float = 1,
|
455
|
-
_timeout:
|
435
|
+
_timeout: float | None = None,
|
456
436
|
**kwargs: Any
|
457
437
|
) -> float:
|
458
438
|
"""
|
@@ -522,7 +502,7 @@ class RTimeMark():
|
|
522
502
|
self.record: dict[int, RecordData] = {}
|
523
503
|
|
524
504
|
|
525
|
-
def mark(self, note:
|
505
|
+
def mark(self, note: str | None = None) -> int:
|
526
506
|
"""
|
527
507
|
Marking now time.
|
528
508
|
|
@@ -560,7 +540,7 @@ class RTimeMark():
|
|
560
540
|
return index
|
561
541
|
|
562
542
|
|
563
|
-
def report(self, title:
|
543
|
+
def report(self, title: str | None = None) -> DataFrame:
|
564
544
|
"""
|
565
545
|
Print and return time mark information table.
|
566
546
|
|
reykit/rtype.py
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
"""
|
10
10
|
|
11
11
|
|
12
|
-
from typing import Any,
|
12
|
+
from typing import Any, Self
|
13
13
|
from collections.abc import Callable
|
14
14
|
|
15
15
|
|
@@ -86,7 +86,7 @@ class RSingleton(object):
|
|
86
86
|
When instantiated, method `__singleton__` will be called only once, and will accept arguments.
|
87
87
|
"""
|
88
88
|
|
89
|
-
_instance:
|
89
|
+
_instance: Self | None = None
|
90
90
|
|
91
91
|
|
92
92
|
def __new__(self, *arg: Any, **kwargs: Any) -> Self:
|