|
@@ -31,7 +31,6 @@ audit.py — SKU 审核执行器(固定脚本,结果可复现)
|
|
|
或技能包根目录 credentials.json(见 feishu_credentials.py)
|
|
或技能包根目录 credentials.json(见 feishu_credentials.py)
|
|
|
"""
|
|
"""
|
|
|
import argparse
|
|
import argparse
|
|
|
-import glob
|
|
|
|
|
import hashlib
|
|
import hashlib
|
|
|
import json
|
|
import json
|
|
|
import os
|
|
import os
|
|
@@ -40,7 +39,6 @@ import sys
|
|
|
from pathlib import Path
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
_HERE = os.path.dirname(os.path.abspath(__file__))
|
|
_HERE = os.path.dirname(os.path.abspath(__file__))
|
|
|
-_ROOT = os.path.dirname(_HERE)
|
|
|
|
|
|
|
|
|
|
# ---------------------------------------------------------------- 依赖
|
|
# ---------------------------------------------------------------- 依赖
|
|
|
try:
|
|
try:
|
|
@@ -64,6 +62,7 @@ except ImportError:
|
|
|
if _HERE not in sys.path:
|
|
if _HERE not in sys.path:
|
|
|
sys.path.insert(0, _HERE)
|
|
sys.path.insert(0, _HERE)
|
|
|
import feishu_credentials # noqa: E402
|
|
import feishu_credentials # noqa: E402
|
|
|
|
|
+import kit_path # noqa: E402
|
|
|
|
|
|
|
|
BASE = "https://open.feishu.cn/open-apis"
|
|
BASE = "https://open.feishu.cn/open-apis"
|
|
|
|
|
|
|
@@ -91,14 +90,7 @@ def worst(a, b):
|
|
|
# ---------------------------------------------------------------- 工具包读取
|
|
# ---------------------------------------------------------------- 工具包读取
|
|
|
def pick_workbook():
|
|
def pick_workbook():
|
|
|
"""优先取 assets 下版本号最高的工具包"""
|
|
"""优先取 assets 下版本号最高的工具包"""
|
|
|
- for d in (os.path.join(_ROOT, "assets"), os.path.join(_HERE, "assets"), os.getcwd()):
|
|
|
|
|
- hits = [h for h in glob.glob(os.path.join(d, "SKU审核专员-训练校准工具包_v*.xlsx"))
|
|
|
|
|
- if not os.path.basename(h).startswith("~$")]
|
|
|
|
|
- if hits:
|
|
|
|
|
- hits.sort(key=lambda h: [int(x) if x.isdigit() else 0
|
|
|
|
|
- for x in re.findall(r"v(\d+(?:\.\d+)*)", os.path.basename(h))[0].split(".")])
|
|
|
|
|
- return hits[-1]
|
|
|
|
|
- return None
|
|
|
|
|
|
|
+ return kit_path.find()
|
|
|
|
|
|
|
|
|
|
|
|
|
class Kit:
|
|
class Kit:
|
|
@@ -1162,13 +1154,13 @@ def main():
|
|
|
|
|
|
|
|
wbp = a.workbook or pick_workbook()
|
|
wbp = a.workbook or pick_workbook()
|
|
|
if not wbp or not os.path.exists(wbp):
|
|
if not wbp or not os.path.exists(wbp):
|
|
|
- raise SystemExit("找不到工具包 xlsx(assets/SKU审核专员-训练校准工具包_v*.xlsx)")
|
|
|
|
|
|
|
+ raise SystemExit(f"找不到工具包 xlsx(assets/{kit_path.PATTERN})")
|
|
|
kit = Kit(wbp)
|
|
kit = Kit(wbp)
|
|
|
|
|
|
|
|
if a.coverage:
|
|
if a.coverage:
|
|
|
rows = coverage_rows(kit)
|
|
rows = coverage_rows(kit)
|
|
|
auto = sum(1 for r in rows if r[3].startswith("AUTO"))
|
|
auto = sum(1 for r in rows if r[3].startswith("AUTO"))
|
|
|
- print(f"工具包:{os.path.basename(wbp)}")
|
|
|
|
|
|
|
+ print(f"工具包:{kit_path.display_name(wbp)}")
|
|
|
print(f"判定项 {len(rows)} 条:AUTO {auto} 条 / HUMAN {len(rows)-auto} 条")
|
|
print(f"判定项 {len(rows)} 条:AUTO {auto} 条 / HUMAN {len(rows)-auto} 条")
|
|
|
print(f"FZ-06 阈值(读自 02 表):{kit.fz06_px()}px")
|
|
print(f"FZ-06 阈值(读自 02 表):{kit.fz06_px()}px")
|
|
|
print()
|
|
print()
|
|
@@ -1207,7 +1199,7 @@ def main():
|
|
|
results = [aud.run(Doc(r)) for r in recs]
|
|
results = [aud.run(Doc(r)) for r in recs]
|
|
|
|
|
|
|
|
meta = [
|
|
meta = [
|
|
|
- ("工具包", os.path.basename(wbp)),
|
|
|
|
|
|
|
+ ("工具包", kit_path.display_name(wbp)),
|
|
|
("FZ-06 阈值(读自 02-审核判定表)", f"{kit.fz06_px()}px"),
|
|
("FZ-06 阈值(读自 02-审核判定表)", f"{kit.fz06_px()}px"),
|
|
|
("记录数", len(recs)),
|
|
("记录数", len(recs)),
|
|
|
("输入记录 SHA-256", hashlib.sha256(json.dumps(recs, ensure_ascii=False, sort_keys=True, separators=(',', ':')).encode('utf-8')).hexdigest()),
|
|
("输入记录 SHA-256", hashlib.sha256(json.dumps(recs, ensure_ascii=False, sort_keys=True, separators=(',', ':')).encode('utf-8')).hexdigest()),
|
|
@@ -1223,7 +1215,7 @@ def main():
|
|
|
cnt = {}
|
|
cnt = {}
|
|
|
for r in results:
|
|
for r in results:
|
|
|
cnt[r["concl"]] = cnt.get(r["concl"], 0) + 1
|
|
cnt[r["concl"]] = cnt.get(r["concl"], 0) + 1
|
|
|
- print(f"工具包 {os.path.basename(wbp)} FZ-06={kit.fz06_px()}px")
|
|
|
|
|
|
|
+ print(f"工具包 {kit_path.display_name(wbp)} FZ-06={kit.fz06_px()}px")
|
|
|
print(f"记录 {len(recs)} 条")
|
|
print(f"记录 {len(recs)} 条")
|
|
|
for k in (PASS, HOLD, MANUAL, REJECT):
|
|
for k in (PASS, HOLD, MANUAL, REJECT):
|
|
|
print(f" {k}: {cnt.get(k,0)}")
|
|
print(f" {k}: {cnt.get(k,0)}")
|