一个用于检测图片、文档、压缩包与媒体文件是否损坏的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)
- 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file errorfile-0.2.1.tar.gz.
File metadata
- Download URL: errorfile-0.2.1.tar.gz
- Upload date:
- Size: 53.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b33a906ae2516cec9ee3a7cb92a291491f2db257b36ab30024bd582fa769665
|
|
| MD5 |
04ca5267cc08b50b4bc6e945b0e5b24b
|
|
| BLAKE2b-256 |
7fde9a17c2eeeb806c581d938e1cd45db35211ae896332a7b9c93d2d21e8afe4
|
Provenance
The following attestation bundles were made for errorfile-0.2.1.tar.gz:
Publisher:
ci-cd.yml on Hellohistory/ErrorFile
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
errorfile-0.2.1.tar.gz -
Subject digest:
3b33a906ae2516cec9ee3a7cb92a291491f2db257b36ab30024bd582fa769665 - Sigstore transparency entry: 789646184
- Sigstore integration time:
-
Permalink:
Hellohistory/ErrorFile@a615a3975d028a3f160bd46d82285d0bdb13ed76 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/Hellohistory
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci-cd.yml@a615a3975d028a3f160bd46d82285d0bdb13ed76 -
Trigger Event:
release
-
Statement type:
File details
Details for the file errorfile-0.2.1-py3-none-any.whl.
File metadata
- Download URL: errorfile-0.2.1-py3-none-any.whl
- Upload date:
- Size: 58.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4919827998a02762aaa219b002d1f0e611252943f83970877ded2b21fd09a8d
|
|
| MD5 |
5e4a917e792237ebd9873b47c7b046ba
|
|
| BLAKE2b-256 |
32a125f56661f1482fb39d51ac11592a8384adce5bfd01086f9c17cc80066846
|
Provenance
The following attestation bundles were made for errorfile-0.2.1-py3-none-any.whl:
Publisher:
ci-cd.yml on Hellohistory/ErrorFile
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
errorfile-0.2.1-py3-none-any.whl -
Subject digest:
a4919827998a02762aaa219b002d1f0e611252943f83970877ded2b21fd09a8d - Sigstore transparency entry: 789646190
- Sigstore integration time:
-
Permalink:
Hellohistory/ErrorFile@a615a3975d028a3f160bd46d82285d0bdb13ed76 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/Hellohistory
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci-cd.yml@a615a3975d028a3f160bd46d82285d0bdb13ed76 -
Trigger Event:
release
-
Statement type: