smartpush 1.1.4__py3-none-any.whl → 1.1.6__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 +20 -23
- smartpush/export/basic/GetOssUrl.py +2 -3
- smartpush/export/basic/ReadExcel.py +8 -2
- smartpush/test.py +7 -4
- {smartpush-1.1.4.dist-info → smartpush-1.1.6.dist-info}/METADATA +1 -1
- smartpush-1.1.6.dist-info/RECORD +14 -0
- {smartpush-1.1.4.dist-info → smartpush-1.1.6.dist-info}/WHEEL +1 -1
- smartpush-1.1.4.dist-info/RECORD +0 -14
- {smartpush-1.1.4.dist-info → smartpush-1.1.6.dist-info}/top_level.txt +0 -0
@@ -20,6 +20,8 @@ def check_excel(check_type="content", **kwargs):
|
|
20
20
|
all: 对比所有内容
|
21
21
|
"""
|
22
22
|
try:
|
23
|
+
if "type" not in kwargs.keys():
|
24
|
+
kwargs["type"] = ".xlsx"
|
23
25
|
if check_type == "content":
|
24
26
|
if "actual" in kwargs.keys() and "expected" in kwargs.keys():
|
25
27
|
return check_excel_content(actual=kwargs["actual"], expected=kwargs["expected"])
|
@@ -39,8 +41,7 @@ def check_excel(check_type="content", **kwargs):
|
|
39
41
|
**kwargs)
|
40
42
|
flag1, content_result = check_excel_content(actual=actual_content, expected=expected_content)
|
41
43
|
flag2, name_result = check_excel_name(actual_oss=kwargs["actual_oss"], expected_oss=kwargs["expected_oss"])
|
42
|
-
|
43
|
-
return all([flag1, flag2, flag3]), {"文件名称": name_result, "导出内容": content_result, "表头比较:": header_result}
|
44
|
+
return all([flag1, flag2]), {"文件名称": name_result, "导出内容和表头": content_result}
|
44
45
|
else:
|
45
46
|
return False, f"不支持此类型: {check_type}"
|
46
47
|
except Exception as e:
|
@@ -157,33 +158,29 @@ def check_excel_content(actual, expected):
|
|
157
158
|
"""
|
158
159
|
try:
|
159
160
|
if actual == expected:
|
160
|
-
return True, ["excel
|
161
|
+
return True, ["excel内容和表头-完全匹配"]
|
161
162
|
else:
|
162
163
|
errors = []
|
163
|
-
# 断言1
|
164
|
-
|
165
|
-
expected_num = len(expected)
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
errors.append(
|
171
|
-
"excel内容-行数和预期对比差" + check_row.__str__() + "行" + ", 实际:" + str(
|
172
|
-
actual_num) + "预期: " + str(
|
173
|
-
expected_num))
|
174
|
-
# 断言不匹配行
|
175
|
-
if check_row >= 0:
|
176
|
-
num = len(expected)
|
177
|
-
else:
|
178
|
-
num = len(actual)
|
164
|
+
# 断言1:对比sheet数
|
165
|
+
errors = []
|
166
|
+
actual_num, expected_num = len(actual), len(expected)
|
167
|
+
errors.append("预期和实际sheet数相等,为" + str(
|
168
|
+
actual_num) + "个" if actual_num - expected_num == 0 else "sheet数和预期对比差" + str(
|
169
|
+
actual_num - expected_num) + "个" + ", 实际:" + str(actual_num) + " 预期: " + str(expected_num))
|
170
|
+
# 断言2:对比具体行
|
179
171
|
if isinstance(actual, list) and isinstance(expected, list):
|
180
|
-
|
172
|
+
# 第一层提取sheet
|
173
|
+
for i in range(min(len(expected), len(actual))):
|
181
174
|
if actual[i] == expected[i]:
|
182
175
|
continue
|
183
176
|
else:
|
184
|
-
|
185
|
-
|
186
|
-
|
177
|
+
for row in range(min(len(expected[i]), len(actual[i]))):
|
178
|
+
if actual[i][row] == expected[i][row]:
|
179
|
+
continue
|
180
|
+
else:
|
181
|
+
errors.append(
|
182
|
+
f"第{i+1}个sheet的内容-第" + str(i + 1) + "行不匹配,预期为:" + str(expected[i]) + ", 实际为: " + str(
|
183
|
+
actual[i]))
|
187
184
|
return False, errors
|
188
185
|
else:
|
189
186
|
return False, compare_dicts(actual, expected)
|
@@ -2,8 +2,7 @@
|
|
2
2
|
import json
|
3
3
|
|
4
4
|
import requests
|
5
|
-
import
|
6
|
-
from tenacity import retry, stop_after_attempt, wait_fixed
|
5
|
+
from tenacity import retry, stop_after_attempt, wait_fixed,RetryError
|
7
6
|
|
8
7
|
from smartpush.utils.StringUtils import StringUtils
|
9
8
|
|
@@ -75,7 +74,7 @@ def get_oss_address_with_retry(target_id, url, requestHeader, requestParam, **kw
|
|
75
74
|
return get_oss_address()
|
76
75
|
except Exception as e:
|
77
76
|
# print(f"最终失败,错误信息: {e}")
|
78
|
-
if isinstance(e,
|
77
|
+
if isinstance(e, RetryError):
|
79
78
|
cancel_export_file(target_id)
|
80
79
|
return None
|
81
80
|
|
@@ -44,7 +44,7 @@ def read_excel_csv_data(excel_data, **kwargs):
|
|
44
44
|
with warnings.catch_warnings():
|
45
45
|
warnings.filterwarnings("ignore", category=UserWarning, module=re.escape('openpyxl.styles.stylesheet'))
|
46
46
|
if kwargs['type'] in excel_extensions:
|
47
|
-
dfs = pd.read_excel(excel_data, sheet_name=None, na_filter=False) if isinstance(excel_data,
|
47
|
+
dfs = pd.read_excel(excel_data, sheet_name=None, na_filter=False, engine="openpyxl") if isinstance(excel_data,
|
48
48
|
io.BytesIO) \
|
49
49
|
else excel_data
|
50
50
|
else:
|
@@ -87,11 +87,17 @@ def read_excel_and_write_to_list(excel_data=None, sheet_name=None, file_name=Non
|
|
87
87
|
excel_data = os.path.join(os.path.dirname(os.getcwd()) + "/check_file/" + file_name)
|
88
88
|
dfs = read_excel_csv_data(excel_data, **kwargs)
|
89
89
|
rows_list = []
|
90
|
+
excel_header = read_excel_header(dfs, **kwargs)
|
91
|
+
index = 0
|
90
92
|
# 多sheet处理
|
91
93
|
for name, df in dfs.items():
|
92
|
-
|
94
|
+
row_list = df.values.tolist()
|
95
|
+
row_list.insert(0, excel_header[index])
|
96
|
+
rows_list.append(row_list)
|
97
|
+
index += 1
|
93
98
|
if len(dfs) <= 1:
|
94
99
|
rows_list = rows_list[0]
|
100
|
+
# 插入表头
|
95
101
|
return rows_list
|
96
102
|
except Exception as e:
|
97
103
|
print(f"excel写入list时出错:{e}")
|
smartpush/test.py
CHANGED
@@ -1,19 +1,22 @@
|
|
1
1
|
# -*- codeing = utf-8 -*-
|
2
2
|
# @Time :2025/2/20 00:27
|
3
3
|
# @Author :luzebin
|
4
|
-
from smartpush.export.basic.ExcelExportChecker import check_excel_all
|
4
|
+
from smartpush.export.basic.ExcelExportChecker import check_excel_all,read_excel_and_write_to_list,read_excel_from_oss,read_excel_csv_data,check_excel
|
5
5
|
from smartpush.export.basic.ReadExcel import read_excel_from_oss
|
6
6
|
from smartpush.export.basic.ReadExcel import read_excel_and_write_to_dict
|
7
7
|
from smartpush.export.basic.GetOssUrl import get_oss_address_with_retry
|
8
8
|
|
9
9
|
if __name__ == '__main__':
|
10
10
|
oss1 = "https://cdn.smartpushedm.com/material_ec2/2025-02-19/4d98418295524ab1b52340c2ed2afa4a/AutoTest-%E5%9B%BA%E5%AE%9AB-2025-02-14%20%E5%88%9B%E5%BB%BA%E7%9A%84Email33%E6%95%B0%E6%8D%AE%E6%A6%82%E8%A7%88.xlsx"
|
11
|
-
|
12
|
-
|
11
|
+
oss2 = "https://cdn.smartpushedm.com/material_ec2/2025-02-19/ddbe9965d83840199e678a66dc414518/%E8%90%A5%E9%94%80%E4%BB%BB%E5%8A%A1%E6%95%B0%E6%8D%AE%E6%A6%82%E8%A7%88.xlsx"
|
12
|
+
oss3 = "https://cdn.smartpushedm.com/material_ec2/2025-02-19/4d98418295524ab1b52340c2ed2afa4a/AutoTest-%E5%9B%BA%E5%AE%9AB-2025-02-14%20%E5%88%9B%E5%BB%BA%E7%9A%84Email33%E6%95%B0%E6%8D%AE%E6%A6%82%E8%A7%88.xlsx"
|
13
|
+
# print(check_excel_all(oss1, oss1))
|
13
14
|
|
14
15
|
# expected_oss ="https://cdn.smartpushedm.com/material_ec2_prod/2025-02-20/dae941ec20964ca5b106407858676f89/%E7%BE%A4%E7%BB%84%E6%95%B0%E6%8D%AE%E6%A6%82%E8%A7%88.xlsx"
|
15
16
|
# actual_oss = "https://cdn.smartpushedm.com/material_ec2_prod/2025-02-20/dae941ec20964ca5b106407858676f89/%E7%BE%A4%E7%BB%84%E6%95%B0%E6%8D%AE%E6%A6%82%E8%A7%88.xlsx"
|
16
17
|
# #actual_oss= get_oss_address_with_retry("23161","https://cdn.smartpushedm.com/material_ec2_prod/2025-02-20/dae941ec20964ca5b106407858676f89/%E7%BE%A4%E7%BB%84%E6%95%B0%E6%8D%AE%E6%A6%82%E8%A7%88.xlsx","",'{"page":1,"pageSize":10,"type":null,"status":null,"startTime":null,"endTime":null}')
|
17
18
|
# res=read_excel_and_write_to_dict(read_excel_from_oss(actual_oss))
|
18
19
|
# print(res)
|
19
|
-
# print(
|
20
|
+
# print(read_excel_and_write_to_dict(read_excel_from_oss(oss1), type=".xlsx"))
|
21
|
+
print(check_excel(check_type="all", actual_oss=oss1, expected_oss=oss3))
|
22
|
+
# read_excel_csv_data(type=)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
smartpush/__init__.py,sha256=XJrl1vhGATHSeSVqKmPXxYqxyseriUpvY5tLIXir3EE,24
|
2
|
+
smartpush/get_jira_info.py,sha256=dmCwkKa94xwyE2hegE1KBI3cV_LbrJ67P9osORUGPt4,2633
|
3
|
+
smartpush/test.py,sha256=Pkk6y3snpYnJBT-O51LVujutuT2RSm-nGu-rtB1H-f4,2035
|
4
|
+
smartpush/export/__init__.py,sha256=D9GbWcmwnetEndFDty5XbVienFK1WjqV2yYcQp3CM84,99
|
5
|
+
smartpush/export/basic/ExcelExportChecker.py,sha256=pG6yccw44AIynCOkh_Sv0svLwUMzInMwD-C01qfAtxs,10840
|
6
|
+
smartpush/export/basic/GetOssUrl.py,sha256=IYt-C-SBY4WU_y8dm9aH3uKj1d7M7sSNtitDrz4EfHU,4932
|
7
|
+
smartpush/export/basic/ReadExcel.py,sha256=rL1D29VIHhp2-CN79ROsbEdnnGWAjKNOe6SbPlO_5hA,5368
|
8
|
+
smartpush/export/basic/__init__.py,sha256=6tcrS-2NSlsJo-UwEsnGUmwCf7jgOsh_UEbM0FD-gYE,70
|
9
|
+
smartpush/utils/StringUtils.py,sha256=NXomJ4qmyBRAFnGj5hrFRWwQnRQMTcPzy20fk1dunSw,3980
|
10
|
+
smartpush/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
|
+
smartpush-1.1.6.dist-info/METADATA,sha256=6zoN_MFGdEjUOJFeG3644DSlCHgqO67QaKJN41rVBsc,145
|
12
|
+
smartpush-1.1.6.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
13
|
+
smartpush-1.1.6.dist-info/top_level.txt,sha256=5_CXqu08EfbPaKLjuSAOAqCmGU6shiatwDU_ViBGCmg,10
|
14
|
+
smartpush-1.1.6.dist-info/RECORD,,
|
smartpush-1.1.4.dist-info/RECORD
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
smartpush/__init__.py,sha256=XJrl1vhGATHSeSVqKmPXxYqxyseriUpvY5tLIXir3EE,24
|
2
|
-
smartpush/get_jira_info.py,sha256=dmCwkKa94xwyE2hegE1KBI3cV_LbrJ67P9osORUGPt4,2633
|
3
|
-
smartpush/test.py,sha256=m_Y67qrUeFphwM5jqBOTqheAufmnnjnBVF71nXRXUxg,1598
|
4
|
-
smartpush/export/__init__.py,sha256=D9GbWcmwnetEndFDty5XbVienFK1WjqV2yYcQp3CM84,99
|
5
|
-
smartpush/export/basic/ExcelExportChecker.py,sha256=anvovO657rmo2PF8Mbn_BLFlhSOdyCut4yYoLFUK85c,10807
|
6
|
-
smartpush/export/basic/GetOssUrl.py,sha256=K64PNHNpshYp0ag37IS-wjViCSKS8G4v8AuafHgM31Y,4946
|
7
|
-
smartpush/export/basic/ReadExcel.py,sha256=rGPDq36ujLKA1dlz_33iQQU6I8dhlc5l2ij_JAQX2a0,5145
|
8
|
-
smartpush/export/basic/__init__.py,sha256=6tcrS-2NSlsJo-UwEsnGUmwCf7jgOsh_UEbM0FD-gYE,70
|
9
|
-
smartpush/utils/StringUtils.py,sha256=NXomJ4qmyBRAFnGj5hrFRWwQnRQMTcPzy20fk1dunSw,3980
|
10
|
-
smartpush/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
|
-
smartpush-1.1.4.dist-info/METADATA,sha256=pg3q4VEGLs7d_rDvijLlWHcmOFD4WNF-el-qQzknCvE,145
|
12
|
-
smartpush-1.1.4.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
13
|
-
smartpush-1.1.4.dist-info/top_level.txt,sha256=5_CXqu08EfbPaKLjuSAOAqCmGU6shiatwDU_ViBGCmg,10
|
14
|
-
smartpush-1.1.4.dist-info/RECORD,,
|
File without changes
|