gou2tool 0.2.11__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.
- gou2tool-0.2.11.dist-info/METADATA +49 -0
- gou2tool-0.2.11.dist-info/RECORD +28 -0
- gou2tool-0.2.11.dist-info/WHEEL +5 -0
- gou2tool-0.2.11.dist-info/licenses/LICENSE +201 -0
- gou2tool-0.2.11.dist-info/top_level.txt +2 -0
- goutool/__init__.py +13 -0
- goutool/util/__init__.py +50 -0
- goutool/util/address_util.py +136 -0
- goutool/util/date_util.py +0 -0
- goutool/util/db_template_util.py +121 -0
- goutool/util/email_util.py +9 -0
- goutool/util/env_util.py +19 -0
- goutool/util/file_util.py +67 -0
- goutool/util/id_util.py +11 -0
- goutool/util/path_util.py +203 -0
- goutool/util/phone_util.py +25 -0
- goutool/util/sql_util.py +208 -0
- goutool/util/str_util.py +51 -0
- goutool/util/time_util.py +0 -0
- goutool/util/tree_util.py +202 -0
- goutool/util/web_hook_util.py +111 -0
- tests/__init__.py +0 -0
- tests/id_util.py +17 -0
- tests/path_util.py +11 -0
- tests/phone_util.py +18 -0
- tests/sql_util.py +21 -0
- tests/str_util.py +15 -0
- tests/web_hook_util.py +22 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gou2tool
|
|
3
|
+
Version: 0.2.11
|
|
4
|
+
Summary: 🐶 Python工具类库 更加快速的开发项目 便捷优雅的使用类库
|
|
5
|
+
Home-page: https://gitee.com/kingood/goutool
|
|
6
|
+
Author: kingood
|
|
7
|
+
Author-email: wl4837@qq.com
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.6
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Provides-Extra: dev
|
|
15
|
+
Requires-Dist: pytest>=6.0; extra == "dev"
|
|
16
|
+
Requires-Dist: twine>=3.0; extra == "dev"
|
|
17
|
+
Dynamic: author
|
|
18
|
+
Dynamic: author-email
|
|
19
|
+
Dynamic: classifier
|
|
20
|
+
Dynamic: description
|
|
21
|
+
Dynamic: description-content-type
|
|
22
|
+
Dynamic: home-page
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
Dynamic: provides-extra
|
|
25
|
+
Dynamic: requires-python
|
|
26
|
+
Dynamic: summary
|
|
27
|
+
|
|
28
|
+
# GouTool
|
|
29
|
+
|
|
30
|
+
#### 介绍
|
|
31
|
+
🐶 Python工具类库 更加快速的开发项目 便捷优雅的使用类库
|
|
32
|
+
|
|
33
|
+
#### 软件架构
|
|
34
|
+
软件架构说明
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
#### 安装教程
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
#### 使用说明
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
#### 参与贡献
|
|
45
|
+
|
|
46
|
+
1. Fork 本仓库
|
|
47
|
+
2. 新建 Feat_xxx 分支
|
|
48
|
+
3. 提交代码
|
|
49
|
+
4. 新建 Pull Request
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
gou2tool-0.2.11.dist-info/licenses/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
|
|
2
|
+
goutool/__init__.py,sha256=ngYinT5cTYsQ-XC1MQ9gSUuHPdIhdgJlROy7ixYPTGs,226
|
|
3
|
+
goutool/util/__init__.py,sha256=dqTK92-asynq7adllAgJ671pOHBc0PvMwh8Qi9R7vZ4,1273
|
|
4
|
+
goutool/util/address_util.py,sha256=cMSg_ZF_Af5wBTTm6qeWjLRHKL6Y20se2r0_Je1IWd0,4488
|
|
5
|
+
goutool/util/date_util.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
goutool/util/db_template_util.py,sha256=ZbcOme6AE7YoiYDPYaWIzbhCTWDfn98bCKpRH7Vu7oE,3731
|
|
7
|
+
goutool/util/email_util.py,sha256=pYC0oAwhw5rJmSwSq6DwxDN-h4-rLEGosVMoIvEjzCc,260
|
|
8
|
+
goutool/util/env_util.py,sha256=nxkV_I52hCqXtzIEEn4vcyQ6yskV-QB8S2mN0D7sCUQ,499
|
|
9
|
+
goutool/util/file_util.py,sha256=mpkHlk8AzviIXUcpGC295YjWIknIJsgYeF9Gb8ktKdU,2004
|
|
10
|
+
goutool/util/id_util.py,sha256=kAQq10VnPkEuNcTrgP3BaG4r9yYueWKbwBTAmwlBS70,203
|
|
11
|
+
goutool/util/path_util.py,sha256=fMbE9NKxtICMpGDu2q8Kf6HcW4jryCqvfSG9bsUxprY,6667
|
|
12
|
+
goutool/util/phone_util.py,sha256=Y6JxRBgRvqvpr4iBWiniA44AulPvM8lhSY7SD44lfUk,621
|
|
13
|
+
goutool/util/sql_util.py,sha256=0uiaG3c3RsG1wES5wMjkMDLJwXdINYSyH441aruroLQ,7430
|
|
14
|
+
goutool/util/str_util.py,sha256=IYQc_pKk6uEhcod0t7RMOe543dDyfZ-rbbrIEf_Hvi8,1476
|
|
15
|
+
goutool/util/time_util.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
|
+
goutool/util/tree_util.py,sha256=nx9x3hRwc5Wj4zcqaGjxRmSDF5ORfERzY_HMdyU8hOM,7406
|
|
17
|
+
goutool/util/web_hook_util.py,sha256=gW2nNI_UP75C16_GNCJYLGuNMjji81wZ2hex63O-Xog,3226
|
|
18
|
+
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
|
+
tests/id_util.py,sha256=vmpgIGwGc3r1Hudicq9FNIJqZwGiF_mneYF3PvoWTpU,367
|
|
20
|
+
tests/path_util.py,sha256=9uQUKYyaFrqUqR8nEVtt72QgwRIVWFzo4rml2FPnaAs,267
|
|
21
|
+
tests/phone_util.py,sha256=uFwnNM6Y1v28NxyV8a5rct8V5gZlTkmhMtD8ZZl8GKE,392
|
|
22
|
+
tests/sql_util.py,sha256=QAOFsVuCnbes3-c_fDOgQlG-0dR3KlWudvm6avuwOG4,502
|
|
23
|
+
tests/str_util.py,sha256=J4PhcKcQNtkpiAsDIMwSrO8bmgf4-4l-ou-Lw5_LY_o,502
|
|
24
|
+
tests/web_hook_util.py,sha256=yOvisscRSWUhvIlykKKYVrka5SIkDUGhaOO1WZFzZ8A,630
|
|
25
|
+
gou2tool-0.2.11.dist-info/METADATA,sha256=H55rYfMtuhRw_J-rBzZh-Esmd58zkb__0BHaaPGL4Ik,1127
|
|
26
|
+
gou2tool-0.2.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
27
|
+
gou2tool-0.2.11.dist-info/top_level.txt,sha256=sn4sjAYXRIfiSuF_1raDISrRT97w8i3YFk1oGNh-cug,14
|
|
28
|
+
gou2tool-0.2.11.dist-info/RECORD,,
|
|
@@ -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.
|
goutool/__init__.py
ADDED
goutool/util/__init__.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""
|
|
2
|
+
工具模块初始化文件
|
|
3
|
+
|
|
4
|
+
提供各种通用工具类和函数,包括地址处理、数据库操作、邮件发送、环境配置、
|
|
5
|
+
文件操作、ID生成、路径处理、手机号处理、SQL处理、字符串处理、树形结构处理和WebHook处理等。
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
# 地址处理工具
|
|
9
|
+
from .address_util import AddressUtil
|
|
10
|
+
# 数据库模板工具
|
|
11
|
+
from .db_template_util import DBTemplateUtil
|
|
12
|
+
# 邮件发送工具
|
|
13
|
+
from .email_util import EmailUtil
|
|
14
|
+
# 环境变量工具
|
|
15
|
+
from .env_util import EnvUtil
|
|
16
|
+
# 文件操作工具
|
|
17
|
+
from .file_util import FileUtil
|
|
18
|
+
# ID生成工具
|
|
19
|
+
from .id_util import IdUtil
|
|
20
|
+
# 路径处理工具
|
|
21
|
+
from .path_util import PathUtil
|
|
22
|
+
# 手机号处理工具
|
|
23
|
+
from .phone_util import PhoneUtil
|
|
24
|
+
# SQL处理工具
|
|
25
|
+
from .sql_util import SQLUtil
|
|
26
|
+
# 字符串处理工具
|
|
27
|
+
from .str_util import StrUtil
|
|
28
|
+
# 树形结构处理工具
|
|
29
|
+
from .tree_util import TreeUtil
|
|
30
|
+
# WebHook处理工具
|
|
31
|
+
from .web_hook_util import WebHookUtil
|
|
32
|
+
|
|
33
|
+
# 定义公共接口
|
|
34
|
+
__all__ = [
|
|
35
|
+
'AddressUtil',
|
|
36
|
+
'DBTemplateUtil',
|
|
37
|
+
'EmailUtil',
|
|
38
|
+
'EnvUtil',
|
|
39
|
+
'FileUtil',
|
|
40
|
+
'IdUtil',
|
|
41
|
+
'PathUtil',
|
|
42
|
+
'PhoneUtil',
|
|
43
|
+
'SQLUtil',
|
|
44
|
+
'StrUtil',
|
|
45
|
+
'TreeUtil',
|
|
46
|
+
'WebHookUtil',
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
# 模块版本信息
|
|
50
|
+
__author__ = "wl4837"
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import json
|
|
3
|
+
|
|
4
|
+
class AddressUtil:
|
|
5
|
+
|
|
6
|
+
@staticmethod
|
|
7
|
+
def parse(address):
|
|
8
|
+
"""
|
|
9
|
+
解析地址字符串,返回结构化地址信息
|
|
10
|
+
|
|
11
|
+
Args:
|
|
12
|
+
address (str): 完整地址字符串
|
|
13
|
+
|
|
14
|
+
Returns:
|
|
15
|
+
dict: 包含省、市、区等信息的字典
|
|
16
|
+
"""
|
|
17
|
+
if not address:
|
|
18
|
+
return {}
|
|
19
|
+
|
|
20
|
+
# 初始化结果字典
|
|
21
|
+
result = {
|
|
22
|
+
"province": "",
|
|
23
|
+
"city": "",
|
|
24
|
+
"district": "",
|
|
25
|
+
"street": "",
|
|
26
|
+
"detail": ""
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
# 获取省市区数据用于匹配
|
|
30
|
+
province_city_data = AddressUtil.get_province_city_district_tree()
|
|
31
|
+
|
|
32
|
+
# 简化的地址解析逻辑(实际应用中可能需要更复杂的匹配规则)
|
|
33
|
+
# 1. 提取省份信息
|
|
34
|
+
for province_data in province_city_data:
|
|
35
|
+
province_name = province_data.get("province", "")
|
|
36
|
+
if province_name and province_name in address:
|
|
37
|
+
result["province"] = province_name
|
|
38
|
+
# 从地址中移除已匹配的省份信息
|
|
39
|
+
address = address.replace(province_name, "", 1)
|
|
40
|
+
break
|
|
41
|
+
|
|
42
|
+
# 2. 提取城市信息
|
|
43
|
+
for province_data in province_city_data:
|
|
44
|
+
if "children" in province_data:
|
|
45
|
+
for city_data in province_data["children"]:
|
|
46
|
+
city_name = city_data.get("city", "")
|
|
47
|
+
if city_name and city_name in address:
|
|
48
|
+
result["city"] = city_name
|
|
49
|
+
# 从地址中移除已匹配的城市信息
|
|
50
|
+
address = address.replace(city_name, "", 1)
|
|
51
|
+
break
|
|
52
|
+
|
|
53
|
+
# 3. 提取区域信息
|
|
54
|
+
for province_data in province_city_data:
|
|
55
|
+
if "children" in province_data:
|
|
56
|
+
for city_data in province_data["children"]:
|
|
57
|
+
if "children" in city_data:
|
|
58
|
+
for district_data in city_data["children"]:
|
|
59
|
+
district_name = district_data.get("district", "")
|
|
60
|
+
if district_name and district_name in address:
|
|
61
|
+
result["district"] = district_name
|
|
62
|
+
# 从地址中移除已匹配的区域信息
|
|
63
|
+
address = address.replace(district_name, "", 1)
|
|
64
|
+
break
|
|
65
|
+
|
|
66
|
+
# 4. 剩余部分作为街道和详细地址
|
|
67
|
+
result["street"] = address.strip()
|
|
68
|
+
result["detail"] = address.strip()
|
|
69
|
+
|
|
70
|
+
return result
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@staticmethod
|
|
74
|
+
def has_province_city_district():
|
|
75
|
+
"""
|
|
76
|
+
判断地址是否包含省市区信息
|
|
77
|
+
|
|
78
|
+
Returns:
|
|
79
|
+
bool: 如果包含省市区信息返回True,否则返回False
|
|
80
|
+
"""
|
|
81
|
+
# TODO: 实现判断逻辑
|
|
82
|
+
return False
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
@staticmethod
|
|
86
|
+
def has_province_city():
|
|
87
|
+
"""
|
|
88
|
+
判断地址是否包含省市信息
|
|
89
|
+
|
|
90
|
+
Returns:
|
|
91
|
+
bool: 如果包含省市信息返回True,否则返回False
|
|
92
|
+
"""
|
|
93
|
+
# TODO: 实现判断逻辑
|
|
94
|
+
return False
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
@staticmethod
|
|
98
|
+
def get_province_city_district_tree():
|
|
99
|
+
"""
|
|
100
|
+
获取省市区三级树形结构数据
|
|
101
|
+
|
|
102
|
+
Returns:
|
|
103
|
+
list: 省市区树形结构数据
|
|
104
|
+
"""
|
|
105
|
+
# TODO: 实现获取省市区树形结构的逻辑
|
|
106
|
+
# 获取当前脚本所在目录
|
|
107
|
+
current_dir = os.path.dirname(__file__)
|
|
108
|
+
# 构建数据文件路径
|
|
109
|
+
data_file_path = os.path.join(current_dir, 'data', 'pca-code.json')
|
|
110
|
+
|
|
111
|
+
# 读取JSON文件
|
|
112
|
+
with open(data_file_path, 'r', encoding='utf-8') as file:
|
|
113
|
+
data = json.load(file)
|
|
114
|
+
|
|
115
|
+
return data
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
@staticmethod
|
|
119
|
+
def get_province_city_district_street_tree():
|
|
120
|
+
"""
|
|
121
|
+
获取省市区街道四级树形结构数据
|
|
122
|
+
|
|
123
|
+
Returns:
|
|
124
|
+
list: 省市区街道树形结构数据
|
|
125
|
+
"""
|
|
126
|
+
# TODO: 实现获取省市区街道树形结构的逻辑
|
|
127
|
+
# 获取当前脚本所在目录
|
|
128
|
+
current_dir = os.path.dirname(__file__)
|
|
129
|
+
# 构建数据文件路径
|
|
130
|
+
data_file_path = os.path.join(current_dir, 'data', 'pcas-code.json')
|
|
131
|
+
|
|
132
|
+
# 读取JSON文件
|
|
133
|
+
with open(data_file_path, 'r', encoding='utf-8') as file:
|
|
134
|
+
data = json.load(file)
|
|
135
|
+
|
|
136
|
+
return data
|
|
File without changes
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import re
|
|
2
|
+
|
|
3
|
+
class DBTemplateUtil:
|
|
4
|
+
|
|
5
|
+
@staticmethod
|
|
6
|
+
def query_for_one(sql, params=None, connection=None):
|
|
7
|
+
"""
|
|
8
|
+
执行SQL查询并返回单个结果的字典格式
|
|
9
|
+
|
|
10
|
+
Args:
|
|
11
|
+
sql (str): SQL查询语句
|
|
12
|
+
connection: 数据库连接对象
|
|
13
|
+
params (tuple|dict|None): SQL参数,支持元组或字典格式
|
|
14
|
+
|
|
15
|
+
Returns:
|
|
16
|
+
dict|None: 查询结果的字典表示,如果没有结果则返回None
|
|
17
|
+
"""
|
|
18
|
+
cursor = connection.cursor(dictionary=True)
|
|
19
|
+
try:
|
|
20
|
+
if params:
|
|
21
|
+
cursor.execute(sql, params)
|
|
22
|
+
else:
|
|
23
|
+
cursor.execute(sql)
|
|
24
|
+
return cursor.fetchone()
|
|
25
|
+
except Exception as e:
|
|
26
|
+
print(f"查询执行出错: {e}")
|
|
27
|
+
return None
|
|
28
|
+
finally:
|
|
29
|
+
cursor.close()
|
|
30
|
+
|
|
31
|
+
@staticmethod
|
|
32
|
+
def query_for_list(sql, params=None, connection=None):
|
|
33
|
+
"""
|
|
34
|
+
执行SQL查询并返回所有结果的字典列表格式
|
|
35
|
+
|
|
36
|
+
Args:
|
|
37
|
+
sql (str): SQL查询语句
|
|
38
|
+
params (tuple|dict|None): SQL参数,支持元组或字典格式
|
|
39
|
+
connection: 数据库连接对象
|
|
40
|
+
|
|
41
|
+
Returns:
|
|
42
|
+
list: 查询结果的字典列表,每个元素是一行数据的字典表示
|
|
43
|
+
"""
|
|
44
|
+
cursor = connection.cursor(dictionary=True)
|
|
45
|
+
try:
|
|
46
|
+
if params:
|
|
47
|
+
cursor.execute(sql, params)
|
|
48
|
+
else:
|
|
49
|
+
cursor.execute(sql)
|
|
50
|
+
return cursor.fetchall()
|
|
51
|
+
except Exception as e:
|
|
52
|
+
print(f"查询执行出错: {e}")
|
|
53
|
+
return []
|
|
54
|
+
finally:
|
|
55
|
+
cursor.close()
|
|
56
|
+
|
|
57
|
+
@staticmethod
|
|
58
|
+
def execute(sql, params=None, connection=None):
|
|
59
|
+
"""
|
|
60
|
+
执行单条SQL增删改操作
|
|
61
|
+
|
|
62
|
+
Args:
|
|
63
|
+
sql (str): SQL语句
|
|
64
|
+
params (tuple|dict|None): SQL参数,支持元组或字典格式
|
|
65
|
+
connection: 数据库连接对象
|
|
66
|
+
|
|
67
|
+
Returns:
|
|
68
|
+
int: 受影响的行数
|
|
69
|
+
"""
|
|
70
|
+
cursor = connection.cursor(dictionary=True)
|
|
71
|
+
try:
|
|
72
|
+
if params:
|
|
73
|
+
cursor.execute(sql, params)
|
|
74
|
+
else:
|
|
75
|
+
cursor.execute(sql)
|
|
76
|
+
|
|
77
|
+
# 提交事务
|
|
78
|
+
connection.commit()
|
|
79
|
+
# 返回受影响的行数
|
|
80
|
+
return cursor.rowcount
|
|
81
|
+
except Exception as e:
|
|
82
|
+
# 发生异常时回滚事务
|
|
83
|
+
connection.rollback()
|
|
84
|
+
print(f"执行出错: {e}")
|
|
85
|
+
return 0
|
|
86
|
+
finally:
|
|
87
|
+
cursor.close()
|
|
88
|
+
|
|
89
|
+
@staticmethod
|
|
90
|
+
def execute_batch(sql, params_list=None, connection=None):
|
|
91
|
+
"""
|
|
92
|
+
批量执行SQL增删改操作
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
sql (str): SQL语句模板
|
|
96
|
+
params_list (list): 参数列表,每个元素是tuple或dict格式的参数
|
|
97
|
+
connection: 数据库连接对象
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
int: 受影响的行数总计
|
|
101
|
+
"""
|
|
102
|
+
cursor = connection.cursor(dictionary=True)
|
|
103
|
+
try:
|
|
104
|
+
if params_list:
|
|
105
|
+
# 批量执行带参数的SQL语句
|
|
106
|
+
cursor.executemany(sql, params_list)
|
|
107
|
+
else:
|
|
108
|
+
# 单次执行不带参数的SQL语句
|
|
109
|
+
cursor.execute(sql)
|
|
110
|
+
|
|
111
|
+
# 提交事务
|
|
112
|
+
connection.commit()
|
|
113
|
+
# 返回受影响的行数
|
|
114
|
+
return cursor.rowcount
|
|
115
|
+
except Exception as e:
|
|
116
|
+
# 发生异常时回滚事务
|
|
117
|
+
connection.rollback()
|
|
118
|
+
print(f"批量执行出错: {e}")
|
|
119
|
+
return 0
|
|
120
|
+
finally:
|
|
121
|
+
cursor.close()
|
goutool/util/env_util.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import configparser
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class EnvUtil:
|
|
6
|
+
|
|
7
|
+
@staticmethod
|
|
8
|
+
def get(name, default=None, group='DEFAULT', env_file_path=None):
|
|
9
|
+
config = configparser.ConfigParser()
|
|
10
|
+
|
|
11
|
+
with open(env_file_path, 'r', encoding='utf-8') as f:
|
|
12
|
+
content = f.read()
|
|
13
|
+
|
|
14
|
+
if not content.strip().startswith('['):
|
|
15
|
+
content = '[DEFAULT]\n' + content
|
|
16
|
+
|
|
17
|
+
config.read_string(content)
|
|
18
|
+
|
|
19
|
+
return config.get(group, name, fallback=default)
|