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.3.tar.gz (5.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.3-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for philiprehberger_dir_snapshot-0.1.3.tar.gz
Algorithm Hash digest
SHA256 574fe7503d81d71fc83b16ab89b2c1861fd0566cd83004b8dca6be054cf755b5
MD5 b5291d0e58f0245594dcb8225bb1f9bc
BLAKE2b-256 5d8608f0156cb543a8f77db9217c14bffda51a53fffdf9c9091ae8e490d6c73f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for philiprehberger_dir_snapshot-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8efeb2d99b3e872db8f80b05d278b9f93e8c17d75b61eb4551f700c1dbd56af6
MD5 0ddf7b06c10529971c8400a73d675544
BLAKE2b-256 7a75dcfb843fc52dbb9ce72b2daec2d72a270b31bdc7688e43192774eb9a6307

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