reykit 1.1.95__py3-none-any.whl → 1.1.97__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/rbase.py CHANGED
@@ -9,7 +9,7 @@
9
9
  """
10
10
 
11
11
 
12
- from typing import Any, Literal, Self, TypeVar, NoReturn, overload
12
+ from typing import Any, Literal, Self, TypeVar, Type, NoReturn, overload, final
13
13
  from collections.abc import Callable, Iterable, Container, Mapping
14
14
  from sys import exc_info as sys_exc_info
15
15
  from os.path import exists as os_exists
@@ -35,6 +35,7 @@ __all__ = (
35
35
  'StaticMeta',
36
36
  'ConfigMeta',
37
37
  'Singleton',
38
+ 'NullType',
38
39
  'Null',
39
40
  'ErrorBase',
40
41
  'Exit',
@@ -175,6 +176,28 @@ class ConfigMeta(StaticMeta):
175
176
  setattr(cls, name, value)
176
177
 
177
178
 
179
+ type NullType = Type['Null']
180
+
181
+
182
+ @final
183
+ class Null(Base, metaclass=StaticMeta):
184
+ """
185
+ Null type.
186
+
187
+ Attributes
188
+ ----------
189
+ Type : Type hints of self.
190
+
191
+ Examples
192
+ --------
193
+ >>> def foo(arg: Any | Null.Type = Null):
194
+ ... if arg == Null:
195
+ ... ...
196
+ """
197
+
198
+ Type = NullType
199
+
200
+
178
201
  class Singleton(Base):
179
202
  """
180
203
  Singleton type.
@@ -185,7 +208,7 @@ class Singleton(Base):
185
208
  _instance : Global singleton instance.
186
209
  """
187
210
 
188
- _instance: Self | None = None
211
+ __instance: Self
189
212
 
190
213
 
191
214
  def __new__(self, *arg: Any, **kwargs: Any) -> Self:
@@ -193,22 +216,19 @@ class Singleton(Base):
193
216
  Build `singleton` instance.
194
217
  """
195
218
 
196
- # Build.
197
- if self._instance is None:
198
- self._instance = super().__new__(self)
199
-
200
- ## Singleton method.
201
- if hasattr(self, "__singleton__"):
202
- __singleton__: Callable = getattr(self, "__singleton__")
203
- __singleton__(self, *arg, **kwargs)
219
+ # Built.
220
+ if hasattr(self, '__instance'):
221
+ return self.__instance
204
222
 
205
- return self._instance
223
+ # Build.
224
+ self.__instance = super().__new__(self)
206
225
 
226
+ ## Singleton method.
227
+ if hasattr(self, "__singleton__"):
228
+ __singleton__: Callable = getattr(self, "__singleton__")
229
+ __singleton__(self, *arg, **kwargs)
207
230
 
208
- class Null(Base, metaclass=StaticMeta):
209
- """
210
- Null type.
211
- """
231
+ return self.__instance
212
232
 
213
233
 
214
234
  class ErrorBase(Base, BaseException):
@@ -588,7 +608,7 @@ def get_first_notnone(*values: None) -> NoReturn: ...
588
608
  @overload
589
609
  def get_first_notnone(*values: T) -> T: ...
590
610
 
591
- def get_first_notnone(*values: T, default: U | Null = Null) -> T | U:
611
+ def get_first_notnone(*values: T, default: U | Null.Type = Null) -> T | U:
592
612
  """
593
613
  Get the first value that is not `None`.
594
614
 
@@ -597,7 +617,7 @@ def get_first_notnone(*values: T, default: U | Null = Null) -> T | U:
597
617
  values : Check values.
598
618
  default : When all are `None`, then return this is value, or throw exception.
599
619
  - `Any`: Return this is value.
600
- - `Null`: Throw exception.
620
+ - `Null.Type`: Throw exception.
601
621
 
602
622
  Returns
603
623
  -------
reykit/rdata.py CHANGED
@@ -337,14 +337,14 @@ def chain(*iterables: dict[KT, VT] | Iterable[T]) -> ChainMap[KT, VT] | IChain[T
337
337
  return data
338
338
 
339
339
 
340
- def default_dict(default: T | Null = Null, data: dict[KT, VT] | None = None) -> Defaultdict[KT, VT | T]:
340
+ def default_dict(default: T | Null.Type = Null, data: dict[KT, VT] | None = None) -> Defaultdict[KT, VT | T]:
341
341
  """
