philiprehberger-dir-snapshot
Filesystem state snapshots with diff comparison.
Installation
pip install philiprehberger-dir-snapshot
Usage
Take a Snapshot
from philiprehberger_dir_snapshot import snapshot
snap = snapshot("./src")
print(f"Found {len(snap.files)} files")
Compare Snapshots
before = snapshot("./src")
# ... make changes ...
after = snapshot("./src")
diff = before.diff(after)
print(diff.summary())
for f in diff.added:
print(f"+ {f.path}")
for f in diff.removed:
print(f"- {f.path}")
for f in diff.modified:
print(f"~ {f.path}")
Save and Load
# Save to JSON
before.to_json("snapshot.json")
# Load later
from philiprehberger_dir_snapshot import Snapshot
restored = Snapshot.from_json("snapshot.json")
Options
# Include only Python files
snap = snapshot("./src", include=["*.py"])
# Exclude build artifacts
snap = snapshot(".", exclude=["__pycache__", "*.pyc", ".git"])
# Use faster hashing (or disable with "none")
snap = snapshot(".", hash_mode="md5")
Verify a Snapshot
Re-check that every file recorded in a snapshot is still on disk and unchanged — useful for backup verification or detecting silent corruption.
snap = snapshot("./backup", hash_mode="sha256")
# ... time passes / backup is restored ...
report = snap.verify()
if report.is_intact:
print("backup intact")
else:
print(report.summary())
for path in report.missing:
print(f"missing: {path}")
for path in report.modified:
print(f"corrupt: {path}")
API
| Function / Class | Description |
|---|---|
snapshot(path, hash_mode="mtime", include=None, exclude=None) |
Create a directory snapshot |
Snapshot.diff(other) |
Compare two snapshots, returns SnapshotDiff |
Snapshot.verify(strict=False) |
Re-check stored entries against disk; returns VerifyReport |
Snapshot.to_json(path) / Snapshot.from_json(path) |
Serialize/deserialize |
VerifyReport.is_intact |
True when nothing is missing or modified |
VerifyReport.verified / .missing / .modified |
File path lists |
FileEntry |
File metadata — .path, .size, .mtime, .hash |
SnapshotDiff.has_changes |
True if any files were added, removed, or modified |
SnapshotDiff.added / .removed / .modified / .unchanged |
Lists of file paths |
SnapshotDiff.summary() |
Human-readable diff summary |
Development
pip install -e .
python -m pytest tests/ -v
Support
If you find this project useful:
License
Metadata
Release files for philiprehberger-dir-snapshot 0.3.0
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 |
|---|---|---|---|---|
| philiprehberger_dir_snapshot-0.3.0.tar.gz | 179.0 kB | Without provenance | Details for philiprehberger_dir_snapshot-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| philiprehberger_dir_snapshot-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for philiprehberger_dir_snapshot-0.3.0-py3-none-any.whl |
Total release size: 185.5 kB
Release files / philiprehberger_dir_snapshot-0.3.0.tar.gz
| Download URL | philiprehberger_dir_snapshot-0.3.0.tar.gz |
|---|---|
| Size | 179.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
25c298aa9a5a8eb43087840c15b5f1a1b7466cc4337e7ea053a6cbc977260aa9
|
|
BLAKE2b-256 checksum How to use checksums |
6d2eb6a24b8eb926e3bb818598c5228a86f1f0e35914b53bdd8c98e497b7d58b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / philiprehberger_dir_snapshot-0.3.0-py3-none-any.whl
| Download URL | philiprehberger_dir_snapshot-0.3.0-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ab0631087057f84eded523c4b6b976dc058dde5a5cbcc4b619c3d4ec7bbb2ed6
|
|
BLAKE2b-256 checksum How to use checksums |
be3a07a1583e252e8d1044ed244de991806c9e017fe48ec997f16327b663b914
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Security for philiprehberger-dir-snapshot 0.3.0
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.