Skip to main content

A Python package for monitoring file system changes

Project description

Watcher

A Python package for monitoring file system changes.

Installation

pip install watcher-fs

Usage

   from watcher_fs.watcher import Watcher, TriggerType
   from pathlib import Path 
   
   test_dir = Path("test_dir")

   def on_change_simple():
      print(f"Something changed.")

   def on_change(change):
      print(f"File {change}")

   watcher = Watcher()
   
   # register as glob pattern
   watcher.register("test_dir/**/*.txt", on_change_simple, TriggerType.PER_FILE)
   watcher.register("test_dir/**/*.py", on_change, TriggerType.ANY_FILE, callback_extra=True)
   
   # register as list of specified files
   watcher.register([
      test_dir / "skin.styl",
      test_dir / "styl/default.styl",
      test_dir / "styl/utils.styl"
   ], on_change, TriggerType.ANY_FILE, callback_extra=True)

   # Simulate a check
   watcher.check()

   # do something
   with open(test_dir / "aaa.txt", "w") as f:
      f.write("Modified content")
   with open(test_dir / "bbb.txt", "w") as f:
      f.write("Modified content")

   with open(test_dir / "skin.styl", "w") as f:
      f.write("a = #0af")
   with open(test_dir / "styl/default.styl", "w") as f:
      f.write("a = #f00")

   # check again
   watcher.check()

Documentation

See https://pavelkrupala.github.io/watcher-fs

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

watcher_fs-1.0.1-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file watcher_fs-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: watcher_fs-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for watcher_fs-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1b9f7be6b1cd2c042ab1479982acd8530b8ed528dbf3c83dcb022d4fea0e054f
MD5 d29cf227b3ae32b412922ca3d29c95b0
BLAKE2b-256 cfd3e6daf4bc4900e247f24f24b096e76b3267eae6a87b1a3ceac94096198ee6

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