Skip to main content

Create and validate a directory stamp based on deterministic path hashing.

Project description

Directory Validator (dirval) 📂✅

GitHub Sponsors Patreon Buy Me a Coffee PayPal Tests License: MIT GitHub stars Tests PyPI version Python versions

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 stamp
  • 1 → directory has changed
  • 3 → 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dirval-1.1.3.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

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

dirval-1.1.3-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file dirval-1.1.3.tar.gz.

File metadata

  • Download URL: dirval-1.1.3.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

Hashes for dirval-1.1.3.tar.gz
Algorithm Hash digest
SHA256 b0f956e9a8a55caccefacb3f6c4d8c8b44f8c4309cff24b82dac082ea1d26843
MD5 cbd5c4f9299d20a165ccf32dfab4d369
BLAKE2b-256 cb6c0a4ea525e369756d6c42803aaf4e43e13a38c3b598a9446cc0de870598e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for dirval-1.1.3.tar.gz:

Publisher: publish-pypi.yml on kevinveenbirkenbach/directory-validator

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

File details

Details for the file dirval-1.1.3-py3-none-any.whl.

File metadata

  • Download URL: dirval-1.1.3-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

Hashes for dirval-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4e69e30a4ceaed0c3a322453cd95c50ca3fad92136f540dc4bb7c32192eca1b2
MD5 8108b5892c59b532e4ebc97405210d9f
BLAKE2b-256 50e130dee3808c65fa8ccf5281eff06d1accd7dcdade6e420ccfa5258b3de756

See more details on using hashes here.

Provenance

The following attestation bundles were made for dirval-1.1.3-py3-none-any.whl:

Publisher: publish-pypi.yml on kevinveenbirkenbach/directory-validator

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