reykit 1.1.2__py3-none-any.whl → 1.1.6__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 CHANGED
@@ -9,11 +9,12 @@
9
9
  """
10
10
 
11
11
 
12
- from typing import Any, TypedDict, Literal, NoReturn, TypeVar, overload
12
+ from typing import Any, TypedDict, Literal, overload
13
13
  from collections.abc import Callable, Iterable, Generator
14
14
 
15
15
  from .rexception import check_least_one, check_most_one
16
16
  from .rsystem import is_iterable
17
+ from .rtype import AnyValue
17
18
 
18
19
 
19
20
  __all__ = (
@@ -28,7 +29,6 @@ __all__ = (
28
29
 
29
30
 
30
31
  CountResult = TypedDict('CountResult', {'value': Any, 'count': int})
31
- Element = TypeVar('Element')
32
32
 
33
33
 
34
34
  def count(
@@ -130,15 +130,12 @@ def flatten(data: Any, *, _flattern_data: list | None = None) -> list:
130
130
 
131
131
 
132
132
  @overload
133
- def split(data: Iterable[Element], share: None = None, bin_size: None = None) -> NoReturn: ...
133
+ def split(data: Iterable[AnyValue], share: int = None, bin_size: None = None) -> list[list[AnyValue]]: ...
134
134
 
135
135
  @overload
136
- def split(data: Iterable[Element], share: int = None, bin_size: int = None) -> NoReturn: ...
136
+ def split(data: Iterable[AnyValue], share: None = None, bin_size: int = None) -> list[list[AnyValue]]: ...
137
137
 
138
- @overload
139
- def split(data: Iterable[Element], share: int | None = None, bin_size: int | None = None) -> list[list[Element]]: ...
140
-
141
- def split(data: Iterable[Element], share: int | None = None, bin_size: int | None = None) -> list[list[Element]]:
138
+ def split(data: Iterable[AnyValue], share: int | None = None, bin_size: int | None = None) -> list[list[AnyValue]]:
142
139
  """
143
140
  Split data into multiple data.
144
141
 
