Create and validate a directory stamp based on deterministic path hashing.
Project description
Directory Validator (dirval) 📂✅
Directory Validator is a Python utility that creates and verifies a unique hash stamp for a directory. This stamp, saved as a JSON file, represents the directory’s structure (relative paths, excluding the stamp file itself), allowing you to quickly detect changes in the directory layout.
🛠 Features
- Stamp Creation: Generate a deterministic SHA-256 hash from all relative paths (files and subdirectories).
- Validation: Recalculate the hash to determine if any files or directories have changed.
- Exclusion Handling: Automatically ignores the stamp file (
directory_stemp.json) in the directory root. - Simple CLI Interface: Easily create or validate stamps via command-line options.
📥 Installation
Install Directory Validator directly from PyPI:
pip install dirval
For a user-local installation (recommended if you don’t use virtual environments):
pip install --user dirval
For development or editable installs:
git clone https://github.com/kevinveenbirkenbach/directory-validator.git
cd directory-validator
pip install -e .
After installation, the dirval command will be available in your shell.
🚀 Usage
Create a Directory Stamp
Generate a stamp (hash and timestamp) for a directory.
The stamp is saved as directory_stemp.json inside the directory.
dirval <path_to_directory> --stamp
Example:
dirval ./my-folder --stamp
Validate a Directory
Compare the current directory state against the stored stamp to check for any modifications.
dirval <path_to_directory> --validate
Example:
dirval ./my-folder --validate
Exit codes:
0→ directory matches the stored stamp1→ directory has changed3→ directory or stamp file not found
📖 How It Works
- The tool recursively walks through the given directory and collects all file and subdirectory paths.
- The stamp file (
directory_stemp.json) in the directory root is ignored automatically. - All collected relative paths are sorted deterministically.
- A cumulative SHA-256 hash is generated from those paths.
- The hash and a timestamp are stored in
directory_stemp.json. - During validation, the hash is recalculated and compared against the stored value.
🧑💻 Author
Developed by Kevin Veen-Birkenbach
📜 License
This project is licensed under the MIT License. See the LICENSE file for details.
🤝 Contributions
Contributions are welcome! Feel free to fork the repository, submit pull requests, or open issues if you have suggestions or encounter any problems. Let's improve directory validation together! 😊
Project details
Release history Release notifications | RSS feed
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 dirval-1.1.4.tar.gz.
File metadata
- Download URL: dirval-1.1.4.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9fcd1ccd24cc441e3b304b00b64387df36b91db36bc4e3aaf9a48df97615736e
|
|
| MD5 |
d70107d15f32c5ce5fec2523e0d56f21
|
|
| BLAKE2b-256 |
1e33f4bc55b070eae1fc0e53df6c6f72b0a3fc8a234debbebcfbb7e9cc213bee
|
Provenance
The following attestation bundles were made for dirval-1.1.4.tar.gz:
Publisher:
publish-pypi.yml on kevinveenbirkenbach/directory-validator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dirval-1.1.4.tar.gz -
Subject digest:
9fcd1ccd24cc441e3b304b00b64387df36b91db36bc4e3aaf9a48df97615736e - Sigstore transparency entry: 763261776
- Sigstore integration time:
-
Permalink:
kevinveenbirkenbach/directory-validator@e5bcd6952f6c16ec0558cf80a010e8c8fa8aaef8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/kevinveenbirkenbach
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@e5bcd6952f6c16ec0558cf80a010e8c8fa8aaef8 -
Trigger Event:
workflow_run
-
Statement type:
File details
Details for the file dirval-1.1.4-py3-none-any.whl.
File metadata
- Download URL: dirval-1.1.4-py3-none-any.whl
- Upload date:
- Size: 6.5 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 |
e56a0daf219c93c8bf5cb4ebb83cbda2ecc9f31b14cc47be4caf6fdb0aecbc3e
|
|
| MD5 |
65e950dbd6d18bbab6d21d3cb4da3b1d
|
|
| BLAKE2b-256 |
ec95af7059ab40d8c7a343fff324760e86b2bd97a3b735220fe257865e6f38ee
|
Provenance
The following attestation bundles were made for dirval-1.1.4-py3-none-any.whl:
Publisher:
publish-pypi.yml on kevinveenbirkenbach/directory-validator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dirval-1.1.4-py3-none-any.whl -
Subject digest:
e56a0daf219c93c8bf5cb4ebb83cbda2ecc9f31b14cc47be4caf6fdb0aecbc3e - Sigstore transparency entry: 763261777
- Sigstore integration time:
-
Permalink:
kevinveenbirkenbach/directory-validator@e5bcd6952f6c16ec0558cf80a010e8c8fa8aaef8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/kevinveenbirkenbach
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@e5bcd6952f6c16ec0558cf80a010e8c8fa8aaef8 -
Trigger Event:
workflow_run
-
Statement type: