xtn-tools-pro 1.0.0.0.5__tar.gz → 1.0.0.0.6__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.
- {xtn-tools-pro-1.0.0.0.5/xtn_tools_pro.egg-info → xtn-tools-pro-1.0.0.0.6}/PKG-INFO +1 -1
- {xtn-tools-pro-1.0.0.0.5 → xtn-tools-pro-1.0.0.0.6}/setup.py +1 -1
- {xtn-tools-pro-1.0.0.0.5 → xtn-tools-pro-1.0.0.0.6}/xtn_tools_pro/db/MongoDB.py +2 -2
- {xtn-tools-pro-1.0.0.0.5 → xtn-tools-pro-1.0.0.0.6}/xtn_tools_pro/proxy/XiaoXiangProxy.py +1 -1
- xtn-tools-pro-1.0.0.0.6/xtn_tools_pro/tools.py +23 -0
- xtn-tools-pro-1.0.0.0.6/xtn_tools_pro/utils/crypto.py +87 -0
- xtn-tools-pro-1.0.0.0.5/xtn_tools_pro/tools_flie.py → xtn-tools-pro-1.0.0.0.6/xtn_tools_pro/utils/file_utils.py +4 -3
- xtn-tools-pro-1.0.0.0.6/xtn_tools_pro/utils/helpers.py +123 -0
- {xtn-tools-pro-1.0.0.0.5 → xtn-tools-pro-1.0.0.0.6}/xtn_tools_pro/utils/log.py +1 -2
- {xtn-tools-pro-1.0.0.0.5 → xtn-tools-pro-1.0.0.0.6}/xtn_tools_pro/utils/sql.py +1 -1
- xtn-tools-pro-1.0.0.0.5/xtn_tools_pro/tools_time.py → xtn-tools-pro-1.0.0.0.6/xtn_tools_pro/utils/time_utils.py +4 -3
- {xtn-tools-pro-1.0.0.0.5 → xtn-tools-pro-1.0.0.0.6/xtn_tools_pro.egg-info}/PKG-INFO +1 -1
- {xtn-tools-pro-1.0.0.0.5 → xtn-tools-pro-1.0.0.0.6}/xtn_tools_pro.egg-info/SOURCES.txt +5 -3
- xtn-tools-pro-1.0.0.0.5/xtn_tools_pro/tools.py +0 -176
- {xtn-tools-pro-1.0.0.0.5 → xtn-tools-pro-1.0.0.0.6}/LICENSE +0 -0
- {xtn-tools-pro-1.0.0.0.5 → xtn-tools-pro-1.0.0.0.6}/README.md +0 -0
- {xtn-tools-pro-1.0.0.0.5 → xtn-tools-pro-1.0.0.0.6}/setup.cfg +0 -0
- {xtn-tools-pro-1.0.0.0.5 → xtn-tools-pro-1.0.0.0.6}/xtn_tools_pro/__init__.py +0 -0
- {xtn-tools-pro-1.0.0.0.5 → xtn-tools-pro-1.0.0.0.6}/xtn_tools_pro/db/MysqlDB.py +0 -0
- {xtn-tools-pro-1.0.0.0.5 → xtn-tools-pro-1.0.0.0.6}/xtn_tools_pro/db/RedisDB.py +0 -0
- {xtn-tools-pro-1.0.0.0.5 → xtn-tools-pro-1.0.0.0.6}/xtn_tools_pro/db/__init__.py +0 -0
- {xtn-tools-pro-1.0.0.0.5 → xtn-tools-pro-1.0.0.0.6}/xtn_tools_pro/proxy/__init__.py +0 -0
- {xtn-tools-pro-1.0.0.0.5 → xtn-tools-pro-1.0.0.0.6}/xtn_tools_pro/utils/__init__.py +0 -0
- {xtn-tools-pro-1.0.0.0.5 → xtn-tools-pro-1.0.0.0.6}/xtn_tools_pro/utils/retry.py +0 -0
- {xtn-tools-pro-1.0.0.0.5 → xtn-tools-pro-1.0.0.0.6}/xtn_tools_pro.egg-info/dependency_links.txt +0 -0
- {xtn-tools-pro-1.0.0.0.5 → xtn-tools-pro-1.0.0.0.6}/xtn_tools_pro.egg-info/requires.txt +0 -0
- {xtn-tools-pro-1.0.0.0.5 → xtn-tools-pro-1.0.0.0.6}/xtn_tools_pro.egg-info/top_level.txt +0 -0
@@ -8,11 +8,11 @@
|
|
8
8
|
# --------------------------------------------------------------------------------------------------
|
9
9
|
# 2024/4/17 xiatn V00.01.000 新建
|
10
10
|
# --------------------------------------------------------------------------------------------------
|
11
|
-
from xtn_tools_pro.tools_time import *
|
12
11
|
from urllib import parse
|
12
|
+
from typing import List, Dict, Optional
|
13
|
+
from xtn_tools_pro.utils.time_utils import *
|
13
14
|
from pymongo import MongoClient as _MongoClient
|
14
15
|
from pymongo.database import Database as _Database
|
15
|
-
from typing import List, Dict, Optional
|
16
16
|
from pymongo.collection import Collection as _Collection
|
17
17
|
from pymongo.errors import DuplicateKeyError, BulkWriteError
|
18
18
|
|
@@ -10,7 +10,7 @@
|
|
10
10
|
# --------------------------------------------------------------------------------------------------
|
11
11
|
import requests, time, random
|
12
12
|
from xtn_tools_pro.db.RedisDB import RedisDBPro
|
13
|
-
from xtn_tools_pro.
|
13
|
+
from xtn_tools_pro.utils.time_utils import get_time_now_timestamp, get_time_now_day59_timestamp
|
14
14
|
|
15
15
|
import warnings
|
16
16
|
from urllib3.exceptions import InsecureRequestWarning
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
# 说明:
|
5
|
+
# tools
|
6
|
+
# History:
|
7
|
+
# Date Author Version Modification
|
8
|
+
# --------------------------------------------------------------------------------------------------
|
9
|
+
# 2024/4/17 xiatn V00.01.000 新建
|
10
|
+
# --------------------------------------------------------------------------------------------------
|
11
|
+
|
12
|
+
|
13
|
+
def split_image(img):
|
14
|
+
"""
|
15
|
+
切割图片
|
16
|
+
:param img:
|
17
|
+
:return:
|
18
|
+
"""
|
19
|
+
pass
|
20
|
+
|
21
|
+
|
22
|
+
if __name__ == '__main__':
|
23
|
+
pass
|
@@ -0,0 +1,87 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
# 说明:
|
5
|
+
# 加解密、编解码
|
6
|
+
# History:
|
7
|
+
# Date Author Version Modification
|
8
|
+
# --------------------------------------------------------------------------------------------------
|
9
|
+
# 2024/5/13 xiatn V00.01.000 新建
|
10
|
+
# --------------------------------------------------------------------------------------------------
|
11
|
+
import hashlib
|
12
|
+
|
13
|
+
|
14
|
+
def get_md5_32(s, is_upper=False):
|
15
|
+
"""
|
16
|
+
获取文本的md5值 32位
|
17
|
+
:param s: 文本
|
18
|
+
:param is_upper: 是否转大写 默认False
|
19
|
+
:return:
|
20
|
+
"""
|
21
|
+
# s.encode()#变成bytes类型才能加密
|
22
|
+
m = hashlib.md5(s.encode()) # 长度是32
|
23
|
+
if is_upper:
|
24
|
+
return m.hexdigest().upper()
|
25
|
+
return m.hexdigest()
|
26
|
+
|
27
|
+
|
28
|
+
def get_md5_16(s, is_upper=False):
|
29
|
+
"""
|
30
|
+
获取文本的md5值 16位
|
31
|
+
:param s: 文本
|
32
|
+
:param is_upper: 是否转大写 默认False
|
33
|
+
:return:
|
34
|
+
"""
|
35
|
+
result = get_md5_32(s, is_upper)
|
36
|
+
return result[8:24]
|
37
|
+
|
38
|
+
|
39
|
+
def get_binary_content_md5_32(content, is_upper=False):
|
40
|
+
"""
|
41
|
+
二进制内容md5 例如图片
|
42
|
+
:param content: 二进制内容
|
43
|
+
:param is_upper: 是否转大写 默认False
|
44
|
+
:return:
|
45
|
+
"""
|
46
|
+
md5_hash = hashlib.md5(content)
|
47
|
+
md5_hexdigest = md5_hash.hexdigest()
|
48
|
+
if is_upper:
|
49
|
+
return md5_hexdigest.upper()
|
50
|
+
return md5_hexdigest
|
51
|
+
|
52
|
+
|
53
|
+
def get_binary_content_md5_16(content, is_upper=False):
|
54
|
+
"""
|
55
|
+
二进制内容md5 例如图片
|
56
|
+
:param content: 二进制内容
|
57
|
+
:param is_upper: 是否转大写 默认False
|
58
|
+
:return:
|
59
|
+
"""
|
60
|
+
result = get_binary_content_md5_32(content, is_upper)
|
61
|
+
return result[8:24]
|
62
|
+
|
63
|
+
|
64
|
+
def get_file_md5_32(file_path, is_upper=False):
|
65
|
+
"""
|
66
|
+
获取文件md5值
|
67
|
+
:param file_path: 文件路径
|
68
|
+
:param is_upper: 是否转大写 默认False
|
69
|
+
:return:
|
70
|
+
"""
|
71
|
+
with open(file_path, 'rb') as file:
|
72
|
+
data = file.read()
|
73
|
+
md5_hash = hashlib.md5(data).hexdigest()
|
74
|
+
if is_upper:
|
75
|
+
return md5_hash.upper()
|
76
|
+
return md5_hash
|
77
|
+
|
78
|
+
|
79
|
+
def get_file_md5_16(file_path, is_upper=False):
|
80
|
+
"""
|
81
|
+
获取文件md5值
|
82
|
+
:param file_path: 文件路径
|
83
|
+
:param is_upper: 是否转大写 默认False
|
84
|
+
:return:
|
85
|
+
"""
|
86
|
+
result = get_file_md5_32(file_path, is_upper)
|
87
|
+
return result[8:24]
|
@@ -2,13 +2,14 @@
|
|
2
2
|
# -*- coding: utf-8 -*-
|
3
3
|
|
4
4
|
# 说明:
|
5
|
-
#
|
5
|
+
# 文件
|
6
6
|
# History:
|
7
7
|
# Date Author Version Modification
|
8
8
|
# --------------------------------------------------------------------------------------------------
|
9
|
-
# 2024/
|
9
|
+
# 2024/5/13 xiatn V00.01.000 新建
|
10
10
|
# --------------------------------------------------------------------------------------------------
|
11
|
-
import os
|
11
|
+
import os
|
12
|
+
import re
|
12
13
|
|
13
14
|
|
14
15
|
def get_file_extension(file_name):
|
@@ -0,0 +1,123 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
# 说明:
|
5
|
+
# 杂七杂八
|
6
|
+
# History:
|
7
|
+
# Date Author Version Modification
|
8
|
+
# --------------------------------------------------------------------------------------------------
|
9
|
+
# 2024/5/13 xiatn V00.01.000 新建
|
10
|
+
# --------------------------------------------------------------------------------------------------
|
11
|
+
import re
|
12
|
+
import uuid
|
13
|
+
import math
|
14
|
+
import json
|
15
|
+
from uuid import UUID
|
16
|
+
from pprint import pformat
|
17
|
+
from urllib.parse import urlencode
|
18
|
+
|
19
|
+
|
20
|
+
def get_uuid(version=4, namespace: UUID = uuid.NAMESPACE_DNS, name=""):
|
21
|
+
"""
|
22
|
+
生成uuid
|
23
|
+
:param version:版本号
|
24
|
+
1:基于当前时间和 MAC 地址生成版本 1 的 UUID,具有唯一性,但可能存在一定的安全风险。
|
25
|
+
3:基于名称和命名空间的方式生成。它通过将名称和命名空间的标识符组合起来进行哈希计算,生成一个唯一的标识符。UUID 版本 3 使用的哈希算法是 MD5。
|
26
|
+
4:使用随机数生成版本 4 的 UUID,具有足够的随机性和唯一性。
|
27
|
+
5:使用基于命名空间和名称生成版本 5 的 UUID,可以使用自定义的命名空间和名称。
|
28
|
+
:param namespace:命名空间 uuid.NAMESPACE_DNS、uuid.NAMESPACE_URL、uuid.NAMESPACE_OID、uuid.NAMESPACE_X500
|
29
|
+
:param name:名称 自定义
|
30
|
+
:return:
|
31
|
+
"""
|
32
|
+
if version == 1:
|
33
|
+
result = uuid.uuid1()
|
34
|
+
elif version == 3:
|
35
|
+
result = uuid.uuid3(namespace, name)
|
36
|
+
elif version == 5:
|
37
|
+
result = uuid.uuid5(namespace, name)
|
38
|
+
else:
|
39
|
+
result = uuid.uuid4()
|
40
|
+
|
41
|
+
uuid_str = str(result)
|
42
|
+
# uuid_hex = uuid_obj.hex
|
43
|
+
# uuid_int = uuid_obj.int
|
44
|
+
# uuid_bytes = uuid_obj.bytes
|
45
|
+
return uuid_str
|
46
|
+
|
47
|
+
|
48
|
+
def get_str_to_json(str_json):
|
49
|
+
"""
|
50
|
+
字符串类型的json格式 转 json
|
51
|
+
:param str_json: 字符串json
|
52
|
+
:return:
|
53
|
+
"""
|
54
|
+
try:
|
55
|
+
new_str_json = str_json.replace("'", '"'). \
|
56
|
+
replace("None", "null").replace("True", "true"). \
|
57
|
+
replace("False", "false")
|
58
|
+
return json.loads(new_str_json)
|
59
|
+
except Exception as e:
|
60
|
+
return {}
|
61
|
+
|
62
|
+
|
63
|
+
def list_to_strtuple(datas):
|
64
|
+
"""
|
65
|
+
列表转字符串元组
|
66
|
+
:param datas: datas: [1, 2]
|
67
|
+
:return: (1, 2) 字符串类型
|
68
|
+
"""
|
69
|
+
data_str = str(tuple(datas))
|
70
|
+
data_str = re.sub(",\)$", ")", data_str)
|
71
|
+
return data_str
|
72
|
+
|
73
|
+
|
74
|
+
def dumps_json(data, indent=4, sort_keys=False):
|
75
|
+
"""
|
76
|
+
将JSON数据格式化为可打印的字符串
|
77
|
+
:param data:
|
78
|
+
:param indent: 每一级嵌套都使用4个空格进行缩进
|
79
|
+
:param sort_keys: 是否排序
|
80
|
+
:return:
|
81
|
+
"""
|
82
|
+
try:
|
83
|
+
if isinstance(data, str):
|
84
|
+
data = get_str_to_json(data)
|
85
|
+
|
86
|
+
data = json.dumps(
|
87
|
+
data,
|
88
|
+
ensure_ascii=False,
|
89
|
+
indent=indent,
|
90
|
+
skipkeys=True,
|
91
|
+
sort_keys=sort_keys,
|
92
|
+
default=str,
|
93
|
+
)
|
94
|
+
|
95
|
+
except Exception as e:
|
96
|
+
data = pformat(data)
|
97
|
+
|
98
|
+
return data
|
99
|
+
|
100
|
+
|
101
|
+
def get_calculate_total_page(total, limit):
|
102
|
+
"""
|
103
|
+
根据total和limit计算出一共有多少页
|
104
|
+
:param total:
|
105
|
+
:param limit:
|
106
|
+
:return:
|
107
|
+
"""
|
108
|
+
if limit <= 0:
|
109
|
+
return 0
|
110
|
+
# 根据总条数和limit计算总页数
|
111
|
+
total_pages = math.ceil(total / limit)
|
112
|
+
return total_pages
|
113
|
+
|
114
|
+
def get_build_url_with_params(url, params):
|
115
|
+
"""
|
116
|
+
传入url和params拼接完整的url ->效果 https://wwww.xxxx.com/?xxx1=1&xxx2=2
|
117
|
+
:param url:
|
118
|
+
:param params:
|
119
|
+
:return:
|
120
|
+
"""
|
121
|
+
encoded_params = urlencode(params)
|
122
|
+
full_url = url + "?" + encoded_params
|
123
|
+
return full_url
|
@@ -10,11 +10,10 @@
|
|
10
10
|
# --------------------------------------------------------------------------------------------------
|
11
11
|
import os
|
12
12
|
import sys
|
13
|
-
import time
|
14
13
|
import inspect
|
15
14
|
import logging
|
16
|
-
from xtn_tools_pro.tools_time import get_time_timestamp_to_datestr
|
17
15
|
from logging.handlers import BaseRotatingHandler
|
16
|
+
from xtn_tools_pro.utils.time_utils import get_time_timestamp_to_datestr
|
18
17
|
|
19
18
|
|
20
19
|
class RotatingFileHandler(BaseRotatingHandler):
|
@@ -9,7 +9,7 @@
|
|
9
9
|
# 2024/5/12 xiatn V00.01.000 新建
|
10
10
|
# --------------------------------------------------------------------------------------------------
|
11
11
|
import datetime
|
12
|
-
from xtn_tools_pro.
|
12
|
+
from xtn_tools_pro.utils.helpers import list_to_strtuple, dumps_json
|
13
13
|
|
14
14
|
|
15
15
|
def format_sql_value(value):
|
@@ -2,13 +2,14 @@
|
|
2
2
|
# -*- coding: utf-8 -*-
|
3
3
|
|
4
4
|
# 说明:
|
5
|
-
#
|
5
|
+
# 时间
|
6
6
|
# History:
|
7
7
|
# Date Author Version Modification
|
8
8
|
# --------------------------------------------------------------------------------------------------
|
9
|
-
# 2024/
|
9
|
+
# 2024/5/13 xiatn V00.01.000 新建
|
10
10
|
# --------------------------------------------------------------------------------------------------
|
11
|
-
import time
|
11
|
+
import time
|
12
|
+
import datetime
|
12
13
|
|
13
14
|
|
14
15
|
def get_time_now_timestamp(is_time_10=False, is_time_13=False):
|
@@ -3,8 +3,6 @@ README.md
|
|
3
3
|
setup.py
|
4
4
|
xtn_tools_pro/__init__.py
|
5
5
|
xtn_tools_pro/tools.py
|
6
|
-
xtn_tools_pro/tools_flie.py
|
7
|
-
xtn_tools_pro/tools_time.py
|
8
6
|
xtn_tools_pro.egg-info/PKG-INFO
|
9
7
|
xtn_tools_pro.egg-info/SOURCES.txt
|
10
8
|
xtn_tools_pro.egg-info/dependency_links.txt
|
@@ -17,6 +15,10 @@ xtn_tools_pro/db/__init__.py
|
|
17
15
|
xtn_tools_pro/proxy/XiaoXiangProxy.py
|
18
16
|
xtn_tools_pro/proxy/__init__.py
|
19
17
|
xtn_tools_pro/utils/__init__.py
|
18
|
+
xtn_tools_pro/utils/crypto.py
|
19
|
+
xtn_tools_pro/utils/file_utils.py
|
20
|
+
xtn_tools_pro/utils/helpers.py
|
20
21
|
xtn_tools_pro/utils/log.py
|
21
22
|
xtn_tools_pro/utils/retry.py
|
22
|
-
xtn_tools_pro/utils/sql.py
|
23
|
+
xtn_tools_pro/utils/sql.py
|
24
|
+
xtn_tools_pro/utils/time_utils.py
|
@@ -1,176 +0,0 @@
|
|
1
|
-
#!/usr/bin/env python
|
2
|
-
# -*- coding: utf-8 -*-
|
3
|
-
|
4
|
-
# 说明:
|
5
|
-
# tools
|
6
|
-
# History:
|
7
|
-
# Date Author Version Modification
|
8
|
-
# --------------------------------------------------------------------------------------------------
|
9
|
-
# 2024/4/17 xiatn V00.01.000 新建
|
10
|
-
# --------------------------------------------------------------------------------------------------
|
11
|
-
import hashlib, json, math,re
|
12
|
-
from pprint import pformat
|
13
|
-
from urllib.parse import urlencode
|
14
|
-
|
15
|
-
|
16
|
-
def get_md5_32(s, is_upper=False):
|
17
|
-
"""
|
18
|
-
获取文本的md5值 32位
|
19
|
-
:param s: 文本
|
20
|
-
:param is_upper: 是否转大写 默认False
|
21
|
-
:return:
|
22
|
-
"""
|
23
|
-
# s.encode()#变成bytes类型才能加密
|
24
|
-
m = hashlib.md5(s.encode()) # 长度是32
|
25
|
-
if is_upper:
|
26
|
-
return m.hexdigest().upper()
|
27
|
-
return m.hexdigest()
|
28
|
-
|
29
|
-
|
30
|
-
def get_md5_16(s, is_upper=False):
|
31
|
-
"""
|
32
|
-
获取文本的md5值 16位
|
33
|
-
:param s: 文本
|
34
|
-
:param is_upper: 是否转大写 默认False
|
35
|
-
:return:
|
36
|
-
"""
|
37
|
-
result = get_md5_32(s, is_upper)
|
38
|
-
return result[8:24]
|
39
|
-
|
40
|
-
|
41
|
-
def get_binary_content_md5_32(content, is_upper=False):
|
42
|
-
"""
|
43
|
-
二进制内容md5 例如图片
|
44
|
-
:param content: 二进制内容
|
45
|
-
:param is_upper: 是否转大写 默认False
|
46
|
-
:return:
|
47
|
-
"""
|
48
|
-
md5_hash = hashlib.md5(content)
|
49
|
-
md5_hexdigest = md5_hash.hexdigest()
|
50
|
-
if is_upper:
|
51
|
-
return md5_hexdigest.upper()
|
52
|
-
return md5_hexdigest
|
53
|
-
|
54
|
-
|
55
|
-
def get_binary_content_md5_16(content, is_upper=False):
|
56
|
-
"""
|
57
|
-
二进制内容md5 例如图片
|
58
|
-
:param content: 二进制内容
|
59
|
-
:param is_upper: 是否转大写 默认False
|
60
|
-
:return:
|
61
|
-
"""
|
62
|
-
result = get_binary_content_md5_32(content, is_upper)
|
63
|
-
return result[8:24]
|
64
|
-
|
65
|
-
|
66
|
-
def get_file_md5_32(file_path, is_upper=False):
|
67
|
-
"""
|
68
|
-
获取文件md5值
|
69
|
-
:param file_path: 文件路径
|
70
|
-
:param is_upper: 是否转大写 默认False
|
71
|
-
:return:
|
72
|
-
"""
|
73
|
-
with open(file_path, 'rb') as file:
|
74
|
-
data = file.read()
|
75
|
-
md5_hash = hashlib.md5(data).hexdigest()
|
76
|
-
if is_upper:
|
77
|
-
return md5_hash.upper()
|
78
|
-
return md5_hash
|
79
|
-
|
80
|
-
|
81
|
-
def get_file_md5_16(file_path, is_upper=False):
|
82
|
-
"""
|
83
|
-
获取文件md5值
|
84
|
-
:param file_path: 文件路径
|
85
|
-
:param is_upper: 是否转大写 默认False
|
86
|
-
:return:
|
87
|
-
"""
|
88
|
-
result = get_file_md5_32(file_path, is_upper)
|
89
|
-
return result[8:24]
|
90
|
-
|
91
|
-
|
92
|
-
def get_str_to_json(str_json):
|
93
|
-
"""
|
94
|
-
字符串类型的json格式 转 json
|
95
|
-
:param str_json: 字符串json
|
96
|
-
:return:
|
97
|
-
"""
|
98
|
-
try:
|
99
|
-
new_str_json = str_json.replace("'", '"'). \
|
100
|
-
replace("None", "null").replace("True", "true"). \
|
101
|
-
replace("False", "false")
|
102
|
-
return json.loads(new_str_json)
|
103
|
-
except Exception as e:
|
104
|
-
return {}
|
105
|
-
|
106
|
-
|
107
|
-
def get_build_url_with_params(url, params):
|
108
|
-
"""
|
109
|
-
传入url和params拼接完整的url ->效果 https://wwww.xxxx.com/?xxx1=1&xxx2=2
|
110
|
-
:param url:
|
111
|
-
:param params:
|
112
|
-
:return:
|
113
|
-
"""
|
114
|
-
encoded_params = urlencode(params)
|
115
|
-
full_url = url + "?" + encoded_params
|
116
|
-
return full_url
|
117
|
-
|
118
|
-
|
119
|
-
def get_calculate_total_page(total, limit):
|
120
|
-
"""
|
121
|
-
根据total和limit计算出一共有多少页
|
122
|
-
:param total:
|
123
|
-
:param limit:
|
124
|
-
:return:
|
125
|
-
"""
|
126
|
-
if limit <= 0:
|
127
|
-
return 0
|
128
|
-
# 根据总条数和limit计算总页数
|
129
|
-
total_pages = math.ceil(total / limit)
|
130
|
-
return total_pages
|
131
|
-
|
132
|
-
def list_to_strtuple(datas):
|
133
|
-
"""
|
134
|
-
列表转字符串
|
135
|
-
:param datas: datas: [1, 2]
|
136
|
-
:return: (1, 2) 字符串类型
|
137
|
-
"""
|
138
|
-
data_str = str(tuple(datas))
|
139
|
-
data_str = re.sub(",\)$", ")", data_str)
|
140
|
-
return data_str
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
def dumps_json(data,indent=4,sort_keys=False):
|
146
|
-
"""
|
147
|
-
将JSON数据格式化为可打印的字符串
|
148
|
-
:param data:
|
149
|
-
:param indent: 每一级嵌套都使用4个空格进行缩进
|
150
|
-
:param sort_keys: 是否排序
|
151
|
-
:return:
|
152
|
-
"""
|
153
|
-
try:
|
154
|
-
if isinstance(data, str):
|
155
|
-
data = get_str_to_json(data)
|
156
|
-
|
157
|
-
data = json.dumps(
|
158
|
-
data,
|
159
|
-
ensure_ascii=False,
|
160
|
-
indent=indent,
|
161
|
-
skipkeys=True,
|
162
|
-
sort_keys=sort_keys,
|
163
|
-
default=str,
|
164
|
-
)
|
165
|
-
|
166
|
-
except Exception as e:
|
167
|
-
data = pformat(data)
|
168
|
-
|
169
|
-
return data
|
170
|
-
|
171
|
-
|
172
|
-
def split_image(img):
|
173
|
-
pass
|
174
|
-
|
175
|
-
if __name__ == '__main__':
|
176
|
-
pass
|
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
|
{xtn-tools-pro-1.0.0.0.5 → xtn-tools-pro-1.0.0.0.6}/xtn_tools_pro.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|