eric7.EricCore.EricFileSystemWatcher
Module implementing a QFileSystemWatcher replacement based on the 'watchdog' package.
Global Attributes
Classes
EricFileSystemWatcher |
Class implementing a file system monitor based on the 'watchdog' package as a replacement for 'QFileSystemWatcher'. |
_EricFileSystemEventHandler |
Class implementing a QObject based file system event handler for watchdog. |
Functions
instance |
Function to get a reference to the global file system monitor object. |
EricFileSystemWatcher
Class implementing a file system monitor based on the 'watchdog' package as a
replacement for 'QFileSystemWatcher'.
This class has more fine grained signaling capability compared to
QFileSystemWatcher. The 'directoryChanged' and 'fileChanged' signals are emitted
to keep the API compatible with QFileSystemWatcher.
Signals
- directoryChanged(path: str)
-
emitted when the directory at a given path is
modified or removed from disk
- directoryCreated(path: str)
-
emitted when a directory is created
- directoryDeleted(path: str)
-
emitted when a directory is removed from disk
- directoryModified(path: str)
-
emitted when a directory is modified
- directoryMoved(srcPath: str, dstPath: str)
-
emitted when the directory at a
given source path is renamed or moved to destination path
- error(errno: int, errmsg: str)
-
emitted to indicate an OS error
- fileChanged(path: str)
-
emitted when the file at a given path is modified
or removed from disk
- fileCreated(path: str)
-
emitted when a file is created
- fileDeleted(path: str)
-
emitted when a file is removed from disk
- fileModified(path: str)
-
emitted when a file is modified
- fileMoved(srcPath: str, dstPath: str)
-
emitted when the file at a
given source path is renamed or moved to destination path
Derived from
QObject
Class Attributes
Class Methods
Methods
EricFileSystemWatcher |
Constructor |
__del__ |
Special method called when an instance object is about to be destroyed. |
__directoryChanged |
Private slot handling any change of a directory at a given path. |
__fileChanged |
Private slot handling any change of a file at a given path. |
addPath |
Public method to add the given path to the list of watched paths. |
addPaths |
Public method to add each path of the given list to the file system watched. |
directories |
Public method to return a list of paths to directories that are being watched. |
files |
Public method to return a list of paths to files that are being watched. |
paths |
Public method to return a list of paths that are being watched. |
removePath |
Public method to remove a given path from the list of monitored paths. |
removePaths |
Public method to remove the specified paths from the list of monitored paths. |
shutdown |
Public method to shut down the file system watcher instance. |
Static Methods
EricFileSystemWatcher (Constructor)
EricFileSystemWatcher(parent=None)
Constructor
- parent (QObject (optional))
-
reference to the parent object (defaults to None)
EricFileSystemWatcher.__del__
__del__()
Special method called when an instance object is about to be destroyed.
EricFileSystemWatcher.__directoryChanged
__directoryChanged(path)
Private slot handling any change of a directory at a given path.
It emits the signal 'directoryChanged', if the path is in the list of
watched paths. This behavior is compatible with the QFileSystemWatcher signal
of identical name.
- path (str)
-
path name of the changed directory
EricFileSystemWatcher.__fileChanged
__fileChanged(path)
Private slot handling any change of a file at a given path.
It emits the signal 'fileChanged', if the path is in the list of
watched paths. This behavior is compatible with the QFileSystemWatcher signal
of identical name.
- path (str)
-
path name of the changed file
EricFileSystemWatcher.addPath
addPath(path, recursive=False)
Public method to add the given path to the list of watched paths.
If the given path is a directory, a recursive watch may be requested.
Otherwise only the given directory is watched for changes but none of its
subdirectories.
The path is not added, if it does not exist or if it is already being monitored
by the file system watcher.
- path (str)
-
file or directory path to be added to the watched paths
- recursive (bool (optional))
-
flag indicating a watch for the complete tree rooted at the
given path (for directory paths only) (defaults to False)
- Return:
-
flag indicating a successful creation of a watch for the given path
- Return Type:
-
bool
EricFileSystemWatcher.addPaths
addPaths(paths, recursive=False)
Public method to add each path of the given list to the file system watched.
If a path of the given paths list is a directory, a recursive watch may be
requested. Otherwise only the given directory is watched for changes but none
of its subdirectories. This applies to all directory paths of the given list.
A path of the list is not added, if it does not exist or if it is already being
monitored by the file system watcher.
- paths (list of str)
-
list of file or directory paths to be added to the watched paths
- recursive (bool (optional))
-
flag indicating a watch for the complete tree rooted at the
given path (for directory paths only) (defaults to False)
- Return:
-
list of paths that could not be added to the list of monitored paths
- Return Type:
-
list of str
EricFileSystemWatcher.directories
directories()
Public method to return a list of paths to directories that are being watched.
- Return:
-
list of watched directory paths
- Return Type:
-
list of str
EricFileSystemWatcher.files
files()
Public method to return a list of paths to files that are being watched.
- Return:
-
list of watched file paths
- Return Type:
-
list of str
EricFileSystemWatcher.paths
paths()
Public method to return a list of paths that are being watched.
- Return:
-
list of all watched paths
- Return Type:
-
list of str
EricFileSystemWatcher.removePath
removePath(path)
Public method to remove a given path from the list of monitored paths.
- path (str)
-
directory or file path to be removed
- Return:
-
flag indicating a successful removal. The only reason for a failure is,
if the given path is not currently being monitored.
- Return Type:
-
bool
EricFileSystemWatcher.removePaths
removePaths(paths)
Public method to remove the specified paths from the list of monitored paths.
- paths (list of str)
-
list of directory or file paths to be removed
- Return:
-
list of paths that could not be removed from the list of monitored paths
- Return Type:
-
list of str
EricFileSystemWatcher.shutdown
shutdown()
Public method to shut down the file system watcher instance.
This needs to be done in order to stop the monitoring threads doing their
work in the background. If this method was not called explicitly when the
instance is about to be destroyed, the special method '__del__' will do that.
_EricFileSystemEventHandler
Class implementing a QObject based file system event handler for watchdog.
Signals
- directoryChanged(path: str)
-
emitted when the directory at a given path is
modified or removed from disk
- directoryCreated(path: str)
-
emitted when a directory is created
- directoryDeleted(path: str)
-
emitted when a directory is removed from disk
- directoryModified(path: str)
-
emitted when a directory is modified
- directoryMoved(srcPath: str, dstPath: str)
-
emitted when the directory at a
given source path is renamed or moved to destination path
- fileChanged(path: str)
-
emitted when the file at a given path is modified
or removed from disk
- fileCreated(path: str)
-
emitted when a file is created
- fileDeleted(path: str)
-
emitted when a file is removed from disk
- fileModified(path: str)
-
emitted when a file is modified
- fileMoved(srcPath: str, dstPath: str)
-
emitted when the file at a
given source path is renamed or moved to destination path
Derived from
QObject, FileSystemEventHandler
Class Attributes
Class Methods
Methods
Static Methods
_EricFileSystemEventHandler (Constructor)
_EricFileSystemEventHandler(parent=None)
Constructor
- parent (QObject (optional))
-
reference to the parent object (defaults to None)
_EricFileSystemEventHandler.on_any_event
on_any_event(event)
Private method handling any file system event.
- event (watchdog.events.FileSystemEvent)
-
event to be handled
_EricFileSystemEventHandler.on_created
on_created(event)
Private method to handle a creation event.
- event (watchdog.events.FileCreatedEvent or watchdog.event.DirCreatedEvent)
-
event to be handled
_EricFileSystemEventHandler.on_deleted
on_deleted(event)
Private method to handle a deletion event.
- event (watchdog.events.FileDeletedEvent or watchdog.event.DirDeletedEvent)
-
event to be handled
_EricFileSystemEventHandler.on_modified
on_modified(event)
Private method to handle a modification event.
- event (watchdog.events.FileModifiedEvent or watchdog.event.DirModifiedEvent)
-
event to be handled
_EricFileSystemEventHandler.on_moved
on_moved(event)
Private method to handle a move or rename event.
- event (watchdog.events.FileMovedEvent or watchdog.event.DirMovedEvent)
-
event to be handled
instance
instance()
Function to get a reference to the global file system monitor object.
If the global file system monitor does not exist yet, it will be created
automatically.
- Return:
-
reference to the global file system monitor object
- Return Type:
-
EricFileSystemWatcher