Skip to main content

Filesystem state snapshots with diff comparison

Project description

philiprehberger-dir-snapshot

Tests PyPI version License

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")

API

  • snapshot(path, hash_mode="sha256", include=None, exclude=None) — Create a snapshot
  • Snapshot.diff(other) — Compare two snapshots, returns SnapshotDiff
  • Snapshot.to_json(path) / Snapshot.from_json(path) — Serialize/deserialize
  • SnapshotDiff.summary() — Human-readable diff summary

Development

pip install -e .
python -m pytest tests/ -v

License

MIT

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

philiprehberger_dir_snapshot-0.1.7.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

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

philiprehberger_dir_snapshot-0.1.7-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file philiprehberger_dir_snapshot-0.1.7.tar.gz.

File metadata

File hashes

Hashes for philiprehberger_dir_snapshot-0.1.7.tar.gz
Algorithm Hash digest
SHA256 0efd43b7e1e7c3ac07212a9c7480c56bfddefeb5dc01d5ab0e5a7905ad188ebe
MD5 42c3583d95c9b3d616c65c39992eb7e7
BLAKE2b-256 7458f73e26e9d03f31b9272ed7c101265fb1385da942aab77b5a50b3a10f3941

See more details on using hashes here.

File details

Details for the file philiprehberger_dir_snapshot-0.1.7-py3-none-any.whl.

File metadata

File hashes

Hashes for philiprehberger_dir_snapshot-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 da1d924ab954a62897171c9ae2ebd6c2c4bfbf7a3dfe8ee235e3c79c25eaed24
MD5 392e20446a67155c0b943eb73263a636
BLAKE2b-256 65e05e6ba8bd95ff328c71f3d9f4a3afbeb0198edd35ed32e4671e5ad7d41b18

See more details on using hashes here.

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