@@ -186,7 +183,7 @@ def split(data: Iterable[Element], share: int | None = None, bin_size: int | Non
186
183
  return _data
187
184
 
188
185
 
189
- def unique(data: Iterable[Element]) -> list[Element]:
186
+ def unique(data: Iterable[AnyValue]) -> list[AnyValue]:
190
187
  """
191
188
  De duplication of data.
192
189
 
reykit/rlog.py CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
 
12
12
  from __future__ import annotations
13
- from typing import Any, Literal, Final, NoReturn, overload, override
13
+ from typing import Any, Literal, Final, 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
@@ -462,28 +462,6 @@ class RLog(object):
462
462
  filter_: Callable[[LogRecord], bool] | None = None
463
463
  ) -> ConcurrentTimedRotatingFileHandler: ...
464
464
 
465
- @overload
466
- def add_file(
467
- self,
468
- path: str | None = None,
469
- mb: None = None,
470
- time: Any = None,
471
- level: int = DEBUG,
472
- format_: str | None = None,
473
- filter_: Callable[[LogRecord], bool] | None = None
474
- ) -> NoReturn: ...
475
-
476
- @overload
477
- def add_file(
478
- self,
479
- path: str | None = None,
480
- mb: float = None,
481
- time: float | Literal['m', 'w0', 'w1', 'w2', 'w3', 'w4', 'w5', 'w6'] = None,
482
- level: int = DEBUG,
483
- format_: str | None = None,
484
- filter_: Callable[[LogRecord], bool] | None = None
485
- ) -> NoReturn: ...
486
-
487
465
  def add_file(
488
466
  self,
489
467
  path: str | None = None,
reykit/ros.py CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
 
12
12
  from __future__ import annotations
13
- from typing import Any, Literal, NoReturn, overload
13
+ from typing import Any, Literal, overload
14
14
  from io import TextIOBase, BufferedIOBase
15
15
  from os import (
16
16
  walk as os_walk,
@@ -219,12 +219,6 @@ def get_file_str(file: FileStr) -> str:
219
219
  return file_str
220
220
 
221
221
 
222
- @overload
223
- def get_file_bytes(file: FileBytes) -> bytes: ...
224
-
225
- @overload
226
- def get_file_bytes(file: Any) -> NoReturn: ...
227
-
228
222
  def get_file_bytes(file: FileBytes) -> bytes:
229
223
  """
230
224
  Get file bytes data.
reykit/rsystem.py CHANGED
@@ -208,7 +208,13 @@ def del_modules(path: str) -> list[str]:
208
208
  return deleted_dict
209
209
 
210
210
 
211
- def dos_command(command: str | Iterable[str]) -> str:
211
+ @overload
212
+ def dos_command(command: str | Iterable[str], read: False = False) -> None: ...
213
+
214
+ @overload
215
+ def dos_command(command: str | Iterable[str], read: True = False) -> str: ...
216
+
217
+ def dos_command(command: str | Iterable[str], read: bool = False) -> str | None:
212
218
  """
213
219
  Execute DOS command.
214
220
 
@@ -218,26 +224,24 @@ def dos_command(command: str | Iterable[str]) -> str:
218
224
  - `str`: Use this command.
219
225
  - `Iterable[str]`: Join strings with space as command.
220
226
  When space in the string, automatic add quotation mark (e.g., ['echo', 'a b'] -> 'echo 'a b'').
227
+ read : Whether read command output, will block.
221
228
 
222
229
  Returns
223
230
  -------
224
- Command standard output.
231
+ Command standard output or None.
225
232
  """
226
233
 
227
234
  # Execute.
228
- popen = Popen(command, shell=True, stdout=PIPE, stderr=PIPE)
229
-
230
- # Check.
231
- error_bytes: bytes = popen.stderr.read()
232
- if error_bytes != b'':
233
- error = error_bytes.decode('GBK')
234
- throw(value=error)
235
+ popen = Popen(command, stdout=PIPE, stderr=PIPE, shell=True)
235
236
 
236
- # Standard output.
237
- output_bytes: bytes = popen.stdout.read()
238
- output = output_bytes.decode('GBK')
237
+ # Output.
238
+ if read:
239
+ stderr_bytes: bytes = popen.stderr.read()
240
+ stdout_bytes: bytes = popen.stdout.read()
241
+ output_bytes = stdout_bytes + stderr_bytes
242
+ output = output_bytes.decode('GBK')
239
243
 
240
- return output
244
+ return output
241
245
 
242
246
 
243
247
  def dos_command_var(*vars: Any) -> list[Any]:
@@ -1265,6 +1269,10 @@ def popup_ask(
1265
1269
  - `Literal['yes_no_cancel']`: Buttons are `yes` and `no` and `cancel`.
1266
1270
  message : Ask box content.
1267
1271
  title : Ask box title.
1272
+
1273
+ Returns
1274
+ -------
1275
+ Ask result.
1268
1276
  """
1269
1277
 
1270
1278
  # Pop up.
@@ -1296,7 +1304,7 @@ def popup_select(
1296
1304
  init_folder : str | None = None,
1297
1305
  init_file : str | None = None,
1298
1306
  filter_file : list[tuple[str, str | list[str]]] | None = None
1299
- ) -> str: ...
1307
+ ) -> str | None: ...
1300
1308
 
1301
1309
  @overload
1302
1310
  def popup_select(
@@ -1305,14 +1313,14 @@ def popup_select(
1305
1313
  init_folder : str | None = None,
1306
1314
  init_file : str | None = None,
1307
1315
  filter_file : list[tuple[str, str | list[str]]] | None = None
1308
- ) -> tuple[str, ...]: ...
1316
+ ) -> tuple[str, ...] | None: ...
1309
1317
 
1310
1318
  @overload
1311
1319
  def popup_select(
1312
1320
  style: Literal['folder'] = 'file',
1313
1321
  title : str | None = None,
1314
1322
  init_folder : str | None = None
1315
- ) -> str: ...
1323
+ ) -> str | None: ...
1316
1324
 
1317
1325
  def popup_select(
1318
1326
  style: Literal['file', 'files', 'folder', 'save'] = 'file',
@@ -1320,7 +1328,7 @@ def popup_select(
1320
1328
  init_folder : str | None = None,
1321
1329
  init_file : str | None = None,
1322
1330
  filter_file : list[tuple[str, str | list[str]]] | None = None
1323
- ) -> str | tuple[str, ...]:
1331
+ ) -> str | tuple[str, ...] | None:
1324
1332
  """
1325
1333
  Pop up system select box.
1326
1334
 
@@ -1337,6 +1345,11 @@ def popup_select(
1337
1345
  filter_file : Filter file.
1338
1346
  - `tuple[str, str]`: Filter name and filter pattern.
1339
1347
  - `tuple[str, list[str]]`: Filter name and multiple filter patterns (or).
1348
+
1349
+ Returns
1350
+ -------
1351
+ File or folder path.
1352
+ - `None`: Close select box.
1340
1353
  """
1341
1354
 
1342
1355
  # Pop up.
@@ -1370,5 +1383,6 @@ def popup_select(
1370
1383
  method = tkinter_asksaveasfilename
1371
1384
 
1372
1385
  path = method(**kwargs)
1386
+ path = path or None
1373
1387
 
1374
1388
  return path
reykit/rtime.py CHANGED
@@ -34,6 +34,7 @@ from .rnumber import digits
34
34
  from .rrandom import randn
35
35
  from .rregex import search
36
36
  from .rstdout import echo
37
+ from .rtype import AnyValue
37
38
 
38
39
 
39
40
  __all__ = (
@@ -65,9 +66,6 @@ def now(format_: Literal['datetime_str', 'date_str', 'time_str'] = 'datetime') -
65
66
  @overload
66
67
  def now(format_: Literal['timestamp'] = 'datetime') -> int: ...
67
68
 
68
- @overload
69
- def now(format_: Any) -> NoReturn: ...
70
-
71
69
  def now(
72
70
  format_: Literal[
73
71
  'datetime',
@@ -134,10 +132,10 @@ def time_to(
134
132
 
135
133
  @overload
136
134
  def time_to(
137
- obj: Any,
135
+ obj: AnyValue,
138
136
  decimal: bool = False,
139
137
  raising: Literal[False] = True
140
- ) -> Any: ...
138
+ ) -> AnyValue: ...
141
139
 
142
140
  def time_to(
143
141
  obj: Any,
@@ -328,9 +326,9 @@ def to_time(
328
326
 
329
327
  @overload
330
328
  def to_time(
331
- obj: Any,
329
+ obj: AnyValue,
332
330
  raising: Literal[False] = True
333
- ) -> Any: ...
331
+ ) -> AnyValue: ...
334
332
 
335
333
  def to_time(
336
334
  obj: Any,
@@ -433,10 +431,11 @@ def wait(
433
431
  *args: Any,
434
432
  _interval: float = 1,
435
433
  _timeout: float | None = None,
434
+ _raising: bool = True,
436
435
  **kwargs: Any
437
- ) -> float:
436
+ ) -> float | None:
438
437
  """
439
- Wait success, timeout throw exception.
438
+ Wait success.
440
439
 
441
440
  Parameters
442
441
  ----------
@@ -446,11 +445,12 @@ def wait(
446
445
  _timeout : Timeout seconds, timeout throw exception.
447
446
  - `None`: Infinite time.
448
447
  - `float`: Use this time.
448
+ _raising : When timeout, whether throw exception, otherwise return None.
449
449
  kwargs : Keyword arguments of decorated function.
450
450
 
451
451
  Returns
452
452
  -------
453
- Total spend seconds.
453
+ Total spend seconds or None.
454
454
  """
455
455
 
456
456
  # Set parameter.
@@ -477,7 +477,12 @@ def wait(
477
477
  ## Timeout.
478
478
  rtm()
479
479
  if rtm.total_spend > _timeout:
480
- throw(TimeoutError, _timeout)
480
+
481
+ ### Throw exception.
482
+ if _raising:
483
+ throw(TimeoutError, _timeout)
484
+
485
+ return
481
486
 
482
487
  ## Sleep.
483
488
  sleep(_interval)
reykit/rtype.py CHANGED
@@ -9,11 +9,12 @@
9
9
  """
10
10
 
11
11
 
12
- from typing import Any, Self
12
+ from typing import Any, Self, TypeVar
13
13
  from collections.abc import Callable
14
14
 
15
15
 
16
16
  __all__ = (
17
+ 'AnyValue',
17
18
  'RStaticMeta',
18
19
  'RConfigMeta',
19
20
  'RNull',
@@ -21,6 +22,9 @@ __all__ = (
21
22
  )
22
23
 
23
24
 
25
+ AnyValue = TypeVar('AnyValue')
26
+
27
+
24
28
  class RStaticMeta(type):
25
29
  """
26
30
  Rey's `static meta` type.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reykit
3
- Version: 1.1.2
3
+ Version: 1.1.6
4
4
  Summary: Rey's kit method set.
5
5
  Project-URL: homepage, https://github.com/reyxbo/reykit/
6
6
  Author-email: Rey <reyxbo@163.com>
@@ -1,30 +1,30 @@
1
1
  reykit/__init__.py,sha256=QwnhdUDSXgjXJQ4ClaeP9oKXUXyQOPj5sApwGCDrILc,848
2
2
  reykit/rall.py,sha256=mOFwHXZ4-BOkJ5Ptbm6lQc2zwNf_VqcqM6AYYnYPfoo,672
3
3
  reykit/rcomm.py,sha256=LgSLrpUokOgdRMYwuZj6JNvxDyvENwsiOd6ZHo67HBg,11444
4
- reykit/rdata.py,sha256=d5zO9dQotDGoXxNh1TvEZdIfacaW55yeb79r0bbgj0k,8470
4
+ reykit/rdata.py,sha256=tlHpKB3px5KCxhA_rgu_nYOGjHkyJTLqqRlX9UypGR0,8348
5
5
  reykit/remail.py,sha256=rK_hbqGeZh04DnVPtjODLsm_YfdrZ5L-Z6SbjplrfUc,6736
6
6
  reykit/rexception.py,sha256=ftXVdEVkU0B0HXbKjQTiJRJVVGbvhorwWtMiplpN9Zk,8118
7
7
  reykit/rimage.py,sha256=fQpIHX6Go3Jk_MDgsSDnZx27EZHumyGdgI9xyjP5lYQ,6275
8
- reykit/rlog.py,sha256=4RqfYU7RZJJ3qUXHUTWFVgAM3nqjP4glDyRmvWNXpbk,26406
8
+ reykit/rlog.py,sha256=qhmATMv3_bJRaiuN9mo8hSf_95HH5Lw838aJFio98sg,25760
9
9
  reykit/rmonkey.py,sha256=RqhmKXabl11s2RJaGizpm00Q1yEkul1Je5uxw8_thUk,7584
10
10
  reykit/rmultitask.py,sha256=9UVAg8P85UsLS_exW-e6tZTa_b5r3ceL7LQRDrP8eAw,21981
11
11
  reykit/rnumber.py,sha256=XseLDNLDOt-XYP2P9oDbkKYuHudeSoWzIHsOENO8vvE,3196
12
- reykit/ros.py,sha256=flnczS5InFd9rVdXNi-amVETlIu1nwZPWSGySLMOPLw,39231
12
+ reykit/ros.py,sha256=UXX7FENgVCTR8m6-53CxzJvmPzHIzC7vLK2vyrkySiw,39096
13
13
  reykit/rrandom.py,sha256=fMeorpkjWAAtjD2oZCux3tpYuD2RRoBSkWI0M6NPM5Q,9102
14
14
  reykit/rregex.py,sha256=XTlnDLior8yyncFdrTr9FsVlBcqMXvsWRfpmvQS-BR8,6089
15
15
  reykit/rschedule.py,sha256=7EH_6TdEhwV-T6YyBEGYEcy85I1vTSNutDci-e_veTY,5796
16
16
  reykit/rstdout.py,sha256=vSvD4QjYybNiGnowWLXRU6q1u9ERPjr8YTXgq82eYDU,9648
17
- reykit/rsystem.py,sha256=LG0I4ZZjr-Bxfy6zbCqz3WvSG_bGYwtaBLowTHQ0mzY,34332
17
+ reykit/rsystem.py,sha256=XD5-kjJ0Dx1ONLknbAGt5VRCOYjBPc8qs0bTxt_Lxb0,34754
18
18
  reykit/rtable.py,sha256=gXszf_9DE_5SMdNcxMX-xd4IpHGQVjGsN3NQIm7wVGY,12055
19
19
  reykit/rtext.py,sha256=whaKpVkd36yYVtCmZ1ptp_TVRL1v3f7Jab0vPXC8wXY,11089
20
- reykit/rtime.py,sha256=bV1sB_FHcqNJAP9L7WmYMZul3HrQM2QU9a2Q1zN98Aw,16980
21
- reykit/rtype.py,sha256=HQFllZjKHPnGYLS-zTwC948Rt0HVsGY12eObjwFfOSo,1962
20
+ reykit/rtime.py,sha256=z468hEtU2gP6PRUFGgazf0EAVk6DhUy8LRvwLMjUZ_w,17172
21
+ reykit/rtype.py,sha256=Hg_LkyGpxLHbj5xwtJOwaqaS6WFwQZifXdC0n0mwhgY,2024
22
22
  reykit/rwrap.py,sha256=AJBYTDLHLGlMSiGIKoVkCsQk-Y4nDHWWFVCdnz5Bwdk,15222
23
23
  reykit/rzip.py,sha256=i6KkmeSWCnq025d-O1mbuCYezNRUhyY9OGVK0CRlNAM,3522
24
24
  reykit/rdll/__init__.py,sha256=vM9V7wSNno-WH9RrxgHTIgCkQm8LmBFoLFO8z7qovNo,306
25
25
  reykit/rdll/rdll_inject.py,sha256=bETl8tywtN1OiQudbA21u6GwBM_bqVX7jbiisNj_JBg,645
26
26
  reykit/rdll/rdll_inject_core.py,sha256=Trgh_pdJs_Lw-Y-0Kkn8kHr4BnilM9dBKnHnX25T_pM,5092
27
- reykit-1.1.2.dist-info/METADATA,sha256=2PvdTJEz7npFsQ53sEkQD4f8k7xHYLDAPZS81xxHQhM,1888
28
- reykit-1.1.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
29
- reykit-1.1.2.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
30
- reykit-1.1.2.dist-info/RECORD,,
27
+ reykit-1.1.6.dist-info/METADATA,sha256=lH3vUQkbSiXiD4YWYxCcg1Q7_91KBGSINZL4Q1lblBU,1888
28
+ reykit-1.1.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
29
+ reykit-1.1.6.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
30
+ reykit-1.1.6.dist-info/RECORD,,
File without changes