reykit 1.1.26__py3-none-any.whl → 1.1.27__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
@@ -14,9 +14,7 @@ from collections import defaultdict as Defaultdict, ChainMap
14
14
  from collections.abc import Callable, Iterable, Generator
15
15
  from itertools import chain as IChain
16
16
 
17
- from .rexc import check_least_one, check_most_one
18
- from .rsys import is_iterable
19
- from .rtype import T, KT, VT, Base, null
17
+ from .rbase import T, KT, VT, Base, null, check_least_one, check_most_one, is_iterable
20
18
 
21
19
 
22
20
  __all__ = (
@@ -134,10 +132,10 @@ def flatten(data: Any, *, _flattern_data: list | None = None) -> list:
134
132
 
135
133
 
136
134
  @overload
137
- def split(data: Iterable[T], share: int = None, bin_size: None = None) -> list[list[T]]: ...
135
+ def split(data: Iterable[T], share: int) -> list[list[T]]: ...
138
136
 
139
137
  @overload
140
- def split(data: Iterable[T], share: None = None, bin_size: int = None) -> list[list[T]]: ...
138
+ def split(data: Iterable[T], *, bin_size: int) -> list[list[T]]: ...
141
139
 
142
140
  def split(data: Iterable[T], share: int | None = None, bin_size: int | None = None) -> list[list[T]]:
143
141
  """
reykit/remail.py CHANGED
@@ -14,10 +14,9 @@ from email.mime.multipart import MIMEMultipart
14
14
  from email.mime.text import MIMEText
15
15
  from email.mime.application import MIMEApplication
16
16
 
17
+ from .rbase import Base, throw
17
18
  from .rdata import unique
18
- from .rexc import throw
19
19
  from .ros import FileBytes, get_file_bytes
20
- from .rtype import Base
21
20
 
22
21
 
23
22
  __all__ = (
reykit/rimage.py CHANGED
@@ -32,8 +32,8 @@ __all__ = (
32
32
 
33
33
 
34
34
  # Monkey path.
35
- monkey_image_type = monkey_path_pil_image_get_bytes()
36
- Image = monkey_image_type
35
+ Image_ = monkey_path_pil_image_get_bytes()
36
+ Image = Image_
37
37
 
38
38
 
39
39
  def encode_qrcode(text: str, path: str | None = None) -> bytes:
reykit/rlog.py CHANGED
@@ -29,14 +29,12 @@ from logging import (
29
29
  from logging.handlers import QueueHandler
30
30
  from concurrent_log_handler import ConcurrentRotatingFileHandler, ConcurrentTimedRotatingFileHandler
31
31
 
32
- from .rexc import throw, catch_exc
32
+ from .rbase import Base, ConfigMeta, throw, catch_exc, get_first_notnone, get_stack_param
33
33
  from .ros import File
34
34
  from .rre import search, sub
35
35
  from .rstdout import ConfigStdout, modify_print, reset_print
36
- from .rsys import get_first_notnull, get_stack_param
37
36
  from .rtext import to_text
38
37
  from .rtime import now, time_to
39
- from .rtype import Base, ConfigMeta
40
38
  from .rwrap import wrap_thread
41
39
 
42
40
 
@@ -421,7 +419,7 @@ class Log(Base):
421
419
  """
422
420
 
423
421
  # Get parameter.
424
- format_ = get_first_notnull(format_, self.default_format, default='exception')
422
+ format_ = get_first_notnone(format_, self.default_format)
425
423
  filter_ = filter_ or self.get_default_filter_method(format_, 'print')
426
424
 
427
425
  # Create handler.
@@ -443,7 +441,7 @@ class Log(Base):
443
441
  self,
444
442
  path: str | None = None,
445
443
  mb: float | None = None,
446
- time: None = None,
444
+ *,
447
445
  level: int = DEBUG,
448
446
  format_: str | None = None,
449
447
  filter_: Callable[[LogRecord], bool] | None = None
@@ -453,7 +451,7 @@ class Log(Base):
453
451
  def add_file(
454
452
  self,
455
453
  path: str | None = None,
456
- mb: None = None,
454
+ *,
457
455
  time: float | Literal['m', 'w0', 'w1', 'w2', 'w3', 'w4', 'w5', 'w6'] = None,
458
456
  level: int = DEBUG,
459
457
  format_: str | None = None,
@@ -500,7 +498,7 @@ class Log(Base):
500
498
  """
501
499
 
502
500
  # Get parameter.
503
- format_ = get_first_notnull(format_, self.default_format, default='exception')
501
+ format_ = get_first_notnone(format_, self.default_format)
504
502
  path = path or self.name
505
503
  filter_ = filter_ or self.get_default_filter_method(format_, 'file')
506
504
 
reykit/rmonkey.py CHANGED
@@ -48,6 +48,7 @@ def monkey_patch_sqlalchemy_result_more_fetch():
48
48
  # Import.
49
49
  from sqlalchemy.engine.cursor import CursorResult
50
50
  from pandas import DataFrame, NA, concat
51
+ from .rbase import Base
51
52
  from .rstdout import echo
52
53
  from .rtable import (
53
54
  to_table,
@@ -62,7 +63,6 @@ def monkey_patch_sqlalchemy_result_more_fetch():
62
63
  to_excel
63
64
  )
64
65
  from .rtime import time_to
65
- from .rtype import Base
66
66
 
67
67
  # Fetch result as table in 'list[dict]' format.
68
68
  CursorResult.fetch_table = to_table
@@ -323,7 +323,7 @@ def monkey_path_pil_image_get_bytes():
323
323
 
324
324
  from PIL.Image import Image
325
325
  from io import BytesIO
326
- from reykit.rtype import Base
326
+ from reykit.rbase import Base
327
327
 
328
328
 
329
329
  # Define.
reykit/rnet.py CHANGED
@@ -30,10 +30,9 @@ from mimetypes import guess_type
30
30
  from filetype import guess as filetype_guess
31
31
  from datetime import datetime
32
32
 
33
- from .rexc import throw, check_response_code
33
+ from .rbase import Base, throw, check_response_code
34
34
  from .ros import File
35
35
  from .rre import search
36
- from .rtype import Base
37
36
 
38
37
 
39
38
  __all__ = (
reykit/rnum.py CHANGED
@@ -11,10 +11,11 @@
11
11
 
12
12
  from typing import Any
13
13
 
14
- from .rexc import throw
14
+ from .rbase import throw
15
15
 
16
16
 
17
17
  __all__ = (
18
+ 'is_int',
18
19
  'digits',
19
20
  'to_number',
20
21
  'number_ch'
reykit/ros.py CHANGED
@@ -51,11 +51,10 @@ from docx.oxml.table import CT_Tbl
51
51
  from lxml.etree import ElementChildIterator
52
52
  from pdfplumber import open as pdfplumber_open
53
53
 
54
- from .rexc import throw
54
+ from .rbase import Base, throw
55
55
  from .rre import search, sub
56
- from .rsys import dos_command
56
+ from .rsys import run_cmd
57
57
  from .rtext import to_json
58
- from .rtype import Base
59
58
 
60
59
 
61
60
  __all__ = (
@@ -324,14 +323,14 @@ class File(Base):
324
323
  @overload
325
324
  def open(
326
325
  self,
327
- mode: OpenTextMode = 'wb+'
328
- ) -> TextIO: ...
326
+ mode: OpenBinaryMode = 'wb+'
327
+ ) -> BinaryIO: ...
329
328
 
330
329
  @overload
331
330
  def open(
332
331
  self,
333
- mode: OpenBinaryMode = 'wb+'
334
- ) -> BinaryIO: ...
332
+ mode: OpenTextMode
333
+ ) -> TextIO: ...
335
334
 
336
335
  def open(
337
336
  self,
@@ -368,22 +367,10 @@ class File(Base):
368
367
 
369
368
 
370
369
  @overload
371
- def r(self) -> TextIO: ...
372
-
373
- @overload
374
- def w(self) -> TextIO: ...
370
+ def __getattr__(self, name: Literal['r', 'w', 'a']) -> TextIO: ...
375
371
 
376
372
  @overload
377
- def a(self) -> TextIO: ...
378
-
379
- @overload
380
- def rb(self) -> BinaryIO: ...
381
-
382
- @overload
383
- def wb(self) -> BinaryIO: ...
384
-
385
- @overload
386
- def ab(self) -> BinaryIO: ...
373
+ def __getattr__(self, name: Literal['rb', 'wb', 'ab']) -> BinaryIO: ...
387
374
 
388
375
  def __getattr__(self, name: Literal['r', 'w', 'a', 'rb', 'wb', 'ab']) -> TextIO | BinaryIO:
389
376
  """
@@ -398,10 +385,14 @@ class File(Base):
398
385
  IO object.
399
386
  """
400
387
 
388
+ # Open.
401
389
  if name in ('r', 'w', 'a', 'rb', 'wb', 'ab'):
402
390
  io = self.open(name)
403
391
  return io
404
392
 
393
+ # Throw exception.
394
+ throw(AttributeError, name)
395
+
405
396
 
406
397
  @overload
407
398
  def read(
@@ -412,7 +403,7 @@ class File(Base):
412
403
  @overload
413
404
  def read(
414
405
  self,
415
- type_: Literal['str'] = 'bytes'
406
+ type_: Literal['str']
416
407
  ) -> str: ...
417
408
 
418
409
  def read(
@@ -538,7 +529,7 @@ class File(Base):
538
529
  # Read only.
539
530
  except PermissionError:
540
531
  command = f'attrib -r "{self.path}"'
541
- dos_command(command)
532
+ run_cmd(command)
542
533
  os_remove(self.path)
543
534
 
544
535
 
@@ -958,7 +949,8 @@ class Folder(Base):
958
949
  self,
959
950
  pattern: str,
960
951
  recursion: bool = False,
961
- all_ : Literal[True] = False
952
+ *,
953
+ all_ : Literal[True]
962
954
  ) -> list[str]: ...
963
955
 
964
956
  def search(
@@ -966,7 +958,7 @@ class Folder(Base):
966
958
  pattern: str,
967
959
  recursion: bool = False,
968
960
  all_ : bool = False
969
- ) -> str | None:
961
+ ) -> str | list[str] | None:
970
962
  """
971
963
  Search file by name.
972
964
 
@@ -1452,6 +1444,23 @@ class TempFile(Base):
1452
1444
  return file_md5
1453
1445
 
1454
1446
 
1447
+ @property
1448
+ def toml(self) -> dict[str, Any]:
1449
+ """
1450
+ Read and parse TOML file.
1451
+ Treat nan as a None or null value.
1452
+
1453
+ Returns
1454
+ -------
1455
+ Parameter dictionary.
1456
+ """
1457
+
1458
+ # Read and parse.
1459
+ params = read_toml(self.path)
1460
+
1461
+ return params
1462
+
1463
+
1455
1464
  def __len__(self) -> int:
1456
1465
  """
1457
1466
  Return file byte size.
@@ -1614,7 +1623,8 @@ class TempFolder(Base):
1614
1623
  self,
1615
1624
  pattern: str,
1616
1625
  recursion: bool = False,
1617
- all_ : Literal[True] = False
1626
+ *,
1627
+ all_ : Literal[True]
1618
1628
  ) -> list[str]: ...
1619
1629
 
1620
1630
  def search(
reykit/rrand.py CHANGED
@@ -19,9 +19,8 @@ from random import Random
19
19
  from secrets import randbelow as secrets_randbelow
20
20
  from threading import get_ident as threading_get_ident
21
21
 
22
- from .rexc import throw
22
+ from .rbase import T, Base, ConfigMeta, throw
23
23
  from .rnum import digits
24
- from .rtype import T, Base, ConfigMeta
25
24
 
26
25
 
27
26
  __all__ = (
@@ -132,48 +131,24 @@ class RandomSeed(Base):
132
131
 
133
132
 
134
133
  @overload
135
- def randn(
136
- *,
137
- precision: None = None
138
- ) -> int: ...
134
+ def randn() -> int: ...
139
135
 
140
136
  @overload
141
- def randn(
142
- high: int = 10,
143
- *,
144
- precision: None = None
145
- ) -> int: ...
137
+ def randn(high: int = 10) -> int: ...
146
138
 
147
139
  @overload
148
- def randn(
149
- low: int = 0,
150
- high: int = 10,
151
- *,
152
- precision: None = None
153
- ) -> int: ...
140
+ def randn(low: int = 0, high: int = 10) -> int: ...
154
141
 
155
142
  @overload
156
- def randn(
157
- *thresholds: float,
158
- precision: None = None
159
- ) -> float: ...
143
+ def randn(*thresholds: float) -> float: ...
160
144
 
161
145
  @overload
162
- def randn(
163
- *thresholds: float,
164
- precision: Literal[0] = None
165
- ) -> int: ...
146
+ def randn(*thresholds: float, precision: Literal[0]) -> int: ...
166
147
 
167
148
  @overload
168
- def randn(
169
- *thresholds: float,
170
- precision: int = None
171
- ) -> float: ...
172
-
173
- def randn(
174
- *thresholds: float,
175
- precision: int | None = None
176
- ) -> int | float:
149
+ def randn(*thresholds: float, precision: int) -> float: ...
150
+
151
+ def randn(*thresholds: float, precision: int | None = None) -> int | float:
177
152
  """
178
153
  Random number.
179
154
 
@@ -281,7 +256,7 @@ def randi(
281
256
  @overload
282
257
  def randi(
283
258
  data: Sequence,
284
- multi: int = None,
259
+ multi: int,
285
260
  unique: bool = True
286
261
  ) -> list[T]: ...
287
262
 
reykit/rre.py CHANGED
@@ -167,7 +167,7 @@ def search_batch(
167
167
  def search_batch(
168
168
  text: str,
169
169
  *patterns: str,
170
- first: Literal[False] = True
170
+ first: Literal[False]
171
171
  ) -> list[str | tuple[str | None, ...] | None]: ...
172
172
 
173
173
  def search_batch(
reykit/rschedule.py CHANGED
@@ -16,7 +16,7 @@ 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 Base
19
+ from .rbase import Base
20
20
 
21
21
 
22
22
  __all__ = (
reykit/rstdout.py CHANGED
@@ -16,9 +16,8 @@ from io import TextIOWrapper
16
16
  from os import devnull as os_devnull
17
17
  from os.path import abspath as os_abspath
18
18
 
19
- from .rsys import get_first_notnull, get_name, get_stack_param
19
+ from .rbase import Base, ConfigMeta, get_first_notnone, get_name, get_stack_param
20
20
  from .rtext import to_text, add_text_frame
21
- from .rtype import Base, ConfigMeta
22
21
 
23
22
 
24
23
  __all__ = (
@@ -112,7 +111,7 @@ def beautify_text(
112
111
  title = None
113
112
 
114
113
  ## Width.
115
- width = get_first_notnull(width, ConfigStdout.default_width, default='exception')
114
+ width = get_first_notnone(width, ConfigStdout.default_width)
116
115
 
117
116
  ## Frame.
118
117
  if ConfigStdout.is_frame_plain: