Skip to main content

Compare testdetails tables from HTML reports and generate diff/summary HTML reports.

Project description

XTS Summary Tool

简介

summary_tool 是一个用于提取、比较文本或 HTML 内容并生成差异报告的 Python 包。它可以帮助对比两套文档(如稿件、翻译稿等),并生成可视化的 HTML 报告以及汇总页面。


环境要求

  • Python 3.11 或以上
  • 运行环境:Linux (已在 Docker 镜像中测试)

安装步骤

  1. 克隆或下载代码库(已在本目录下)。
  2. 安装依赖:
    pip install -r requirements.txt
    
  3. (可选)如果希望以命令行入口使用,推荐以可编辑方式安装:
    pip install -e .
    
    这会在 PATH 中添加 summary-tool 命令。

使用示例

以AATS实际目录,ex: 单参数: summary-tool http://10.22.193.246/AATS_XTS_REPORTS/Merlin9_ANR16/DB2881/20260102_171/

单列模式(单参数)

单列模式仅提供左侧路径(目录或 HTML 文件),工具会递归搜索 test_result_failures_suite.html(或首个 HTML)并生成单独的汇总报告。

# 左侧为本地目录,自动递归搜索子目录
python -m summary_tool.cli /path/to/left_root -s cts,gts -o xts_summary.html

# 左侧为远程 URL(目录)
python -m summary_tool.cli https://example.com/reports -r -o remote_summary.html
  • -s:不指定之目录,就会递归搜索所有的子目录下的test_result_failures_suite.html。
  • -r/--recursive:在单列模式下强制递归搜索(可选,默认若左路径是目录且包含目标文件也会递归)。
  • 输出默认 xts_summary.html(未指定 -o 时)。

双列模式(双参数)

双列模式同时提供左、右路径,用于两套报告的对比,生成差异报告。

# 本地目录对比
python -m summary_tool.cli /path/to/left_root /path/to/right_root -s cts,gts -o xts-diff_summary.html

# 本地文件对比(单个子目录)
python -m summary_tool.cli /path/to/left.html /path/to/right.html -o diff.html

# 远程 URL 对比
python -m summary_tool.cli https://example.com/left https://example.com/right -s sts -o remote_diff.html
  • -s:不指定之目录,就会递归搜索所有的子目录下的test_result_failures_suite.html。
  • 输出默认 xts-diff_summary.html(未指定 -o 时)。
  • 若只提供左侧路径,则进入单列模式,上述示例可省略右侧参数。

使用已安装的 CLI 命令(若已执行 pip install -e .

summary-tool -a path/to/first -b path/to/second -o reports

运行后会在指定的输出目录生成以下文件, 默认缓存文件输出目录tmp_diff_reports:

  • *_1.html*_2.html:原始文本的 HTML 展示
  • *-diff.html:对比后的差异报告 项目根目录:
  • xts_summary.htmlxts-diff_summary.html:整体汇总页面

常见错误及解决办法

错误信息 可能原因 解决方案
ModuleNotFoundError: No module named 'xxx' 依赖未安装或虚拟环境不匹配 确认已在当前环境执行 pip install -r requirements.txt,或使用 python -m venv venv && source venv/bin/activate 再安装。
FileNotFoundError: [Errno 2] No such file or directory 提供的路径不存在或拼写错误 检查 --source-a--source-b 参数,确保路径正确且文件可读。
UnicodeDecodeError 输入文件编码不是 UTF-8 extractor.py 中添加 encoding='utf-8',或先将文件转换为 UTF-8 编码。
git status 报 “detected dubious ownership” 在容器中挂载的目录所有权不被 Git 认可 执行 git config --global --add safe.directory <repo_path>(已在项目根目录做过此设置)。
空的 diff 报告 两个输入的内容完全相同或提取阶段出错 打印 extractor 的日志(utils.py 中的 logger),确认文本已被正确读取。

开发 & 贡献

Continue CLI

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

summary_tool-1.0.1.tar.gz (22.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

summary_tool-1.0.1-py3-none-any.whl (22.3 kB view details)

Uploaded Python 3

File details

Details for the file summary_tool-1.0.1.tar.gz.

File metadata

  • Download URL: summary_tool-1.0.1.tar.gz
  • Upload date:
  • Size: 22.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for summary_tool-1.0.1.tar.gz
Algorithm Hash digest
SHA256 0836fc555b2c995b79800e5c2a2bac2ff857dbc30096e06e4b13313c98a5745c
MD5 da18b2893eeaa708ae7ad62eb78b4d7d
BLAKE2b-256 2e033f67a1ef2eae4615517c51ed1a28ca9885b9873780edbd25215ddaad69c3

See more details on using hashes here.

File details

Details for the file summary_tool-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: summary_tool-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 22.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for summary_tool-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bce27d2168c3b942c0f6fef7f52ea37ea01e79b4b95e1719375de3a07f1f0c9b
MD5 4db9d96f93076c26823acfe8d66ea3c3
BLAKE2b-256 32c902d73b30df868cfbafd7f89d5b3df8c53498014186e6044a99edc15399e0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page