Skip to main content

一个用于检测图片、文档、压缩包与媒体文件是否损坏的Python包

Project description

ErrorFile

ErrorFile是一个用于检测和识别各种文件错误的Python包,包括图片、PDF、Excel和Word文件。通过使用统一的顶层接口,可以快速定位文件中潜在的问题。

安装

你可以通过pip安装ErrorFile

pip install ErrorFile

快速开始

使用ErrorFile非常简单。推荐直接使用顶层函数inspect_file

from ErrorFile import inspect_file

file_path = r'tests/files/TOM_损坏.jpg'
# mode 参数由 inspect_file 统一处理,当前仅支持 'precise'
is_ok, message = inspect_file(file_path, mode='precise')
print(f"File: {file_path}\nOK: {is_ok}\nMessage: {message}")

支持的文件类型

目前,ErrorFile支持以下文件类型的检查:

  • 图片(JPEG, JPG, PNG, GIF, BMP, WEBP, TIFF, SVG)
  • PDF
  • Office 文档(Excel:XLSX、XLS;Word:DOCX;PowerPoint:PPTX)
  • 压缩包(ZIP、RAR)
  • 媒体文件(MP3、MP4)

检测模式

图片文件采用精确检测模式(precise),底层基于 Pillow 的 verify()load() 方法,能够快速且可靠地发现问题。非图片文件会自动执行相应的深度检查,无需手动配置模式。

API参考

inspect_file(file_path, mode='precise')

顶层函数,用于检查指定路径的文件是否损坏。

参数

  • file_path:要检查的文件路径。
  • mode:(可选)图片检测模式,目前仅支持 precise,其它文件类型忽略此参数。

返回

  • (is_ok, message)is_ok是布尔值,表示文件是否通过检查;message是详细描述信息。

贡献

欢迎贡献!如果你有任何建议或改进,请提交Pull Request或创建Issue。

许可证

ErrorFile根据Apache-2.0许可证发布。有关详细信息,请查看LICENSE文件。

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

errorfile-0.2.0.tar.gz (52.0 kB view details)

Uploaded Source

Built Distribution

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

errorfile-0.2.0-py3-none-any.whl (55.3 kB view details)

Uploaded Python 3

File details

Details for the file errorfile-0.2.0.tar.gz.

File metadata

  • Download URL: errorfile-0.2.0.tar.gz
  • Upload date:
  • Size: 52.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for errorfile-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1673a868f5ec200b1268907a0b147b0421ee5728696f2248f3285e1017038309
MD5 c988a75f5844b47fc997178b397713ae
BLAKE2b-256 6108b550adba9ebed14b8cca672c86af7c6fcf6da1cf895bf7786700831c4c14

See more details on using hashes here.

Provenance

The following attestation bundles were made for errorfile-0.2.0.tar.gz:

Publisher: ci-cd.yml on Hellohistory/ErrorFile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file errorfile-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: errorfile-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 55.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for errorfile-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 04144e9972ff9cbb569e5dd565c5fcde4fa32f7fd2a80c41887fdc7223df0bf7
MD5 82577ad38d0af4d492b58d86bb60c51c
BLAKE2b-256 c16f87c21e0d3c73d766ec04b8bafb7323064e78db8177a5dd2d45f463483f30

See more details on using hashes here.

Provenance

The following attestation bundles were made for errorfile-0.2.0-py3-none-any.whl:

Publisher: ci-cd.yml on Hellohistory/ErrorFile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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