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.1.8.tar.gz (45.3 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.1.8-py3-none-any.whl (47.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for errorfile-0.1.8.tar.gz
Algorithm Hash digest
SHA256 ed3d3a1f718a2cf3ac57488ef3bdc61a44d5fa233f76e11fd60f58f26bb5f634
MD5 56c43f83878280946d0ed60163da0e6a
BLAKE2b-256 ef665fee4484ab706000aa6fbb5dac0ab708cf9e2a56480bde6aeeb1814d9d70

See more details on using hashes here.

Provenance

The following attestation bundles were made for errorfile-0.1.8.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.1.8-py3-none-any.whl.

File metadata

  • Download URL: errorfile-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 47.9 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.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 847c1172143e8a0e3603c3c8b9be5c8d7bc50cfcc859f1f377d206a9cd615ef0
MD5 76e1faae598be230c28e3f0dd67cfffc
BLAKE2b-256 d65911d37925df64bb75439faade806a9be4ca4ee6956b4c5c87f06e4a54576c

See more details on using hashes here.

Provenance

The following attestation bundles were made for errorfile-0.1.8-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