342
342
  Set `dict` instance, default value when key does not exist.
343
343
 
344
344
  Parameters
345
345
  ----------
346
346
  default : Default value.
347
- - `Null`: Nest function self.
347
+ - `Null.Type`: Nest function self.
348
348
  - `Callable`: Use call return value.
349
349
  data : `dict` instance.
350
350
  - `None`: Empty `dict`.
reykit/rlog.py CHANGED
@@ -954,7 +954,7 @@ class Mark(Base):
954
954
  self.data: dict[Hashable, set[int]] = {}
955
955
 
956
956
 
957
- def mark(self, obj: Any, group: Hashable | Null = Null) -> int:
957
+ def mark(self, obj: Any, group: Hashable | Null.Type = Null) -> int:
958
958
  """
959
959
  Mark object.
960
960
 
@@ -978,7 +978,7 @@ class Mark(Base):
978
978
  return obj_id
979
979
 
980
980
 
981
- def remove(self, obj: Any, group: Hashable | Null = Null) -> None:
981
+ def remove(self, obj: Any, group: Hashable | Null.Type = Null) -> None:
982
982
  """
983
983
  Whether marked.
984
984
 
@@ -1017,7 +1017,7 @@ class Mark(Base):
1017
1017
  del self.data[group]
1018
1018
 
1019
1019
 
1020
- def is_marked(self, obj: Any, group: Hashable | Null = Null) -> bool:
1020
+ def is_marked(self, obj: Any, group: Hashable | Null.Type = Null) -> bool:
1021
1021
  """
1022
1022
  Whether marked.
1023
1023
 
reykit/rschedule.py CHANGED
@@ -33,6 +33,7 @@ class DatabaseTableSchedule(rorm.Model, table=True):
33
33
  Database `schedule` table model.
34
34
  """
35
35
 
36
+ __name__ = 'schedule'
36
37
  __comment__ = 'Schedule execute record table.'
37
38
  create_time: rorm.Datetime = rorm.Field(field_default=':create_time', not_null=True, index_n=True, comment='Record create time.')
38
39
  update_time: rorm.Datetime = rorm.Field(field_default=':update_time', index_n=True, comment='Record update time.')
reykit/rtable.py CHANGED
@@ -9,8 +9,8 @@
9
9
  """
10
10
 
11
11
 
12
- from typing import Any, TypedDict, Literal, overload
13
- from collections.abc import Collection, MutableMapping
12
+ from typing import Any, TypedDict, overload
13
+ from collections.abc import Iterable, MutableMapping
14
14
  from os.path import abspath as os_abspath
15
15
  from sqlalchemy.engine.cursor import CursorResult, Row as CursorRow
16
16
  from pandas import DataFrame, Series, ExcelWriter
@@ -23,87 +23,20 @@ from .rtime import time_to
23
23
 
24
24
 
25
25
  __all__ = (
26
- 'is_row',
27
- 'is_table',
28
- 'Table'
26
+ 'Table',
29
27
  )
30
28
 
31
29
 
32
- type RowData = MutableMapping | CursorRow | Series
33
- type TableData = Collection[MutableMapping] | RowData | CursorResult | DataFrame
34
30
  SheetSet = TypedDict('SheetsSet', {'name': str, 'index': int, 'fields': str | list[str]})
35
31
 
36
32
 
37
- @overload
38
- def is_row(obj: RowData) -> Literal[True]: ...
39
-
40
- @overload
41
- def is_row(obj: Any) -> Literal[False]: ...
42
-
43
- def is_row(obj: Any) -> bool:
44
- """
45
- Judge whether it is row format.
46
-
47
- Parameters
48
- ----------
49
- obj : Ojbect.
50
-
51
- Returns
52
- -------
53
- Judgment result.
54
- """
55
-
56
- # Judge.
57
- result = isinstance(obj, (MutableMapping, CursorRow, Series))
58
-
59
- return result
60
-
61
-
62
- @overload
63
- def is_table(obj: TableData) -> bool: ...
64
-
65
- @overload
66
- def is_table(obj: Any) -> Literal[False]: ...
67
-
68
- def is_table(obj: Any) -> bool:
69
- """
70
- Judge whether it is table format, and keys sort of the row are the same.
71
-
72
- Parameters
73
- ----------
74
- obj : Ojbect.
75
-
76
- Returns
77
- -------
78
- Judgment result.
79
- """
80
-
81
- # Judge.
82
- if is_row(obj):
83
- return True
84
- if isinstance(obj, (CursorResult, DataFrame)):
85
- return True
86
- if isinstance(obj, Collection):
87
- keys_strs = []
88
- for row in obj:
89
- if not isinstance(row, MutableMapping):
90
- break
91
- keys_str = ':'.join(row)
92
- keys_strs.append(keys_str)
93
- keys_strs = set(keys_strs)
94
- if len(keys_strs) == 1:
95
- return True
96
-
97
- return False
98
-
99
-
100
33
  class Table(Base):
101
34
  """
