editor.common.file_watcher

This module provide file watcher toolkit.

Whole module is built on a python package named watchdog.

Module Contents

class editor.common.file_watcher.PatternWatcher(patterns=None, ignorePatterns=None, ignoreDirectories=True, caseSensitive=True, onCreated=None, onDeleted=None, onModified=None, onMoved=None)[source]

Bases: PySide6.QtCore.QObject

Watch files match given patterns.

Parameters:
  • patterns (list[str]) – Patterns to allow matching event paths.

  • ignorePatterns (list[str]) – Patterns to ignore matching event paths.

  • ignoreDirectories (bool) – True if directories should be ignored; False otherwise.

  • caseSensitive (bool) – True if path names should be matched sensitive to case; False otherwise.

  • onCreated (function) – Called when a file or directory is created.

  • onDeleted (function) – Called when a file or directory is deleted.

  • onModified (function) – Called when a file or directory is modified.

  • onMoved (function) – Called when a file or directory is moved or renamed.

sigCreated[source]

Signal when a file or directory is created.

Type:

PySide6.QtCore.Signal(FileSystemEvent)

sigDeleted[source]

Signal when a file or directory is deleted.

Type:

PySide6.QtCore.Signal(FileSystemEvent)

sigModified[source]

Signal when a file or directory is modified.

Type:

PySide6.QtCore.Signal(FileSystemEvent)

sigMoved[source]

Signal when a file or directory is moved or renamed.

Type:

PySide6.QtCore.Signal(FileSystemEvent)

handler[source]

Internal PatternMatchingEventHandler instance.

Type:

PatternMatchingEventHandler

start(path, recursive=True)[source]

Schedules watching a path and calls appropriate methods specified in the given event handler in response to file system events.

Parameters:
  • path (str) – Directory path that will be monitored.

  • recursive (bool) – True if events will be emitted for sub-directories traversed recursively; False otherwise.

stop()[source]

Unschedules this watch.

class editor.common.file_watcher.RegexWatcher(regexes=['.*'], ignoreRegexes=[], ignoreDirectories=True, caseSensitive=True, onCreated=None, onDeleted=None, onModified=None, onMoved=None)[source]

Bases: PySide6.QtCore.QObject

Watch files match given regexes.

Parameters:
  • regexes (list[str]) – Regexes to allow matching event paths.

  • ignoreRegexes (list[str]) – Regexes to ignore matching event paths.

  • ignoreDirectories (bool) – True if directories should be ignored; False otherwise.

  • caseSensitive (bool) – True if path names should be matched sensitive to case; False otherwise.

  • onCreated (function) – Called when a file or directory is created.

  • onDeleted (function) – Called when a file or directory is deleted.

  • onModified (function) – Called when a file or directory is modified.

  • onMoved (function) – Called when a file or directory is moved or renamed.

sigCreated[source]

Signal when a file or directory is created.

Type:

PySide6.QtCore.Signal(FileSystemEvent)

sigDeleted[source]

Signal when a file or directory is deleted.

Type:

PySide6.QtCore.Signal(FileSystemEvent)

sigModified[source]

Signal when a file or directory is modified.

Type:

PySide6.QtCore.Signal(FileSystemEvent)

sigMoved[source]

Signal when a file or directory is moved or renamed.

Type:

PySide6.QtCore.Signal(FileSystemEvent)

handler[source]

Internal RegexMatchingEventHandler instance.

Type:

RegexMatchingEventHandler

start(path, recursive=True)[source]

Schedules watching a path and calls appropriate methods specified in the given event handler in response to file system events.

Parameters:
  • path (str) – Directory path that will be monitored.

  • recursive (bool) – True if events will be emitted for sub-directories traversed recursively; False otherwise.

stop()[source]

Unschedules this watch.

editor.common.file_watcher.stopAllWatches()[source]

Unschedules all watches and detaches all associated event handlers.