src/eric7/WebBrowser/Tools/DelayedFileWatcher.py

Sat, 26 Apr 2025 12:34:32 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 26 Apr 2025 12:34:32 +0200
branch
eric7
changeset 11240
c48c615c04a3
parent 11090
f5f5f5803935
permissions
-rw-r--r--

MicroPython
- Added a configuration option to disable the support for the no longer produced Pimoroni Pico Wireless Pack.

4763
8ad353f31184 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
8ad353f31184 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
11090
f5f5f5803935 Updated copyright for 2025.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10679
diff changeset
3 # Copyright (c) 2016 - 2025 Detlev Offenbach <detlev@die-offenbachs.de>
4763
8ad353f31184 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
8ad353f31184 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
4766
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
6 """
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
7 Module implementing a file system watcher with a delay.
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
8 """
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
9
10679
4d3e0ce54322 General
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
10 from PyQt6.QtCore import QTimer, pyqtSignal, pyqtSlot
4d3e0ce54322 General
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
11
4d3e0ce54322 General
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
12 from eric7.EricCore.EricFileSystemWatcher import EricFileSystemWatcher
4766
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
13
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
14
10679
4d3e0ce54322 General
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
15 class DelayedFileWatcher(EricFileSystemWatcher):
4766
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
16 """
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
17 Class implementing a file system watcher with a delay.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
18
4766
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
19 @signal delayedDirectoryChanged(path) emitted to indicate a changed
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
20 directory
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
21 @signal delayedFileChanged(path) emitted to indicate a changed file
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
22 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
23
4766
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
24 delayedDirectoryChanged = pyqtSignal(str)
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
25 delayedFileChanged = pyqtSignal(str)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
26
4766
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
27 def __init__(self, paths=None, parent=None):
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
28 """
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
29 Constructor
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
30
4766
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
31 @param paths list of paths to be watched
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
32 @type list of str
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
33 @param parent reference to the parent object
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
34 @type QObject
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
35 """
10679
4d3e0ce54322 General
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
36 super().__init__(parent)
4766
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
37 if paths:
10679
4d3e0ce54322 General
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
38 self.addPaths(paths)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
39
4766
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
40 self.__dirQueue = []
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
41 self.__fileQueue = []
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
42
4766
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
43 self.directoryChanged.connect(self.__directoryChanged)
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
44 self.fileChanged.connect(self.__fileChanged)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
45
4766
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
46 @pyqtSlot(str)
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
47 def __directoryChanged(self, path):
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
48 """
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
49 Private slot handling a changed directory.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
50
4766
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
51 @param path name of the changed directory
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
52 @type str
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
53 """
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
54 self.__dirQueue.append(path)
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
55 QTimer.singleShot(500, self.__dequeueDirectory)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
56
4766
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
57 @pyqtSlot(str)
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
58 def __fileChanged(self, path):
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
59 """
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
60 Private slot handling a changed file.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
61
4766
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
62 @param path name of the changed file
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
63 @type str
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
64 """
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
65 self.__fileQueue.append(path)
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
66 QTimer.singleShot(500, self.__dequeueFile)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
67
4766
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
68 @pyqtSlot()
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
69 def __dequeueDirectory(self):
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
70 """
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
71 Private slot to signal a directory change.
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
72 """
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
73 self.delayedDirectoryChanged.emit(self.__dirQueue.pop(0))
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
74
4766
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
75 @pyqtSlot()
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
76 def __dequeueFile(self):
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
77 """
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
78 Private slot to signal a file change.
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
79 """
5f8d08aa2217 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4763
diff changeset
80 self.delayedFileChanged.emit(self.__fileQueue.pop(0))

eric ide

mercurial