102
35
  Table type.
103
36
  """
104
37
 
105
38
 
106
- def __init__(self, data: TableData) -> None:
39
+ def __init__(self, data: Iterable) -> None:
107
40
  """
108
41
  Build instance attributes.
109
42
 
@@ -131,19 +64,16 @@ class Table(Base):
131
64
  result = [dict(self.data)]
132
65
  case CursorRow():
133
66
  result = [dict(self.data._mapping)]
134
- case Series():
135
- result = [dict(self.data.items())]
136
67
  case CursorResult():
137
68
  result = [
138
69
  dict(row)
139
70
  for row in self.data.mappings()
140
71
  ]
72
+ case Series():
73
+ result = [dict(self.data.items())]
141
74
  case DataFrame():
142
75
  result = self.data.to_dict('records')
143
- case Collection():
144
- if not is_table(self.data):
145
- text = 'is not table format, or keys sort of the row are the not same'
146
- throw(TypeError, text=text)
76
+ case Iterable():
147
77
  result = [
148
78
  dict(row)
149
79
  for row in self.data
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reykit
3
- Version: 1.1.95
3
+ Version: 1.1.97
4
4
  Summary: Kit method set.
5
5
  Project-URL: homepage, https://github.com/reyxbo/reykit/
6
6
  Author-email: Rey <reyxbo@163.com>
@@ -1,20 +1,20 @@
1
1
  reykit/__init__.py,sha256=V86CHqPAAVkooVx3_QIOKpDIFVneQCTTSwfJ-uWgBno,788
2
2
  reykit/rall.py,sha256=7Hip02YOkIDm3_xkoSDjvvYV2LhdBV2r4UKzWWnIfIo,628
3
- reykit/rbase.py,sha256=qGfR24p__cMth8Xs9mdzQNXPq9-SBWcXf5xan2rU5b4,21776
4
- reykit/rdata.py,sha256=ktNSXzWRO_iYiIL-Ro2K6p0ACbmZeu-y1BEEJHxc1Bg,11346
3
+ reykit/rbase.py,sha256=SLnGRzNdHyFQhTW-SI9ncIMS0V7nTjlW9GJZZBT3LF0,22104
4
+ reykit/rdata.py,sha256=oBp3G7OZwb4rLDU_f4qi80u93bCvZ41ZdSM_1FBsMIE,11356
5
5
  reykit/remail.py,sha256=5ImoIRX0pHG_c1kEoMPJdeEaqakgMVIXeWBl9Db5ul4,6714
6
6
  reykit/rimage.py,sha256=3fMGbDwTdbmnlsz1Q33zCw-ht-xOUpj8NXYl6CzvYq0,6145
7
- reykit/rlog.py,sha256=lg2EpsTuEp3-CgrIcFMJIoW7kX7JsIAjyJwHxeMdhhE,25747
7
+ reykit/rlog.py,sha256=2-dStWPCHMmBpm-8J4HgTQ9B-pc9vDQ2bAF9R8XeanE,25762
8
8
  reykit/rmonkey.py,sha256=KBxUyiBlCu7RdVDL0mCuxLqycOItU3KeU6ZWXrKdvxc,7860
9
9
  reykit/rnet.py,sha256=jkFnXKyjgILK2A9CtBZwjOeuABdGwejFtwPV_YK1jNc,16862
10
10
  reykit/rnum.py,sha256=jEhPQatAAaIV6kPx2tVtfjuK0F09UCWU6BjfPRamqBE,3620
11
11
  reykit/ros.py,sha256=n9aqChdRQQFozOn_jXQns_UrKoEstCNRzFTgOBel4wM,47787
12
12
  reykit/rrand.py,sha256=kh9yWOW8zaj8bUU0H0RL_GiOs2K8JDviVzKSoPLEuls,8566
13
13
  reykit/rre.py,sha256=uqqved1_SWrJOQK-o5WYRoJf3JH0YpEktnxwA0x7TPU,6018
14
- reykit/rschedule.py,sha256=TMus57qhT3OPmRQaFLCZW5fT8bnR2c4hehQM1KVJaQ4,12580
14
+ reykit/rschedule.py,sha256=dx2lDfRhxPm8hGgH3mVGPoUSKg35OYQ3UQiRFnPo4yI,12607
15
15
  reykit/rstdout.py,sha256=bLN_kXsWpgTrCrBJNgaEE27DUk-ojsBV-9YJtWH41b4,8188
16
16
  reykit/rsys.py,sha256=PEXUU_jyglEgIyN-URtnpUcrqKF5PFeAVAljEmaSqOs,24931
17
- reykit/rtable.py,sha256=ItsycFuN-gb3gYhHuMx_nbAluGc8tAIMOyD5DHPS-lU,12173
17
+ reykit/rtable.py,sha256=OP8d3qX8xhoQ2pRwD-K4on4Pn7Mi7PZ5-sF8fYmOMAo,10555
18
18
  reykit/rtask.py,sha256=C-VySd7Gk_qtP7FigLckYUhDKsuWPVeGtoRlkdnpyDw,27099
19
19
  reykit/rtext.py,sha256=3wbnsvNX-ibPt7QCpv-CYDUgaFq48eZjCix8jcFPj_M,13248
20
20
  reykit/rtime.py,sha256=8GL2uycThxB-dODuD3D35v2RbSFO-LgTdl6U-ZhuSZc,17795
@@ -22,7 +22,7 @@ reykit/rwrap.py,sha256=8MqbOjq56DbDKuTix75wYGXcAykzLiAPKrgl13Gk4xQ,15086
22
22
  reykit/rzip.py,sha256=u-yyEFXY5iOysgzzqEbaaDTFfoHBj0L2sv5m4AQLt1c,3450
23
23
  reykit/rdll/__init__.py,sha256=TEVZjiW9Y1_VxbZgIygcwmRp5xFHM2wLgwZccZ6gjng,698
24
24
  reykit/rdll/rdll_core.py,sha256=o6-rKcTQgxZQe0kD3GnwyNb3KL9IogzgCQNOmYLMm7A,5086
25
- reykit-1.1.95.dist-info/METADATA,sha256=i8D3Rnu5vu9oR1nHeCNnpa06tKg_ja5B-prxHaFp88g,1872
26
- reykit-1.1.95.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
27
- reykit-1.1.95.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
28
- reykit-1.1.95.dist-info/RECORD,,
25
+ reykit-1.1.97.dist-info/METADATA,sha256=uy793_GknFh-KXeWPUD1p2j97GqUKyau25c4N_-gPY0,1872
26
+ reykit-1.1.97.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
27
+ reykit-1.1.97.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
28
+ reykit-1.1.97.dist-info/RECORD,,