huidevkit 0.6.0__tar.gz
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.
- huidevkit-0.6.0/LICENSE +201 -0
- huidevkit-0.6.0/MANIFEST.in +1 -0
- huidevkit-0.6.0/PKG-INFO +417 -0
- huidevkit-0.6.0/README.md +354 -0
- huidevkit-0.6.0/huidevkit.egg-info/PKG-INFO +417 -0
- huidevkit-0.6.0/huidevkit.egg-info/SOURCES.txt +93 -0
- huidevkit-0.6.0/huidevkit.egg-info/dependency_links.txt +1 -0
- huidevkit-0.6.0/huidevkit.egg-info/entry_points.txt +2 -0
- huidevkit-0.6.0/huidevkit.egg-info/requires.txt +55 -0
- huidevkit-0.6.0/huidevkit.egg-info/top_level.txt +2 -0
- huidevkit-0.6.0/py_tools/__init__.py +1 -0
- huidevkit-0.6.0/py_tools/chatbot/__init__.py +21 -0
- huidevkit-0.6.0/py_tools/chatbot/app_server.py +288 -0
- huidevkit-0.6.0/py_tools/chatbot/chatbot.py +162 -0
- huidevkit-0.6.0/py_tools/chatbot/factory.py +76 -0
- huidevkit-0.6.0/py_tools/connections/__init__.py +5 -0
- huidevkit-0.6.0/py_tools/connections/db/__init__.py +13 -0
- huidevkit-0.6.0/py_tools/connections/db/mysql/__init__.py +9 -0
- huidevkit-0.6.0/py_tools/connections/db/mysql/client.py +708 -0
- huidevkit-0.6.0/py_tools/connections/db/mysql/orm_model.py +59 -0
- huidevkit-0.6.0/py_tools/connections/db/redis_client.py +82 -0
- huidevkit-0.6.0/py_tools/connections/http/__init__.py +8 -0
- huidevkit-0.6.0/py_tools/connections/http/client.py +375 -0
- huidevkit-0.6.0/py_tools/connections/mq/__init__.py +13 -0
- huidevkit-0.6.0/py_tools/connections/mq/kafka_client.py +13 -0
- huidevkit-0.6.0/py_tools/connections/mq/rabbitmq_client.py +13 -0
- huidevkit-0.6.0/py_tools/connections/oss/__init__.py +13 -0
- huidevkit-0.6.0/py_tools/connections/oss/minio_client.py +66 -0
- huidevkit-0.6.0/py_tools/constants/__init__.py +8 -0
- huidevkit-0.6.0/py_tools/constants/const.py +25 -0
- huidevkit-0.6.0/py_tools/data_schemas/__init__.py +5 -0
- huidevkit-0.6.0/py_tools/data_schemas/time.py +15 -0
- huidevkit-0.6.0/py_tools/data_schemas/unit.py +106 -0
- huidevkit-0.6.0/py_tools/decorators/__init__.py +8 -0
- huidevkit-0.6.0/py_tools/decorators/base.py +224 -0
- huidevkit-0.6.0/py_tools/decorators/cache.py +167 -0
- huidevkit-0.6.0/py_tools/enums/__init__.py +8 -0
- huidevkit-0.6.0/py_tools/enums/base.py +87 -0
- huidevkit-0.6.0/py_tools/enums/error.py +43 -0
- huidevkit-0.6.0/py_tools/enums/feishu.py +16 -0
- huidevkit-0.6.0/py_tools/enums/http.py +17 -0
- huidevkit-0.6.0/py_tools/enums/pub_biz.py +28 -0
- huidevkit-0.6.0/py_tools/enums/time.py +25 -0
- huidevkit-0.6.0/py_tools/exceptions/__init__.py +14 -0
- huidevkit-0.6.0/py_tools/exceptions/base.py +44 -0
- huidevkit-0.6.0/py_tools/logging/__init__.py +4 -0
- huidevkit-0.6.0/py_tools/logging/base.py +87 -0
- huidevkit-0.6.0/py_tools/logging/default_logging_conf.py +65 -0
- huidevkit-0.6.0/py_tools/meta_cls/__init__.py +3 -0
- huidevkit-0.6.0/py_tools/meta_cls/base.py +33 -0
- huidevkit-0.6.0/py_tools/utils/__init__.py +15 -0
- huidevkit-0.6.0/py_tools/utils/async_util.py +105 -0
- huidevkit-0.6.0/py_tools/utils/excel_util.py +183 -0
- huidevkit-0.6.0/py_tools/utils/file_util.py +188 -0
- huidevkit-0.6.0/py_tools/utils/func_util.py +32 -0
- huidevkit-0.6.0/py_tools/utils/jwt_util.py +81 -0
- huidevkit-0.6.0/py_tools/utils/mask_util.py +33 -0
- huidevkit-0.6.0/py_tools/utils/project_templates/__init__.py +3 -0
- huidevkit-0.6.0/py_tools/utils/project_templates/make_pro.py +94 -0
- huidevkit-0.6.0/py_tools/utils/project_templates/python_project/src/constants/__init__.py +0 -0
- huidevkit-0.6.0/py_tools/utils/project_templates/python_project/src/dao/__init__.py +28 -0
- huidevkit-0.6.0/py_tools/utils/project_templates/python_project/src/dao/orm/manage/__init__.py +1 -0
- huidevkit-0.6.0/py_tools/utils/project_templates/python_project/src/dao/orm/manage/user.py +7 -0
- huidevkit-0.6.0/py_tools/utils/project_templates/python_project/src/dao/orm/table/__init__.py +1 -0
- huidevkit-0.6.0/py_tools/utils/project_templates/python_project/src/dao/orm/table/user.py +13 -0
- huidevkit-0.6.0/py_tools/utils/project_templates/python_project/src/dao/redis/__init__.py +2 -0
- huidevkit-0.6.0/py_tools/utils/project_templates/python_project/src/dao/redis/cache_info.py +4 -0
- huidevkit-0.6.0/py_tools/utils/project_templates/python_project/src/dao/redis/client.py +5 -0
- huidevkit-0.6.0/py_tools/utils/project_templates/python_project/src/data_schemas/__init__.py +0 -0
- huidevkit-0.6.0/py_tools/utils/project_templates/python_project/src/data_schemas/api_schemas/__init__.py +0 -0
- huidevkit-0.6.0/py_tools/utils/project_templates/python_project/src/data_schemas/logic_schemas/__init__.py +0 -0
- huidevkit-0.6.0/py_tools/utils/project_templates/python_project/src/enums/__init__.py +1 -0
- huidevkit-0.6.0/py_tools/utils/project_templates/python_project/src/enums/base.py +16 -0
- huidevkit-0.6.0/py_tools/utils/project_templates/python_project/src/handlers/__init__.py +0 -0
- huidevkit-0.6.0/py_tools/utils/project_templates/python_project/src/middlewares/__init__.py +0 -0
- huidevkit-0.6.0/py_tools/utils/project_templates/python_project/src/routes/__init__.py +0 -0
- huidevkit-0.6.0/py_tools/utils/project_templates/python_project/src/server.py +0 -0
- huidevkit-0.6.0/py_tools/utils/project_templates/python_project/src/services/__init__.py +0 -0
- huidevkit-0.6.0/py_tools/utils/project_templates/python_project/src/services/base.py +3 -0
- huidevkit-0.6.0/py_tools/utils/project_templates/python_project/src/settings/__init__.py +14 -0
- huidevkit-0.6.0/py_tools/utils/project_templates/python_project/src/settings/base_setting.py +3 -0
- huidevkit-0.6.0/py_tools/utils/project_templates/python_project/src/settings/db_setting.py +13 -0
- huidevkit-0.6.0/py_tools/utils/project_templates/python_project/src/settings/log_setting.py +56 -0
- huidevkit-0.6.0/py_tools/utils/project_templates/python_project/src/utils/__init__.py +3 -0
- huidevkit-0.6.0/py_tools/utils/project_templates/python_project/src/utils/context_util.py +7 -0
- huidevkit-0.6.0/py_tools/utils/project_templates/python_project/src/utils/log_util.py +13 -0
- huidevkit-0.6.0/py_tools/utils/project_templates/python_project/src/utils/trace_util.py +44 -0
- huidevkit-0.6.0/py_tools/utils/project_templates/python_project/src/utils/web_util.py +35 -0
- huidevkit-0.6.0/py_tools/utils/re_util.py +141 -0
- huidevkit-0.6.0/py_tools/utils/serializer_util.py +123 -0
- huidevkit-0.6.0/py_tools/utils/time_util.py +180 -0
- huidevkit-0.6.0/py_tools/utils/tree_util.py +144 -0
- huidevkit-0.6.0/setup.cfg +4 -0
- huidevkit-0.6.0/setup.py +91 -0
- huidevkit-0.6.0/tests/__init__.py +13 -0
huidevkit-0.6.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
recursive-include py_tools/utils/project_templates *
|
huidevkit-0.6.0/PKG-INFO
ADDED
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: huidevkit
|
|
3
|
+
Version: 0.6.0
|
|
4
|
+
Summary: Practical Python development tools
|
|
5
|
+
Home-page: https://github.com/HuiDBK/py-tools
|
|
6
|
+
Author: hui
|
|
7
|
+
Author-email: huidbk@163.com
|
|
8
|
+
License: Apache
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: loguru<0.8,>=0.7.0
|
|
16
|
+
Requires-Dist: pydantic<3,>=2.1.1
|
|
17
|
+
Requires-Dist: asgiref==3.8.1
|
|
18
|
+
Requires-Dist: nest_asyncio==1.6.0
|
|
19
|
+
Requires-Dist: tqdm==4.66.4
|
|
20
|
+
Requires-Dist: python-dateutil==2.8.2
|
|
21
|
+
Requires-Dist: requests==2.31.0
|
|
22
|
+
Requires-Dist: aiohttp==3.9.5
|
|
23
|
+
Requires-Dist: cacheout==0.14.1
|
|
24
|
+
Requires-Dist: aiofiles==24.1.0
|
|
25
|
+
Requires-Dist: python-jose==3.3.0
|
|
26
|
+
Provides-Extra: db-orm
|
|
27
|
+
Requires-Dist: sqlalchemy[asyncio]==2.0.20; extra == "db-orm"
|
|
28
|
+
Requires-Dist: aiomysql==0.2.0; extra == "db-orm"
|
|
29
|
+
Provides-Extra: db-redis
|
|
30
|
+
Requires-Dist: redis>=4.5.4; extra == "db-redis"
|
|
31
|
+
Provides-Extra: cache-proxy
|
|
32
|
+
Requires-Dist: redis>=4.5.4; extra == "cache-proxy"
|
|
33
|
+
Requires-Dist: python-memcached==1.62; extra == "cache-proxy"
|
|
34
|
+
Requires-Dist: cacheout==0.14.1; extra == "cache-proxy"
|
|
35
|
+
Provides-Extra: minio
|
|
36
|
+
Requires-Dist: minio==7.1.17; extra == "minio"
|
|
37
|
+
Provides-Extra: excel-tools
|
|
38
|
+
Requires-Dist: pandas==2.0.3; extra == "excel-tools"
|
|
39
|
+
Requires-Dist: openpyxl==3.0.10; extra == "excel-tools"
|
|
40
|
+
Provides-Extra: all
|
|
41
|
+
Requires-Dist: loguru<0.8,>=0.7.0; extra == "all"
|
|
42
|
+
Requires-Dist: cacheout==0.14.1; extra == "all"
|
|
43
|
+
Requires-Dist: python-dateutil==2.8.2; extra == "all"
|
|
44
|
+
Requires-Dist: pandas==2.0.3; extra == "all"
|
|
45
|
+
Requires-Dist: python-jose==3.3.0; extra == "all"
|
|
46
|
+
Requires-Dist: pydantic<3,>=2.1.1; extra == "all"
|
|
47
|
+
Requires-Dist: aiofiles==24.1.0; extra == "all"
|
|
48
|
+
Requires-Dist: tqdm==4.66.4; extra == "all"
|
|
49
|
+
Requires-Dist: aiomysql==0.2.0; extra == "all"
|
|
50
|
+
Requires-Dist: nest_asyncio==1.6.0; extra == "all"
|
|
51
|
+
Requires-Dist: asgiref==3.8.1; extra == "all"
|
|
52
|
+
Requires-Dist: redis>=4.5.4; extra == "all"
|
|
53
|
+
Requires-Dist: minio==7.1.17; extra == "all"
|
|
54
|
+
Requires-Dist: sqlalchemy[asyncio]==2.0.20; extra == "all"
|
|
55
|
+
Requires-Dist: aiohttp==3.9.5; extra == "all"
|
|
56
|
+
Requires-Dist: python-memcached==1.62; extra == "all"
|
|
57
|
+
Requires-Dist: requests==2.31.0; extra == "all"
|
|
58
|
+
Requires-Dist: openpyxl==3.0.10; extra == "all"
|
|
59
|
+
Provides-Extra: test
|
|
60
|
+
Requires-Dist: pytest==7.3.1; extra == "test"
|
|
61
|
+
Requires-Dist: pytest-mock==3.14.0; extra == "test"
|
|
62
|
+
Requires-Dist: pytest-asyncio==0.23.8; extra == "test"
|
|
63
|
+
|
|
64
|
+
# Py-Tools
|
|
65
|
+
|
|
66
|
+
> Py-Tools 是一个实用的 Python 工具集和可复用组件库,旨在简化常见任务,提高 Python 项目的开发效率。
|
|
67
|
+
>
|
|
68
|
+
> 设计细节请移步到掘金查看:https://juejin.cn/column/7131286129713610766
|
|
69
|
+
|
|
70
|
+
## 安装
|
|
71
|
+
- 环境要求:python version >= 3.8
|
|
72
|
+
- 历史版本记录:https://pypi.org/project/hui-tools/#history
|
|
73
|
+
|
|
74
|
+
> 根据 [PEP 625](https://peps.python.org/pep-0625/) 要求,从 0.6.0 版本开始,将包名改成了 `huidevkit`, 历史版本的包名仍然可用,但是不推荐使用。
|
|
75
|
+
|
|
76
|
+
### 默认安装
|
|
77
|
+
```python
|
|
78
|
+
pip install huidevkit
|
|
79
|
+
```
|
|
80
|
+
默认安装如下功能可以使用
|
|
81
|
+
- 时间工具类
|
|
82
|
+
- http客户端
|
|
83
|
+
- 同步异步互转装饰器
|
|
84
|
+
- 常用枚举
|
|
85
|
+
- pydantic
|
|
86
|
+
- loguru的日志器
|
|
87
|
+
- jwt工具类
|
|
88
|
+
- 等...
|
|
89
|
+
|
|
90
|
+
### 全部安装
|
|
91
|
+
```python
|
|
92
|
+
pip install huidevkit[all]
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### 可选安装
|
|
96
|
+
```python
|
|
97
|
+
pip install huidevkit[db-orm, db-redis, excel-tools]
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
可选参数参考:
|
|
101
|
+
```python
|
|
102
|
+
extras_require = {
|
|
103
|
+
"db-orm": ["sqlalchemy[asyncio]==2.0.20", "aiomysql==0.2.0"],
|
|
104
|
+
"db-redis": ["redis>=4.5.4"],
|
|
105
|
+
"cache-proxy": ["redis>=4.5.4", "python-memcached==1.62", "cacheout==0.14.1"],
|
|
106
|
+
"minio": ["minio==7.1.17"],
|
|
107
|
+
"excel-tools": ["pandas==2.2.2", "openpyxl==3.0.10"],
|
|
108
|
+
"test": ["pytest==7.3.1", "pytest-mock==3.14.0", "pytest-asyncio==0.23.8"],
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### 简单使用
|
|
113
|
+
> 所有功能都是从 py_tools 包中导入使用
|
|
114
|
+
> 详细使用请查看项目的DEMO: https://github.com/HuiDBK/py-tools/tree/master/demo
|
|
115
|
+
|
|
116
|
+
生成python web项目结构模板
|
|
117
|
+
```python
|
|
118
|
+
py_tools make_project WebDemo
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
快速配置项目日志
|
|
122
|
+
```python
|
|
123
|
+
from py_tools.constants import BASE_DIR
|
|
124
|
+
from py_tools.logging import logger, setup_logging
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def main():
|
|
128
|
+
setup_logging(log_dir=BASE_DIR / "logs")
|
|
129
|
+
logger.info("use log dir")
|
|
130
|
+
logger.error("test error")
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
if __name__ == '__main__':
|
|
134
|
+
main()
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
异步http客户端
|
|
138
|
+
```python
|
|
139
|
+
import asyncio
|
|
140
|
+
from py_tools.connections.http import AsyncHttpClient
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
async def main():
|
|
144
|
+
url = "https://juejin.cn/"
|
|
145
|
+
resp = await AsyncHttpClient().get(url).execute()
|
|
146
|
+
text_data = await AsyncHttpClient().get(url, params={"test": "hui"}).text()
|
|
147
|
+
json_data = await AsyncHttpClient().post(url, data={"test": "hui"}).json()
|
|
148
|
+
byte_data = await AsyncHttpClient().get(url).bytes()
|
|
149
|
+
|
|
150
|
+
async with AsyncHttpClient() as client:
|
|
151
|
+
upload_file_ret = await client.upload_file(url, file="test.txt").json()
|
|
152
|
+
|
|
153
|
+
async for chunk in AsyncHttpClient().get(url).stream(chunk_size=512):
|
|
154
|
+
# 流式调用
|
|
155
|
+
print(chunk)
|
|
156
|
+
|
|
157
|
+
await AsyncHttpClient.close()
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
if __name__ == "__main__":
|
|
161
|
+
asyncio.run(main())
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
mysql数据库操作demo
|
|
165
|
+
```python
|
|
166
|
+
import asyncio
|
|
167
|
+
import uuid
|
|
168
|
+
from typing import List
|
|
169
|
+
|
|
170
|
+
from connections.sqlalchemy_demo.manager import UserFileManager
|
|
171
|
+
from connections.sqlalchemy_demo.table import UserFileTable
|
|
172
|
+
from sqlalchemy import func
|
|
173
|
+
|
|
174
|
+
from py_tools.connections.db.mysql import BaseOrmTable, DBManager, SQLAlchemyManager
|
|
175
|
+
|
|
176
|
+
db_client = SQLAlchemyManager(
|
|
177
|
+
host="127.0.0.1",
|
|
178
|
+
port=3306,
|
|
179
|
+
user="root",
|
|
180
|
+
password="123456",
|
|
181
|
+
db_name="hui-demo",
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
async def create_and_transaction_demo():
|
|
186
|
+
async with UserFileManager.transaction() as session:
|
|
187
|
+
await UserFileManager(session).bulk_add(table_objs=[{"filename": "aaa", "oss_key": uuid.uuid4().hex}])
|
|
188
|
+
user_file_obj = UserFileTable(filename="eee", oss_key=uuid.uuid4().hex)
|
|
189
|
+
file_id = await UserFileManager(session).add(table_obj=user_file_obj)
|
|
190
|
+
print("file_id", file_id)
|
|
191
|
+
|
|
192
|
+
ret: UserFileTable = await UserFileManager(session).query_by_id(2)
|
|
193
|
+
print("query_by_id", ret)
|
|
194
|
+
|
|
195
|
+
# a = 1 / 0
|
|
196
|
+
|
|
197
|
+
ret = await UserFileManager(session).query_one(
|
|
198
|
+
cols=[UserFileTable.filename, UserFileTable.oss_key], conds=[UserFileTable.filename == "ccc"],
|
|
199
|
+
)
|
|
200
|
+
print("ret", ret)
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
async def query_demo():
|
|
204
|
+
ret = await UserFileManager().query_one(conds=[UserFileTable.filename == "ccc"])
|
|
205
|
+
print("ret", ret)
|
|
206
|
+
|
|
207
|
+
file_count = await UserFileManager().query_one(cols=[func.count()], flat=True)
|
|
208
|
+
print("str col one ret", file_count)
|
|
209
|
+
|
|
210
|
+
filename = await UserFileManager().query_one(cols=[UserFileTable.filename], conds=[UserFileTable.id == 2], flat=True)
|
|
211
|
+
print("filename", filename)
|
|
212
|
+
|
|
213
|
+
ret = await UserFileManager().query_all(cols=[UserFileTable.filename, UserFileTable.oss_key])
|
|
214
|
+
print("ret", ret)
|
|
215
|
+
|
|
216
|
+
ret = await UserFileManager().query_all(cols=["filename", "oss_key"])
|
|
217
|
+
print("str col ret", ret)
|
|
218
|
+
|
|
219
|
+
ret: List[UserFileTable] = await UserFileManager().query_all()
|
|
220
|
+
print("ret", ret)
|
|
221
|
+
|
|
222
|
+
ret = await UserFileManager().query_all(cols=[UserFileTable.id], flat=True)
|
|
223
|
+
print("ret", ret)
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
async def list_page_demo():
|
|
227
|
+
"""分页查询demo"""
|
|
228
|
+
total_count, data_list = await UserFileManager().list_page(
|
|
229
|
+
cols=["filename", "oss_key", "file_size"], curr_page=2, page_size=10
|
|
230
|
+
)
|
|
231
|
+
print("total_count", total_count, f"data_list[{len(data_list)}]", data_list)
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
async def run_raw_sql_demo():
|
|
235
|
+
"""运行原生sql demo"""
|
|
236
|
+
count_sql = "select count(*) as total_count from user_file"
|
|
237
|
+
count_ret = await UserFileManager().run_sql(count_sql, query_one=True)
|
|
238
|
+
print("count_ret", count_ret)
|
|
239
|
+
|
|
240
|
+
data_sql = "select * from user_file where id > :id_val and file_size >= :file_size_val"
|
|
241
|
+
params = {"id_val": 20, "file_size_val": 0}
|
|
242
|
+
data_ret = await UserFileManager().run_sql(data_sql, params=params)
|
|
243
|
+
print("dict data_ret", data_ret)
|
|
244
|
+
|
|
245
|
+
# 连表查询
|
|
246
|
+
data_sql = """
|
|
247
|
+
select
|
|
248
|
+
user.id as user_id,
|
|
249
|
+
username,
|
|
250
|
+
user_file.id as file_id,
|
|
251
|
+
filename,
|
|
252
|
+
oss_key
|
|
253
|
+
from
|
|
254
|
+
user_file
|
|
255
|
+
join user on user.id = user_file.creator
|
|
256
|
+
where
|
|
257
|
+
user_file.creator = :user_id
|
|
258
|
+
"""
|
|
259
|
+
data_ret = await UserFileManager().run_sql(data_sql, params={"user_id": 1})
|
|
260
|
+
print("join sql data_ret", data_ret)
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
async def curd_demo():
|
|
264
|
+
await create_and_transaction_demo()
|
|
265
|
+
await query_demo()
|
|
266
|
+
await list_page_demo()
|
|
267
|
+
await run_raw_sql_demo()
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
async def create_tables():
|
|
271
|
+
# 根据映射创建库表
|
|
272
|
+
async with DBManager.connection() as conn:
|
|
273
|
+
await conn.run_sync(BaseOrmTable.metadata.create_all)
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
async def main():
|
|
277
|
+
db_client.init_mysql_engine()
|
|
278
|
+
DBManager.init_db_client(db_client)
|
|
279
|
+
await create_tables()
|
|
280
|
+
await curd_demo()
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
if __name__ == "__main__":
|
|
284
|
+
asyncio.run(main())
|
|
285
|
+
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
## Todo List
|
|
289
|
+
|
|
290
|
+
### 连接客户端
|
|
291
|
+
1. [x] http 同步异步客户端
|
|
292
|
+
2. [x] MySQL 客户端 - SQLAlchemy-ORM 封装
|
|
293
|
+
3. [x] Redis 客户端
|
|
294
|
+
4. [x] Minio 客户端
|
|
295
|
+
5. 消息队列客户端,rabbitmq、kafka
|
|
296
|
+
6. websocket 客户端
|
|
297
|
+
|
|
298
|
+
### 工具类
|
|
299
|
+
- [x] 同异步函数转化工具类
|
|
300
|
+
- [x] excel 工具类
|
|
301
|
+
- [x] 文件 工具类
|
|
302
|
+
- [x] 实用函数工具模块
|
|
303
|
+
- [x] 数据掩码工具类
|
|
304
|
+
- [x] 常用正则工具类
|
|
305
|
+
- [x] 时间工具类
|
|
306
|
+
- [x] 树结构转换工具类
|
|
307
|
+
- [x] pydantic model 、dataclass 与 SQLALChemy table 序列化与反序列工具类
|
|
308
|
+
- 认证相关工具类
|
|
309
|
+
- [x] JWT 工具类
|
|
310
|
+
- 图片操作工具类,例如校验图片分辨率
|
|
311
|
+
- 邮件服务工具类
|
|
312
|
+
- 配置解析工具类
|
|
313
|
+
- 编码工具类,统一 base64、md5等编码入口
|
|
314
|
+
- 加密工具类
|
|
315
|
+
|
|
316
|
+
### 装饰器
|
|
317
|
+
1. [x] 超时装饰器
|
|
318
|
+
2. [x] 重试装饰器
|
|
319
|
+
3. [x] 缓存装饰器
|
|
320
|
+
4. [x] 异步执行装饰器
|
|
321
|
+
|
|
322
|
+
### 枚举
|
|
323
|
+
1. [x] 通用枚举类封装
|
|
324
|
+
2. [x] 错误码枚举封装
|
|
325
|
+
3. [x] 常用枚举
|
|
326
|
+
|
|
327
|
+
### 异常
|
|
328
|
+
1. [x] 业务异常类封装
|
|
329
|
+
|
|
330
|
+
### 日志
|
|
331
|
+
1. [x] logger 日志器(loguru)
|
|
332
|
+
2. [x] 快速配置项目日志函数
|
|
333
|
+
|
|
334
|
+
## 工程目录结构
|
|
335
|
+
|
|
336
|
+
```
|
|
337
|
+
py-tools/
|
|
338
|
+
├── py_tools/
|
|
339
|
+
│ ├── chatbot/
|
|
340
|
+
│ ├── connections/
|
|
341
|
+
│ ├── constants/
|
|
342
|
+
│ ├── data_schemas/
|
|
343
|
+
│ ├── decorators/
|
|
344
|
+
│ ├── enums/
|
|
345
|
+
│ ├── exceptions/
|
|
346
|
+
│ ├── meta_cls/
|
|
347
|
+
│ └── utils/
|
|
348
|
+
├── docs/
|
|
349
|
+
├── demo/
|
|
350
|
+
├── tests/
|
|
351
|
+
├── .gitignore
|
|
352
|
+
├── LICENSE
|
|
353
|
+
├── README.md
|
|
354
|
+
└── requirements.txt
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
### 项目模块
|
|
360
|
+
|
|
361
|
+
- **chatbot**: 用于构建和管理聊天机器人互动的工具集。
|
|
362
|
+
- **connections**: 用于连接各种服务和 API 的连接管理工具。
|
|
363
|
+
- **constants**: Python 项目中常用的常量。
|
|
364
|
+
- **data_schemas**: 用于处理结构化数据的数据模型及相关工具。
|
|
365
|
+
- **decorators**: 一系列有用的装饰器,用以增强函数和方法。
|
|
366
|
+
- **enums**: 定义常用枚举类型,方便在项目中使用。
|
|
367
|
+
- **exceptions**: 自定义异常类,用于项目中的错误处理。
|
|
368
|
+
- **meta_cls**: 元类和元编程相关的工具和技术。
|
|
369
|
+
- **utils**: 包含各种实用函数和工具,用于简化日常编程任务。
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
### 项目文档
|
|
374
|
+
|
|
375
|
+
在 `docs` 目录下存放一些项目相关文档。
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
### 示例
|
|
380
|
+
|
|
381
|
+
在 `demo` 目录下,您可以找到一些使用 Py-Tools 的示例代码,这些代码展示了如何使用这些工具集实现实际项目中的任务。
|
|
382
|
+
|
|
383
|
+
demo:https://github.com/HuiDBK/py-tools/tree/master/demo
|
|
384
|
+
|
|
385
|
+
### 测试
|
|
386
|
+
|
|
387
|
+
在 `tests` 目录下,包含了针对 Py-Tools 的各个组件的单元测试。通过运行这些测试,您可以确保工具集在您的环境中正常工作。
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
## 一起贡献
|
|
392
|
+
> 欢迎您对本项目进行贡献。请在提交 Pull Request 之前阅读项目的贡献指南,并确保您的代码符合项目的代码风格。
|
|
393
|
+
|
|
394
|
+
1. Fork后克隆本项目到本地:
|
|
395
|
+
```bash
|
|
396
|
+
git clone https://github.com/<github_name>/py-tools.git
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
2. 安装依赖:
|
|
400
|
+
```python
|
|
401
|
+
pip install -r requirements.txt
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
3. 配置python代码风格检查到 git hook 中
|
|
405
|
+
|
|
406
|
+
安装 pre-commit
|
|
407
|
+
```python
|
|
408
|
+
pip install pre-commit
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
再项目目录下执行
|
|
412
|
+
```python
|
|
413
|
+
pre-commit install
|
|
414
|
+
```
|
|
415
|
+
安装成功后 git commit 后会提前进行代码检查
|
|
416
|
+
|
|
417
|
+
4. 提PR
|