smartpush 1.0.8__py3-none-any.whl → 1.0.9__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.
- smartpush/export/basic/ExcelExportChecker.py +1 -1
- smartpush/export/basic/GetOssUrl.py +37 -0
- smartpush/test.py +18 -0
- smartpush/utils/StringUtils.py +126 -0
- smartpush/utils/__init__.py +0 -0
- {smartpush-1.0.8.dist-info → smartpush-1.0.9.dist-info}/METADATA +1 -1
- smartpush-1.0.9.dist-info/RECORD +13 -0
- {smartpush-1.0.8.dist-info → smartpush-1.0.9.dist-info}/WHEEL +1 -1
- smartpush/felix_test.py +0 -20
- smartpush-1.0.8.dist-info/RECORD +0 -10
- {smartpush-1.0.8.dist-info → smartpush-1.0.9.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
import requests
|
2
|
+
from retry import retry
|
3
|
+
import json
|
4
|
+
from smartpush.utils.StringUtils import StringUtils
|
5
|
+
|
6
|
+
|
7
|
+
def get_oss_address_with_retry(target_id, url, requestHeader, requestParam, **kwargs) -> str:
|
8
|
+
"""
|
9
|
+
创建带有动态重试配置的获取 OSS 地址
|
10
|
+
**kwargs 可传参:tries=10, delay=2, backoff=1
|
11
|
+
:param requestParam:
|
12
|
+
:param url:
|
13
|
+
:param target_id:
|
14
|
+
:param requestHeader:
|
15
|
+
:return: 带有重试配置的获取 OSS 地址的
|
16
|
+
"""
|
17
|
+
|
18
|
+
@retry(tries=10, delay=2, backoff=1)
|
19
|
+
def get_oss_address():
|
20
|
+
if StringUtils.is_empty(target_id):
|
21
|
+
print(f"缺少参数:target_id")
|
22
|
+
return
|
23
|
+
try:
|
24
|
+
response = requests.request(url=url, headers=requestHeader, data=json.dumps(requestParam), method="post")
|
25
|
+
response.raise_for_status()
|
26
|
+
result = response.json()
|
27
|
+
id_url_dict = {item["id"]: item["url"] for item in result["resultData"]["datas"]}
|
28
|
+
if target_id in id_url_dict:
|
29
|
+
if len(id_url_dict[target_id]) == 1:
|
30
|
+
return id_url_dict[target_id][0]
|
31
|
+
else:
|
32
|
+
raise ValueError(f"存在多条 id 为 {target_id} 的记录,记录为:{id_url_dict[target_id]}")
|
33
|
+
else:
|
34
|
+
raise ValueError(f"未找到 id 为 {target_id} 的记录,未包含有效的 OSS 地址,")
|
35
|
+
except (KeyError, json.JSONDecodeError) as e:
|
36
|
+
raise ValueError(f"响应数据格式错误,响应结果: {result},异常: {e}")
|
37
|
+
return get_oss_address()
|
smartpush/test.py
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
from smartpush.export.basic.ExcelExportChecker import check_excel_for_lu
|
2
|
+
from smartpush.export.basic.GetOssUrl import get_oss_address_with_retry
|
3
|
+
|
4
|
+
if __name__ == '__main__':
|
5
|
+
# print(check_excel_for_lu("content",actual_oss="https://sl-smartfile.oss-ap-southeast-1.aliyuncs.com/material_ec2_prod/2025-01-20/fcb98e2965314ef2862db65760dcce1f/ab%E5%BC%B9%E7%AA%97%E6%B4%BB%E5%8A%A8-%E8%BD%AC%E5%8C%96%E7%8E%87%E8%8E%B7%E8%83%9C%E9%94%80%E5%94%AE%E9%A2%9D%E6%98%8E%E7%BB%86%E6%95%B0%E6%8D%AE.xlsx",expected_oss="https://sl-smartfile.oss-ap-southeast-1.aliyuncs.com/material_ec2_prod/2025-01-20/fcb98e2965314ef2862db65760dcce1f/ab%E5%BC%B9%E7%AA%97%E6%B4%BB%E5%8A%A8-%E8%BD%AC%E5%8C%96%E7%8E%87%E8%8E%B7%E8%83%9C%E9%94%80%E5%94%AE%E9%A2%9D%E6%98%8E%E7%BB%86%E6%95%B0%E6%8D%AE.xlsx"))
|
6
|
+
|
7
|
+
|
8
|
+
_id = 10901
|
9
|
+
url = "https://test.smartpushedm.com/api-em-ec2/bulkOps/query"
|
10
|
+
requestHeaders = {
|
11
|
+
'cookie': 'osudb_appid=SMARTPUSH;osudb_oar=#01#SID0000121BJe/0W0PdWQj0Wo/Cr4G9H5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IjoiIn0sImxvZ2luVGltZSI6MTczOTQxOTI0Nzg2OSwic2NvcGUiOlsiZW1haWwtbWFya2V0IiwiY29va2llIiwic2wtZWNvbS1lbWFpbC1tYXJrZXQtbmV3LXRlc3QiLCJlbWFpbC1tYXJrZXQtbmV3LWRldi1mcyIsImFwaS11Yy1lYzIiLCJhcGktc3UtZWMyIiwiYXBpLWVtLWVjMiIsImZsb3ctcGx1Z2luIl0sImNsaWVudF9pZCI6ImVtYWlsLW1hcmtldCJ9.PJGM1sSZyvxTriMK4e1g90krqBUq9OVNc5vEyKxsXyQ;',
|
12
|
+
'Content-Type': 'application/json'}
|
13
|
+
requestParams = {'page': 1, 'pageSize': 10, 'type': 'EXPORT', 'status': None, 'startTime': None, 'endTime': None}
|
14
|
+
oss=get_oss_address_with_retry(_id, url, requestHeaders, requestParams, tries=1, delay=1, backoff=1)
|
15
|
+
eexcelxcel = check_excel_for_lu("all",
|
16
|
+
expected_oss=oss,
|
17
|
+
actual_oss=oss)
|
18
|
+
print(eexcelxcel)
|
@@ -0,0 +1,126 @@
|
|
1
|
+
class StringUtils:
|
2
|
+
@staticmethod
|
3
|
+
def to_upper(s):
|
4
|
+
"""
|
5
|
+
将字符串转换为大写
|
6
|
+
:param s: 输入的字符串
|
7
|
+
:return: 转换为大写后的字符串
|
8
|
+
"""
|
9
|
+
return s.upper() if isinstance(s, str) else s
|
10
|
+
|
11
|
+
@staticmethod
|
12
|
+
def to_lower(s):
|
13
|
+
"""
|
14
|
+
将字符串转换为小写
|
15
|
+
:param s: 输入的字符串
|
16
|
+
:return: 转换为小写后的字符串
|
17
|
+
"""
|
18
|
+
return s.lower() if isinstance(s, str) else s
|
19
|
+
|
20
|
+
@staticmethod
|
21
|
+
def strip(s):
|
22
|
+
"""
|
23
|
+
去除字符串两端的空白字符
|
24
|
+
:param s: 输入的字符串
|
25
|
+
:return: 去除两端空白字符后的字符串
|
26
|
+
"""
|
27
|
+
return s.strip() if isinstance(s, str) else s
|
28
|
+
|
29
|
+
@staticmethod
|
30
|
+
def is_digit(s):
|
31
|
+
"""
|
32
|
+
判断字符串是否只包含数字
|
33
|
+
:param s: 输入的字符串
|
34
|
+
:return: 如果只包含数字返回 True,否则返回 False
|
35
|
+
"""
|
36
|
+
return s.isdigit() if isinstance(s, str) else False
|
37
|
+
|
38
|
+
@staticmethod
|
39
|
+
def substring(s, start, end=None):
|
40
|
+
"""
|
41
|
+
截取字符串的子字符串
|
42
|
+
:param s: 输入的字符串
|
43
|
+
:param start: 起始索引
|
44
|
+
:param end: 结束索引(可选)
|
45
|
+
:return: 截取的子字符串
|
46
|
+
"""
|
47
|
+
return s[start:end] if isinstance(s, str) else s
|
48
|
+
|
49
|
+
@staticmethod
|
50
|
+
def replace(s, old, new):
|
51
|
+
"""
|
52
|
+
替换字符串中的指定子字符串
|
53
|
+
:param s: 输入的字符串
|
54
|
+
:param old: 要替换的旧子字符串
|
55
|
+
:param new: 替换后的新子字符串
|
56
|
+
:return: 替换后的字符串
|
57
|
+
"""
|
58
|
+
return s.replace(old, new) if isinstance(s, str) else s
|
59
|
+
|
60
|
+
@staticmethod
|
61
|
+
def split(s, sep=None):
|
62
|
+
"""
|
63
|
+
根据指定分隔符分割字符串
|
64
|
+
:param s: 输入的字符串
|
65
|
+
:param sep: 分隔符(可选)
|
66
|
+
:return: 分割后的字符串列表
|
67
|
+
"""
|
68
|
+
return s.split(sep) if isinstance(s, str) else s
|
69
|
+
|
70
|
+
@staticmethod
|
71
|
+
def is_empty(s):
|
72
|
+
"""
|
73
|
+
判断字符串是否为空
|
74
|
+
:param s: 输入的字符串
|
75
|
+
:return: 如果字符串为空或仅包含空白字符返回 True,否则返回 False
|
76
|
+
"""
|
77
|
+
return not s or s.isspace() if isinstance(s, str) or s is None else False
|
78
|
+
|
79
|
+
@staticmethod
|
80
|
+
def contains(s, sub):
|
81
|
+
"""
|
82
|
+
判断字符串是否包含指定子字符串
|
83
|
+
:param s: 输入的字符串
|
84
|
+
:param sub: 要检查的子字符串
|
85
|
+
:return: 如果包含返回 True,否则返回 False
|
86
|
+
"""
|
87
|
+
return sub in s if isinstance(s, str) and isinstance(sub, str) else False
|
88
|
+
|
89
|
+
@staticmethod
|
90
|
+
def reverse(s):
|
91
|
+
"""
|
92
|
+
反转字符串
|
93
|
+
:param s: 输入的字符串
|
94
|
+
:return: 反转后的字符串
|
95
|
+
"""
|
96
|
+
return s[::-1] if isinstance(s, str) else s
|
97
|
+
|
98
|
+
@staticmethod
|
99
|
+
def count_substring(s, sub):
|
100
|
+
"""
|
101
|
+
统计子字符串在字符串中出现的次数
|
102
|
+
:param s: 输入的字符串
|
103
|
+
:param sub: 要统计的子字符串
|
104
|
+
:return: 子字符串出现的次数
|
105
|
+
"""
|
106
|
+
return s.count(sub) if isinstance(s, str) and isinstance(sub, str) else 0
|
107
|
+
|
108
|
+
@staticmethod
|
109
|
+
def startswith(s, prefix):
|
110
|
+
"""
|
111
|
+
判断字符串是否以指定前缀开头
|
112
|
+
:param s: 输入的字符串
|
113
|
+
:param prefix: 前缀字符串
|
114
|
+
:return: 如果以指定前缀开头返回 True,否则返回 False
|
115
|
+
"""
|
116
|
+
return s.startswith(prefix) if isinstance(s, str) and isinstance(prefix, str) else False
|
117
|
+
|
118
|
+
@staticmethod
|
119
|
+
def endswith(s, suffix):
|
120
|
+
"""
|
121
|
+
判断字符串是否以指定后缀结尾
|
122
|
+
:param s: 输入的字符串
|
123
|
+
:param suffix: 后缀字符串
|
124
|
+
:return: 如果以指定后缀结尾返回 True,否则返回 False
|
125
|
+
"""
|
126
|
+
return s.endswith(suffix) if isinstance(s, str) and isinstance(suffix, str) else False
|
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
smartpush/__init__.py,sha256=XJrl1vhGATHSeSVqKmPXxYqxyseriUpvY5tLIXir3EE,24
|
2
|
+
smartpush/get_jira_info.py,sha256=dmCwkKa94xwyE2hegE1KBI3cV_LbrJ67P9osORUGPt4,2633
|
3
|
+
smartpush/test.py,sha256=GR8R4qMkXgpp884X9RDV04N2TBGavyXQQe8PBitD1jE,2822
|
4
|
+
smartpush/export/__init__.py,sha256=D9GbWcmwnetEndFDty5XbVienFK1WjqV2yYcQp3CM84,99
|
5
|
+
smartpush/export/basic/ExcelExportChecker.py,sha256=2EMa_KWErJ18un0YPKa9InHyKJ5cIUCnYyCpAjqVqss,12189
|
6
|
+
smartpush/export/basic/GetOssUrl.py,sha256=O2-HtcYzbabck9dKgLu8ga21_AiyDIzgdfoDgvqBY3c,1541
|
7
|
+
smartpush/export/basic/__init__.py,sha256=6tcrS-2NSlsJo-UwEsnGUmwCf7jgOsh_UEbM0FD-gYE,70
|
8
|
+
smartpush/utils/StringUtils.py,sha256=NXomJ4qmyBRAFnGj5hrFRWwQnRQMTcPzy20fk1dunSw,3980
|
9
|
+
smartpush/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
10
|
+
smartpush-1.0.9.dist-info/METADATA,sha256=y3_SkqSb2-fPTteG2RZUOBURVjr3W-higEFBqhVJ5io,145
|
11
|
+
smartpush-1.0.9.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
12
|
+
smartpush-1.0.9.dist-info/top_level.txt,sha256=5_CXqu08EfbPaKLjuSAOAqCmGU6shiatwDU_ViBGCmg,10
|
13
|
+
smartpush-1.0.9.dist-info/RECORD,,
|
smartpush/felix_test.py
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
import requests
|
2
|
-
|
3
|
-
from smartpush.export.basic import ExcelExportChecker
|
4
|
-
|
5
|
-
if __name__ == '__main__':
|
6
|
-
|
7
|
-
ossurl1 = "https://cdn.smartpushedm.com/material_ec2/2025-02-10/4f3c7f2ad92946a894e3df9176341e1c/%E7%94%A8%E6%88%B7%E7%95%99%E5%AD%98.xlsx"
|
8
|
-
ossurl2 = "https://cdn.smartpushedm.com/material_ec2/2025-02-10/238f1f143d34441e9cfd61ba68ce8dd1/%E7%94%A8%E6%88%B7%E7%95%99%E5%AD%98.xlsx"
|
9
|
-
#
|
10
|
-
# # a = ExcelExportChecker.read_excel_and_write_to_list(excel_data=ExcelExportChecker.read_excel_from_oss(url=ossurl1))
|
11
|
-
# # b = ExcelExportChecker.read_excel_and_write_to_list(excel_data=ExcelExportChecker.read_excel_from_oss(url=ossurl2))
|
12
|
-
# # print(ExcelExportChecker.check_excel(actual=a, expected=b))
|
13
|
-
print(ExcelExportChecker.check_excel(check_type="content", actual_oss=ossurl1, expected_oss=ossurl2))
|
14
|
-
|
15
|
-
# a = ['2025-01-02', 1, '100%', 0.0, '0%', 0.0, '0%', nan, nan]
|
16
|
-
# b = ['2025-01-02', 1, '100%', 0.0, '0%', 0.0, '0%', nan, nan]
|
17
|
-
# if a == b:
|
18
|
-
# print(1)
|
19
|
-
# else:
|
20
|
-
# print(2)
|
smartpush-1.0.8.dist-info/RECORD
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
smartpush/__init__.py,sha256=XJrl1vhGATHSeSVqKmPXxYqxyseriUpvY5tLIXir3EE,24
|
2
|
-
smartpush/felix_test.py,sha256=CpB1NMDZ4RAtE028XVYfhxTU7RQPSqlWN6ejGO7ww7I,1020
|
3
|
-
smartpush/get_jira_info.py,sha256=dmCwkKa94xwyE2hegE1KBI3cV_LbrJ67P9osORUGPt4,2633
|
4
|
-
smartpush/export/__init__.py,sha256=D9GbWcmwnetEndFDty5XbVienFK1WjqV2yYcQp3CM84,99
|
5
|
-
smartpush/export/basic/ExcelExportChecker.py,sha256=T9eDPgNh5zekCAdKFu67aHjQPhKQKzK1BUGtn7UQuh0,12187
|
6
|
-
smartpush/export/basic/__init__.py,sha256=6tcrS-2NSlsJo-UwEsnGUmwCf7jgOsh_UEbM0FD-gYE,70
|
7
|
-
smartpush-1.0.8.dist-info/METADATA,sha256=Shg6Xm-PRgQW1n2UFjy9suT2lNAAFMZfjOlYSHJ9VKI,145
|
8
|
-
smartpush-1.0.8.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
9
|
-
smartpush-1.0.8.dist-info/top_level.txt,sha256=5_CXqu08EfbPaKLjuSAOAqCmGU6shiatwDU_ViBGCmg,10
|
10
|
-
smartpush-1.0.8.dist-info/RECORD,,
|
File without changes
|