Skip to main content

Filesystem state snapshots with diff comparison

Project description

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

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

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.0.tar.gz (4.2 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.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for philiprehberger_dir_snapshot-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dd89cfb5896df65377c48631085e0ca3f72db0b88e04e515a6b5009ee148042c
MD5 3d20a1eed92d72281cd512ee3c5529dc
BLAKE2b-256 2ee46c3f122bc5345609ccf94da309bd15c97b4fbba03b0c4c357c433755fa77

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for philiprehberger_dir_snapshot-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e5b7e2e278b236c9869c79b65a2a11dfa79ac52283b3a34f8c0513de37463a3c
MD5 b30b8507ce1ffa7480c97cba0e9baf6c
BLAKE2b-256 8d30aa0ea883c5841aa892f5584c59efc04031f4f7ebdc5d15239697cba64c70

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