class asphalt.filewatcher.component.FileWatcherComponent(watchers: typing.Dict[str, typing.Dict[str, typing.Any]] = None, **default_watcher_args)

Bases: asphalt.core.component.Component

Publishes one or more FileWatcher resources.

If more than one watcher is to be configured, provide a watchers argument as a dictionary where the key is the resource name and the value is a dictionary of keyword arguments to create_watcher(). Otherwise, directly pass those keyword arguments to the component constructor itself.

If watchers is defined, any extra keyword arguments are used as default values for create_watcher() for all watchers (merge_config() is used to merge the per-watcher arguments with the defaults). Otherwise, a single watcher is created based on the provided default arguments, with context_attr defaulting to watcher.

  • watchers (Optional[Dict[str, Dict[str, Any]]]) – a dictionary of resource name ⭢ create_watcher() keyword arguments
  • default_watcher_args – default values for omitted :func:create_watcher` arguments
asphalt.filewatcher.component.create_watcher(path, events, *, recursive=True, backend=None, **kwargs)

Create a new file system watcher.

If no backend name is explicitly given, the best default backend for the current platform is used.

  • path (Union[str, Path]) – path to the directory to watch
  • events (Iterable[FileEventType]) – either a comma separated string or iterable of event types to watch
  • recursive (bool) – True to watch for changes in subdirectories as well
  • backend (Optional[str]) – name of the backend plugin (from the asphalt.watcher.watchers namespace)