ezKit 1.11.3__py3-none-any.whl → 1.11.4__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.
- ezKit/bottle_extensions.py +3 -2
- ezKit/sendemail.py +30 -29
- ezKit/utils.py +11 -10
- ezKit/xftp.py +9 -1
- {ezKit-1.11.3.dist-info → ezKit-1.11.4.dist-info}/METADATA +1 -1
- {ezKit-1.11.3.dist-info → ezKit-1.11.4.dist-info}/RECORD +9 -9
- {ezKit-1.11.3.dist-info → ezKit-1.11.4.dist-info}/LICENSE +0 -0
- {ezKit-1.11.3.dist-info → ezKit-1.11.4.dist-info}/WHEEL +0 -0
- {ezKit-1.11.3.dist-info → ezKit-1.11.4.dist-info}/top_level.txt +0 -0
ezKit/bottle_extensions.py
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
"""Bottle Extensions"""
|
2
|
-
from
|
2
|
+
from types import FunctionType
|
3
|
+
from typing import Any
|
3
4
|
|
4
5
|
from . import bottle, utils
|
5
6
|
|
6
7
|
|
7
|
-
def enable_cors(fn:
|
8
|
+
def enable_cors(fn: FunctionType) -> Any | None:
|
8
9
|
"""Bottle CORS"""
|
9
10
|
# 参考文档:
|
10
11
|
# - https://stackoverflow.com/a/17262900
|
ezKit/sendemail.py
CHANGED
@@ -6,7 +6,7 @@ from email.mime.image import MIMEImage
|
|
6
6
|
from email.mime.multipart import MIMEMultipart
|
7
7
|
from email.mime.text import MIMEText
|
8
8
|
from email.utils import formataddr, parseaddr
|
9
|
-
from typing import
|
9
|
+
from typing import TypedDict, cast
|
10
10
|
|
11
11
|
from loguru import logger
|
12
12
|
|
@@ -28,9 +28,10 @@ class TypedSender(TypedDict):
|
|
28
28
|
class TypedBody(TypedDict, total=False):
|
29
29
|
"""body type"""
|
30
30
|
content: str
|
31
|
-
type:
|
31
|
+
type: str | None # "plain", "html", or "file"
|
32
32
|
|
33
33
|
def format_parse(s):
|
34
|
+
"""格式化邮件地址"""
|
34
35
|
_name, _addr = parseaddr(s)
|
35
36
|
return formataddr((Header(_name, "utf-8").encode(), _addr))
|
36
37
|
|
@@ -42,33 +43,33 @@ def sendemail(
|
|
42
43
|
body: TypedBody,
|
43
44
|
images: None | list = None
|
44
45
|
) -> bool:
|
45
|
-
"""
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
46
|
+
"""发送邮件"""
|
47
|
+
|
48
|
+
# smtp SMTP信息
|
49
|
+
#
|
50
|
+
# server SMTP地址
|
51
|
+
# port SMTP端口
|
52
|
+
# tls 是否使用TLS
|
53
|
+
#
|
54
|
+
# sender 发件人信息
|
55
|
+
#
|
56
|
+
# name 发件人名称
|
57
|
+
# address 发件人邮箱地址
|
58
|
+
# password 发件人邮箱密码(SMTP)
|
59
|
+
#
|
60
|
+
# recipients 收件人(或列表)
|
61
|
+
#
|
62
|
+
# subject 邮件主题
|
63
|
+
#
|
64
|
+
# body 邮件主体
|
65
|
+
#
|
66
|
+
# content 内容
|
67
|
+
# type 类型 (默认 plain, 或者 file, 或者 html)
|
68
|
+
#
|
69
|
+
# images 图片列表(可选)
|
70
|
+
#
|
71
|
+
# cid 图片CID
|
72
|
+
# path 图片路径
|
72
73
|
|
73
74
|
logger.success("sendemail start")
|
74
75
|
|
ezKit/utils.py
CHANGED
@@ -13,7 +13,8 @@ from multiprocessing import Pool
|
|
13
13
|
from multiprocessing.pool import ThreadPool
|
14
14
|
from pathlib import Path
|
15
15
|
from shutil import rmtree
|
16
|
-
from
|
16
|
+
from types import FunctionType
|
17
|
+
from typing import Any
|
17
18
|
from urllib.parse import ParseResult, urlparse
|
18
19
|
from uuid import uuid4
|
19
20
|
|
@@ -23,7 +24,7 @@ from loguru import logger
|
|
23
24
|
|
24
25
|
|
25
26
|
# None Type
|
26
|
-
|
27
|
+
# from types import NoneType
|
27
28
|
|
28
29
|
|
29
30
|
# --------------------------------------------------------------------------------------------------
|
@@ -741,7 +742,7 @@ def parent_dir(
|
|
741
742
|
# --------------------------------------------------------------------------------------------------
|
742
743
|
|
743
744
|
|
744
|
-
def retry(func:
|
745
|
+
def retry(func: FunctionType, times: int = 3, **kwargs):
|
745
746
|
"""重试"""
|
746
747
|
|
747
748
|
# 函数传递参数: https://stackoverflow.com/a/803632
|
@@ -1005,9 +1006,9 @@ def shell(
|
|
1005
1006
|
command: str,
|
1006
1007
|
isfile: bool = False,
|
1007
1008
|
sh_shell: str = "/bin/bash",
|
1008
|
-
sh_option:
|
1009
|
+
sh_option: str | None = None,
|
1009
1010
|
**kwargs
|
1010
|
-
) ->
|
1011
|
+
) -> subprocess.CompletedProcess | None:
|
1011
1012
|
"""执行 Shell 命令 或 脚本"""
|
1012
1013
|
|
1013
1014
|
# :param command: 需要执行的命令
|
@@ -1100,7 +1101,7 @@ def json_sort(
|
|
1100
1101
|
|
1101
1102
|
|
1102
1103
|
def delete_files(
|
1103
|
-
files:
|
1104
|
+
files: str | list
|
1104
1105
|
) -> bool:
|
1105
1106
|
"""删除文件"""
|
1106
1107
|
try:
|
@@ -1132,7 +1133,7 @@ def delete_files(
|
|
1132
1133
|
|
1133
1134
|
|
1134
1135
|
def delete_directory(
|
1135
|
-
directory:
|
1136
|
+
directory: str | list,
|
1136
1137
|
) -> bool:
|
1137
1138
|
"""
|
1138
1139
|
delete directory
|
@@ -1190,12 +1191,12 @@ def delete_directory(
|
|
1190
1191
|
|
1191
1192
|
|
1192
1193
|
def processor(
|
1193
|
-
process_func:
|
1194
|
-
process_data:
|
1194
|
+
process_func: FunctionType,
|
1195
|
+
process_data: list[Any],
|
1195
1196
|
process_num: int = 2,
|
1196
1197
|
thread: bool = False,
|
1197
1198
|
**kwargs
|
1198
|
-
) ->
|
1199
|
+
) -> list | bool:
|
1199
1200
|
"""使用多线程或多进程对数据进行并行处理"""
|
1200
1201
|
|
1201
1202
|
# :param process_func: 处理函数
|
ezKit/xftp.py
CHANGED
@@ -10,7 +10,15 @@ from loguru import logger
|
|
10
10
|
class XFTP:
|
11
11
|
"""XFTP"""
|
12
12
|
|
13
|
-
def __init__(
|
13
|
+
def __init__(
|
14
|
+
self,
|
15
|
+
host: str = "127.0.0.1",
|
16
|
+
port: int = 21,
|
17
|
+
username: str = "anonymous",
|
18
|
+
password: str = "",
|
19
|
+
encoding: str = "UTF-8",
|
20
|
+
debuglevel: int = 0
|
21
|
+
):
|
14
22
|
"""Initiation"""
|
15
23
|
self.ftp = FTP()
|
16
24
|
self.ftp.set_debuglevel(debuglevel)
|
@@ -1,19 +1,19 @@
|
|
1
1
|
ezKit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
2
|
ezKit/_file.py,sha256=0qRZhwYuagTgTGrhm-tzAMvEQT4HTJA_xZKqF2bo0ho,1207
|
3
3
|
ezKit/bottle.py,sha256=usKK1wVaZw4_D-4VwMYmOIc8jtz4TrpM30nck59HMFw,180178
|
4
|
-
ezKit/bottle_extensions.py,sha256=
|
4
|
+
ezKit/bottle_extensions.py,sha256=CwXKxVKxxtbyfeeOSp2xODUqJBo7ro2C88H9sUOVDJI,1161
|
5
5
|
ezKit/cipher.py,sha256=0T_StbjiNI4zgrjVgcfU-ffKgu1waBA9UDudAnqFcNM,2896
|
6
6
|
ezKit/database.py,sha256=r5YNoEzeOeVTlEWI99xXtHTmPZ73_DopS8DTzZk8Lts,12432
|
7
7
|
ezKit/http.py,sha256=ysXzqXFi9zmuVKINbYGwmf9Q5xDVW_DZWrSh6HSVq8M,1800
|
8
8
|
ezKit/mongo.py,sha256=l3jRMmoGrTm16OG4daSCn0JLU1nbYAmTtHokwjLXzoA,2390
|
9
9
|
ezKit/qywx.py,sha256=dGChIIf2V81MwufcPn6hwgSenPuxqK994KRH7ECT-CM,10387
|
10
10
|
ezKit/redis.py,sha256=tdiqfizPYQQTIUumkJGUJsJVlv0zVTSTYGQN0QutYs4,1963
|
11
|
-
ezKit/sendemail.py,sha256=
|
11
|
+
ezKit/sendemail.py,sha256=47JTDFoLJKi0YtF3RAp9nFfo0ko2jlde3R_C1wr2E2w,7397
|
12
12
|
ezKit/token.py,sha256=HKREyZj_T2S8-aFoFIrBXTaCKExQq4zE66OHXhGHqQg,1750
|
13
|
-
ezKit/utils.py,sha256=
|
14
|
-
ezKit/xftp.py,sha256=
|
15
|
-
ezKit-1.11.
|
16
|
-
ezKit-1.11.
|
17
|
-
ezKit-1.11.
|
18
|
-
ezKit-1.11.
|
19
|
-
ezKit-1.11.
|
13
|
+
ezKit/utils.py,sha256=cIoiqZXJkbdo0FtBEExOgA8jvyzjp1Yq0kvTFTc1kjs,42486
|
14
|
+
ezKit/xftp.py,sha256=izUH9pLH_AzgR3c0g8xSfhLn7LQ9EDcTst3LFjTM6hU,7878
|
15
|
+
ezKit-1.11.4.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
16
|
+
ezKit-1.11.4.dist-info/METADATA,sha256=amy4gY1s9zrVATfy2KKD0EI2xuPfTBXlBOV_1SM324g,191
|
17
|
+
ezKit-1.11.4.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
18
|
+
ezKit-1.11.4.dist-info/top_level.txt,sha256=aYLB_1WODsqNTsTFWcKP-BN0KCTKcV-HZJ4zlHkCFw8,6
|
19
|
+
ezKit-1.11.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|