reykit 1.1.96__py3-none-any.whl → 1.1.98__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/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, Mapping
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,24 @@ from .rtime import time_to
23
23
 
24
24
 
25
25
  __all__ = (
26
- 'is_row',
27
- 'is_table',
26
+ 'RowData',
27
+ 'TableData',
28
28
  'Table'
29
29
  )
30
30
 
31
31
 
32
- type RowData = MutableMapping | CursorRow | Series
33
- type TableData = Collection[MutableMapping] | RowData | CursorResult | DataFrame
32
+ RowData = Iterable | Mapping
33
+ TableData = Iterable[RowData]
34
34
  SheetSet = TypedDict('SheetsSet', {'name': str, 'index': int, 'fields': str | list[str]})
35
35
 
36
36
 
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
37
  class Table(Base):
101
38
  """
102
39
  Table type.
103
40
  """
104
41
 
105
42
 
106
- def __init__(self, data: TableData) -> None:
43
+ def __init__(self, data: Iterable) -> None:
107
44
  """
108
45
  Build instance attributes.
109
46
 
@@ -127,23 +64,20 @@ class Table(Base):
127
64
 
128
65
  # Convert.
129
66
  match self.data:
130
- case MutableMapping():
67
+ case Mapping():
131
68
  result = [dict(self.data)]
132
69
  case CursorRow():
133
70
  result = [dict(self.data._mapping)]
134
- case Series():
135
- result = [dict(self.data.items())]
136
71
  case CursorResult():
137
72
  result = [
138
73
  dict(row)
139
74
  for row in self.data.mappings()
140
75
  ]
76
+ case Series():
77
+ result = [dict(self.data.items())]
141
78
  case DataFrame():
142
79
  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)
80
+ case Iterable():
147
81
  result = [
148
82
  dict(row)
149
83
  for row in self.data
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reykit
3
- Version: 1.1.96
3
+ Version: 1.1.98
4
4
  Summary: Kit method set.
5
5
  Project-URL: homepage, https://github.com/reyxbo/reykit/
6
6
  Author-email: Rey <reyxbo@163.com>
@@ -11,10 +11,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=qZL5Zq_zpjib-CcgPFyfH16iD2woLCT3b2ABPb-h0-g,10635
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.96.dist-info/METADATA,sha256=z9LDeiyKn8ElRPyoh3LO6KtSOzo-EuPnm775N6bOsWU,1872
26
- reykit-1.1.96.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
27
- reykit-1.1.96.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
28
- reykit-1.1.96.dist-info/RECORD,,
25
+ reykit-1.1.98.dist-info/METADATA,sha256=z0kX5lsPHZVXID8MNJJQr7XwRLl2ULO_lXRs5XlAVr4,1872
26
+ reykit-1.1.98.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
27
+ reykit-1.1.98.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
28
+ reykit-1.1.98.dist-info/RECORD,,