ezKit 1.11.2__tar.gz → 1.11.4__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ezKit
3
- Version: 1.11.2
3
+ Version: 1.11.4
4
4
  Summary: Easy Kit
5
5
  Author: septvean
6
6
  Author-email: septvean@gmail.com
@@ -1,10 +1,11 @@
1
1
  """Bottle Extensions"""
2
- from typing import Callable
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: Callable) -> Callable:
8
+ def enable_cors(fn: FunctionType) -> Any | None:
8
9
  """Bottle CORS"""
9
10
  # 参考文档:
10
11
  # - https://stackoverflow.com/a/17262900
@@ -60,8 +60,9 @@ class QYWX:
60
60
  # Token: https://developer.work.weixin.qq.com/document/path/90665#access-token
61
61
  access_token: str = ""
62
62
 
63
- def __init__(self, work_id: str, agent_id: str, agent_secret: str):
63
+ def __init__(self, work_id: str, agent_id: str, agent_secret: str, api_prefix: str = "https://qyapi.weixin.qq.com"):
64
64
  """Initiation"""
65
+ self.api_prefix = api_prefix
65
66
  self.work_id = work_id
66
67
  self.agent_id = agent_id
67
68
  self.agent_secret = agent_secret
@@ -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 Optional, TypedDict, cast
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: Optional[str]
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
- smtp SMTP信息
47
-
48
- server SMTP地址
49
- port SMTP端口
50
- tls 是否使用TLS
51
-
52
- sender 发件人信息
53
-
54
- name 发件人名称
55
- address 发件人邮箱地址
56
- password 发件人邮箱密码(SMTP)
57
-
58
- recipients 收件人(或列表)
59
-
60
- subject 邮件主题
61
-
62
- body 邮件主体
63
-
64
- content 内容
65
- type 类型 (默认 plain, 或者 file, 或者 html)
66
-
67
- images 图片列表(可选)
68
-
69
- cid 图片CID
70
- path 图片路径
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
 
@@ -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 typing import Any, Callable, List, Optional, Union
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
- NoneType = type(None)
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: Callable, times: int = 3, **kwargs):
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: Optional[str] = None,
1009
+ sh_option: str | None = None,
1009
1010
  **kwargs
1010
- ) -> Optional[subprocess.CompletedProcess]:
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: Union[str, List]
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: Union[str, List]
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: Callable,
1194
- process_data: List[Any],
1194
+ process_func: FunctionType,
1195
+ process_data: list[Any],
1195
1196
  process_num: int = 2,
1196
1197
  thread: bool = False,
1197
1198
  **kwargs
1198
- ) -> Union[List[Any], bool]:
1199
+ ) -> list | bool:
1199
1200
  """使用多线程或多进程对数据进行并行处理"""
1200
1201
 
1201
1202
  # :param process_func: 处理函数
@@ -10,7 +10,15 @@ from loguru import logger
10
10
  class XFTP:
11
11
  """XFTP"""
12
12
 
13
- def __init__(self, host="127.0.0.1", port=21, username="anonymous", password="", encoding="UTF-8", debuglevel=0):
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,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ezKit
3
- Version: 1.11.2
3
+ Version: 1.11.4
4
4
  Summary: Easy Kit
5
5
  Author: septvean
6
6
  Author-email: septvean@gmail.com
@@ -3,7 +3,7 @@ from setuptools import find_packages, setup
3
3
 
4
4
  setup(
5
5
  name='ezKit',
6
- version='1.11.2',
6
+ version='1.11.4',
7
7
  author='septvean',
8
8
  author_email='septvean@gmail.com',
9
9
  description='Easy Kit',
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes