Files
cmbuyer/client/scripts/sanitize_sku_panel_evidence.py
T

42 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""本机脱敏 T-103 raw 证据到同级 derived;不连接设备或解析页面语义。"""
from __future__ import annotations
import argparse
from pathlib import Path
import sys
CLIENT_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(CLIENT_ROOT / "src"))
from cmbuyer_client.device.sku_evidence_sanitizer import (
SkuEvidenceSanitizationError,
sanitize_sku_panel_evidence,
)
def parse_arguments(argv: list[str] | None = None) -> argparse.Namespace:
parser = argparse.ArgumentParser(description="将本机 raw 规格面板证据确定性脱敏到同级 derived。")
parser.add_argument("--raw-dir", required=True, type=Path, help="仅允许名为 raw 的本机原始证据目录。")
parser.add_argument("--output-dir", required=True, type=Path, help="仅允许 raw 同级且名为 derived 的新目录。")
return parser.parse_args(argv)
def main(argv: list[str] | None = None) -> int:
arguments = parse_arguments(argv)
try:
result = sanitize_sku_panel_evidence(arguments.raw_dir, arguments.output_dir)
except SkuEvidenceSanitizationError as error:
# 错误不回显 raw 路径、manifest/XML、地址、手机号或 serial。
print(f"证据脱敏失败:{error}", file=sys.stderr)
return 1
print(f"派生证据脱敏完成:{result.output_directory}")
print(f"manifest:{result.manifest_path}")
return 0
if __name__ == "__main__":
raise SystemExit(main())