spot_check_files
This is a tool to help validate the integrity of a set of files, e.g. data backups/exports.
- Checks recognized file types for errors, e.g. invalid json.
- Generates thumbnails of files when possible.
- Displays statistics about file types and unrecognized files.
It produces a report like the following in the terminal (seeing images in the terminal requires iTerm2):
Or as HTML:
Usage
Install:
- Install python3 and pip
pip3 install spot_check_files[imgcat]- imgcat is optional and enables support for displaying thumbnails in iTerm2 on OS X
Run:
spotcheck PATH
This will output basic stats and any errors the tool detects in the given files/directories. If you're using iTerm2 on Mac, it will also show thumbnails of files.
Alternatively, you can generate an HTML report:
spotcheck -H PATH > out.html
The full list of options can be seen here or by running spotcheck --help.
This tool can also be used programmatically.
The main entry point for the library is the CheckerRunner class in spot_check_files.checker.
You can add support for new file types by subclassing the Checker class from that module.
Supported file types
The command-line tool currently relies entirely on file extension to determine file types.
| Type | Support |
|---|---|
Archive files:
|
Recursively checks all the files in the archive (including other archives) |
CSV files:
|
Checks that the CSV dialect can be detected and read by Python, and builds a thumbnail |
Image files:
|
Checks that the file can be loaded by the Python imaging library Pillow, and builds a thumbnail |
JSON files: .json |
Checks that the json can be parsed, and builds a thumbnail of the pretty-printed json |
Text files:
|
Treating the file as plaintext, builds a thumbnail |
XML files: .xml |
Checks that the xml can be parsed, and builds a thumbnail of the pretty-printed xml |
| anything supported by OS X Quick Look (HTML, Office docs, ...) | OS X ONLY: generates thumbnails using Quick Look. This greatly increases the number of supported file types. However, it's slow. |
Development
Setup:
- Install python3 and pip
- Clone the repo
- I recommend creating a venv:
cd spot_check_files python3 -m venv venv source venv/bin/activate
- Install dependencies:
pip install . pip install -r requirements-dev.txt
To run tests:
PYTHONPATH=src pytest
(Overriding PYTHONPATH as shown ensures the tests run against the code in the src/ directory rather than the installed copy of the package.)
To run the CLI:
PYTHONPATH=src python -m spot_check_files ...
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/brokensandals/spot_check_files.
License
This is available as open source under the terms of the MIT License.
This package includes and uses a copy of the Monoid font, which is also MIT-licensed.
Metadata
Release files for spot-check-files 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| spot_check_files-0.0.2.tar.gz | 49.6 kB | Without provenance | Details for spot_check_files-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| spot_check_files-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for spot_check_files-0.0.2-py3-none-any.whl |
Total release size: 101.0 kB
Release files / spot_check_files-0.0.2.tar.gz
| Download URL | spot_check_files-0.0.2.tar.gz |
|---|---|
| Size | 49.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
81114989988b4c2b9efe3fa30534ec26b765a2296ab7a9704f6dcf83516015d7
|
|
BLAKE2b-256 checksum How to use checksums |
bad9676de36aa0e5b69a8f84d82d9d259ae1248c8e501a094d2d7bfb57d7b7fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.3
|
Release files / spot_check_files-0.0.2-py3-none-any.whl
| Download URL | spot_check_files-0.0.2-py3-none-any.whl |
|---|---|
| Size | 51.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
809f7c8893da95c4e42447c7eaf6cddff96abe3050f33982cfc7d7857b7c8c5d
|
|
BLAKE2b-256 checksum How to use checksums |
da9b55fc84d4279329d50d5139871e176d4bda409484bc7294e230789b11964e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.3
|
Security for spot-check-files 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.