reykit 1.1.2__py3-none-any.whl → 1.1.4__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/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,22 @@ 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
235
  popen = Popen(command, shell=True, stdout=PIPE, stderr=PIPE)
229
236
 
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
-
236
- # Standard output.
237
- output_bytes: bytes = popen.stdout.read()
238
- output = output_bytes.decode('GBK')
237
+ # Output.
238
+ if read:
239
+ output_bytes: bytes = popen.stdout.read()
240
+ output = output_bytes.decode('GBK')
239
241
 
240
- return output
242
+ return output
241
243
 
242
244
 
243
245
  def dos_command_var(*vars: Any) -> list[Any]:
@@ -1265,6 +1267,10 @@ def popup_ask(
1265
1267
  - `Literal['yes_no_cancel']`: Buttons are `yes` and `no` and `cancel`.
1266
1268
  message : Ask box content.
1267
1269
  title : Ask box title.
1270
+
1271
+ Returns
1272
+ -------
1273
+ Ask result.
1268
1274
  """
1269
1275
 
1270
1276
  # Pop up.
@@ -1296,7 +1302,7 @@ def popup_select(
1296
1302
  init_folder : str | None = None,
1297
1303
  init_file : str | None = None,
1298
1304
  filter_file : list[tuple[str, str | list[str]]] | None = None
1299
- ) -> str: ...
1305
+ ) -> str | None: ...
1300
1306
 
1301
1307
  @overload
1302
1308
  def popup_select(
@@ -1305,14 +1311,14 @@ def popup_select(
1305
1311
  init_folder : str | None = None,
1306
1312
  init_file : str | None = None,
1307
1313
  filter_file : list[tuple[str, str | list[str]]] | None = None
1308
- ) -> tuple[str, ...]: ...
1314
+ ) -> tuple[str, ...] | None: ...
1309
1315
 
1310
1316
  @overload
1311
1317
  def popup_select(
1312
1318
  style: Literal['folder'] = 'file',
1313
1319
  title : str | None = None,
1314
1320
  init_folder : str | None = None
1315
- ) -> str: ...
1321
+ ) -> str | None: ...
1316
1322
 
1317
1323
  def popup_select(
1318
1324
  style: Literal['file', 'files', 'folder', 'save'] = 'file',
@@ -1320,7 +1326,7 @@ def popup_select(
1320
1326
  init_folder : str | None = None,
1321
1327
  init_file : str | None = None,
1322
1328
  filter_file : list[tuple[str, str | list[str]]] | None = None
1323
- ) -> str | tuple[str, ...]:
1329
+ ) -> str | tuple[str, ...] | None:
1324
1330
  """
1325
1331
  Pop up system select box.
1326
1332
 
@@ -1337,6 +1343,11 @@ def popup_select(
1337
1343
  filter_file : Filter file.
1338
1344
  - `tuple[str, str]`: Filter name and filter pattern.
1339
1345
  - `tuple[str, list[str]]`: Filter name and multiple filter patterns (or).
1346
+
1347
+ Returns
1348
+ -------
1349
+ File or folder path.
1350
+ - `None`: Close select box.
1340
1351
  """
1341
1352
 
1342
1353
  # Pop up.
@@ -1370,5 +1381,6 @@ def popup_select(
1370
1381
  method = tkinter_asksaveasfilename
1371
1382
 
1372
1383
  path = method(**kwargs)
1384
+ path = path or None
1373
1385
 
1374
1386
  return path
reykit/rtime.py CHANGED
@@ -433,10 +433,11 @@ def wait(
433
433
  *args: Any,
434
434
  _interval: float = 1,
435
435
  _timeout: float | None = None,
436
+ _raising: bool = True,
436
437
  **kwargs: Any
437
- ) -> float:
438
+ ) -> float | None:
438
439
  """
439
- Wait success, timeout throw exception.
440
+ Wait success.
440
441
 
441
442
  Parameters
442
443
  ----------
@@ -446,11 +447,12 @@ def wait(
446
447
  _timeout : Timeout seconds, timeout throw exception.
447
448
  - `None`: Infinite time.
448
449
  - `float`: Use this time.
450
+ _raising : When timeout, whether throw exception, otherwise return None.
449
451
  kwargs : Keyword arguments of decorated function.
450
452
 
451
453
  Returns
452
454
  -------
453
- Total spend seconds.
455
+ Total spend seconds or None.
454
456
  """
455
457
 
456
458
  # Set parameter.
@@ -477,7 +479,12 @@ def wait(
477
479
  ## Timeout.
478
480
  rtm()
479
481
  if rtm.total_spend > _timeout:
480
- throw(TimeoutError, _timeout)
482
+
483
+ ### Throw exception.
484
+ if _raising:
485
+ throw(TimeoutError, _timeout)
486
+
487
+ return
481
488
 
482
489
  ## Sleep.
483
490
  sleep(_interval)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reykit
3
- Version: 1.1.2
3
+ Version: 1.1.4
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>
@@ -14,17 +14,17 @@ 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=8goz-IL26EpVSDgDg47Qe3U10vhze4modHIhR2dpmYI,34651
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
20
+ reykit/rtime.py,sha256=nye9VIpFiAVL4Dg3ILxotVxHyXOigg_YJIZUlKITsq8,17176
21
21
  reykit/rtype.py,sha256=HQFllZjKHPnGYLS-zTwC948Rt0HVsGY12eObjwFfOSo,1962
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.4.dist-info/METADATA,sha256=Y41lIpSdEMy8NsPp8tA4YiqYMy3MrHPAN-5qQCRXkCY,1888
28
+ reykit-1.1.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
29
+ reykit-1.1.4.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
30
+ reykit-1.1.4.dist-info/RECORD,,
File without changes