src/eric7/Documentation/Source/eric7.EricCore.EricFileSystemWatcher.html

branch
eric7
changeset 10679
4d3e0ce54322
child 10685
a9134b4e8ed0
equal deleted inserted replaced
10678:665f1084ebf9 10679:4d3e0ce54322
1 <!DOCTYPE html>
2 <html><head>
3 <title>eric7.EricCore.EricFileSystemWatcher</title>
4 <meta charset="UTF-8">
5 <link rel="stylesheet" href="styles.css">
6 </head>
7 <body>
8 <a NAME="top" ID="top"></a>
9 <h1>eric7.EricCore.EricFileSystemWatcher</h1>
10 <p>
11 Module implementing a QFileSystemWatcher replacement based on the 'watchdog' package.
12 </p>
13
14 <h3>Global Attributes</h3>
15 <table>
16 <tr><td>_GlobalFileSystemWatcher</td></tr>
17 </table>
18
19 <h3>Classes</h3>
20 <table>
21 <tr>
22 <td><a href="#EricFileSystemWatcher">EricFileSystemWatcher</a></td>
23 <td>Class implementing a file system monitor based on the 'watchdog' package as a replacement for 'QFileSystemWatcher'.</td>
24 </tr>
25 <tr>
26 <td><a href="#_EricFileSystemEventHandler">_EricFileSystemEventHandler</a></td>
27 <td>Class implementing a QObject based file system event handler for watchdog.</td>
28 </tr>
29 </table>
30
31 <h3>Functions</h3>
32 <table>
33 <tr>
34 <td><a href="#instance">instance</a></td>
35 <td>Function to get a reference to the global file system monitor object.</td>
36 </tr>
37 </table>
38
39 <hr />
40 <hr />
41 <a NAME="EricFileSystemWatcher" ID="EricFileSystemWatcher"></a>
42 <h2>EricFileSystemWatcher</h2>
43 <p>
44 Class implementing a file system monitor based on the 'watchdog' package as a
45 replacement for 'QFileSystemWatcher'.
46 </p>
47 <p>
48 This class has more fine grained signaling capability compared to
49 QFileSystemWatcher. The 'directoryChanged' and 'fileChanged' signals are emitted
50 to keep the API compatible with QFileSystemWatcher.
51 </p>
52
53 <h3>Signals</h3>
54 <dl>
55
56 <dt>directoryChanged(path: str)</dt>
57 <dd>
58 emitted when the directory at a given path is
59 modified or removed from disk
60 </dd>
61 <dt>directoryCreated(path: str)</dt>
62 <dd>
63 emitted when a directory is created
64 </dd>
65 <dt>directoryDeleted(path: str)</dt>
66 <dd>
67 emitted when a directory is removed from disk
68 </dd>
69 <dt>directoryModified(path: str)</dt>
70 <dd>
71 emitted when a directory is modified
72 </dd>
73 <dt>directoryMoved(srcPath: str, dstPath: str)</dt>
74 <dd>
75 emitted when the directory at a
76 given source path is renamed or moved to destination path
77 </dd>
78 <dt>fileChanged(path: str)</dt>
79 <dd>
80 emitted when the file at a given path is modified
81 or removed from disk
82 </dd>
83 <dt>fileCreated(path: str)</dt>
84 <dd>
85 emitted when a file is created
86 </dd>
87 <dt>fileDeleted(path: str)</dt>
88 <dd>
89 emitted when a file is removed from disk
90 </dd>
91 <dt>fileModified(path: str)</dt>
92 <dd>
93 emitted when a file is modified
94 </dd>
95 <dt>fileMoved(srcPath: str, dstPath: str)</dt>
96 <dd>
97 emitted when the file at a
98 given source path is renamed or moved to destination path
99 </dd>
100 </dl>
101 <h3>Derived from</h3>
102 QObject
103 <h3>Class Attributes</h3>
104 <table>
105 <tr><td>None</td></tr>
106 </table>
107
108 <h3>Class Methods</h3>
109 <table>
110 <tr><td>None</td></tr>
111 </table>
112
113 <h3>Methods</h3>
114 <table>
115 <tr>
116 <td><a href="#EricFileSystemWatcher.__init__">EricFileSystemWatcher</a></td>
117 <td>Constructor</td>
118 </tr>
119 <tr>
120 <td><a href="#EricFileSystemWatcher.__del__">__del__</a></td>
121 <td>Special method called when an instance object is about to be destroyed.</td>
122 </tr>
123 <tr>
124 <td><a href="#EricFileSystemWatcher.__directoryChanged">__directoryChanged</a></td>
125 <td>Private slot handling any change of a directory at a given path.</td>
126 </tr>
127 <tr>
128 <td><a href="#EricFileSystemWatcher.__fileChanged">__fileChanged</a></td>
129 <td>Private slot handling any change of a file at a given path.</td>
130 </tr>
131 <tr>
132 <td><a href="#EricFileSystemWatcher.addPath">addPath</a></td>
133 <td>Public method to add the given path to the list of watched paths.</td>
134 </tr>
135 <tr>
136 <td><a href="#EricFileSystemWatcher.addPaths">addPaths</a></td>
137 <td>Public method to add each path of the given list to the file system watched.</td>
138 </tr>
139 <tr>
140 <td><a href="#EricFileSystemWatcher.directories">directories</a></td>
141 <td>Public method to return a list of paths to directories that are being watched.</td>
142 </tr>
143 <tr>
144 <td><a href="#EricFileSystemWatcher.files">files</a></td>
145 <td>Public method to return a list of paths to files that are being watched.</td>
146 </tr>
147 <tr>
148 <td><a href="#EricFileSystemWatcher.paths">paths</a></td>
149 <td>Public method to return a list of paths that are being watched.</td>
150 </tr>
151 <tr>
152 <td><a href="#EricFileSystemWatcher.removePath">removePath</a></td>
153 <td>Public method to remove a given path from the list of monitored paths.</td>
154 </tr>
155 <tr>
156 <td><a href="#EricFileSystemWatcher.removePaths">removePaths</a></td>
157 <td>Public method to remove the specified paths from the list of monitored paths.</td>
158 </tr>
159 <tr>
160 <td><a href="#EricFileSystemWatcher.shutdown">shutdown</a></td>
161 <td>Public method to shut down the file system watcher instance.</td>
162 </tr>
163 </table>
164
165 <h3>Static Methods</h3>
166 <table>
167 <tr><td>None</td></tr>
168 </table>
169
170
171 <a NAME="EricFileSystemWatcher.__init__" ID="EricFileSystemWatcher.__init__"></a>
172 <h4>EricFileSystemWatcher (Constructor)</h4>
173 <b>EricFileSystemWatcher</b>(<i>parent=None</i>)
174 <p>
175 Constructor
176 </p>
177
178 <dl>
179
180 <dt><i>parent</i> (QObject (optional))</dt>
181 <dd>
182 reference to the parent object (defaults to None)
183 </dd>
184 </dl>
185 <a NAME="EricFileSystemWatcher.__del__" ID="EricFileSystemWatcher.__del__"></a>
186 <h4>EricFileSystemWatcher.__del__</h4>
187 <b>__del__</b>(<i></i>)
188 <p>
189 Special method called when an instance object is about to be destroyed.
190 </p>
191
192 <a NAME="EricFileSystemWatcher.__directoryChanged" ID="EricFileSystemWatcher.__directoryChanged"></a>
193 <h4>EricFileSystemWatcher.__directoryChanged</h4>
194 <b>__directoryChanged</b>(<i>path</i>)
195 <p>
196 Private slot handling any change of a directory at a given path.
197 </p>
198 <p>
199 It emits the signal 'directoryChanged', if the path is in the list of
200 watched paths. This behavior is compatible with the QFileSystemWatcher signal
201 of identical name.
202 </p>
203
204 <dl>
205
206 <dt><i>path</i> (str)</dt>
207 <dd>
208 path name of the changed directory
209 </dd>
210 </dl>
211 <a NAME="EricFileSystemWatcher.__fileChanged" ID="EricFileSystemWatcher.__fileChanged"></a>
212 <h4>EricFileSystemWatcher.__fileChanged</h4>
213 <b>__fileChanged</b>(<i>path</i>)
214 <p>
215 Private slot handling any change of a file at a given path.
216 </p>
217 <p>
218 It emits the signal 'fileChanged', if the path is in the list of
219 watched paths. This behavior is compatible with the QFileSystemWatcher signal
220 of identical name.
221 </p>
222
223 <dl>
224
225 <dt><i>path</i> (str)</dt>
226 <dd>
227 path name of the changed file
228 </dd>
229 </dl>
230 <a NAME="EricFileSystemWatcher.addPath" ID="EricFileSystemWatcher.addPath"></a>
231 <h4>EricFileSystemWatcher.addPath</h4>
232 <b>addPath</b>(<i>path, recursive=False</i>)
233 <p>
234 Public method to add the given path to the list of watched paths.
235 </p>
236 <p>
237 If the given path is a directory, a recursive watch may be requested.
238 Otherwise only the given directory is watched for changes but none of its
239 subdirectories.
240 </p>
241 <p>
242 The path is not added, if it does not exist or if it is already being monitored
243 by the file system watcher.
244 </p>
245
246 <dl>
247
248 <dt><i>path</i> (str)</dt>
249 <dd>
250 file or directory path to be added to the watched paths
251 </dd>
252 <dt><i>recursive</i> (bool (optional))</dt>
253 <dd>
254 flag indicating a watch for the complete tree rooted at the
255 given path (for directory paths only) (defaults to False)
256 </dd>
257 </dl>
258 <dl>
259 <dt>Return:</dt>
260 <dd>
261 flag indicating a successful creation of a watch for the given path
262 </dd>
263 </dl>
264 <dl>
265 <dt>Return Type:</dt>
266 <dd>
267 bool
268 </dd>
269 </dl>
270 <a NAME="EricFileSystemWatcher.addPaths" ID="EricFileSystemWatcher.addPaths"></a>
271 <h4>EricFileSystemWatcher.addPaths</h4>
272 <b>addPaths</b>(<i>paths, recursive=False</i>)
273 <p>
274 Public method to add each path of the given list to the file system watched.
275 </p>
276 <p>
277 If a path of the given paths list is a directory, a recursive watch may be
278 requested. Otherwise only the given directory is watched for changes but none
279 of its subdirectories. This applies to all directory paths of the given list.
280 </p>
281 <p>
282 A path of the list is not added, if it does not exist or if it is already being
283 monitored by the file system watcher.
284 </p>
285
286 <dl>
287
288 <dt><i>paths</i> (list of str)</dt>
289 <dd>
290 list of file or directory paths to be added to the watched paths
291 </dd>
292 <dt><i>recursive</i> (bool (optional))</dt>
293 <dd>
294 flag indicating a watch for the complete tree rooted at the
295 given path (for directory paths only) (defaults to False)
296 </dd>
297 </dl>
298 <dl>
299 <dt>Return:</dt>
300 <dd>
301 list of paths that could not be added to the list of monitored paths
302 </dd>
303 </dl>
304 <dl>
305 <dt>Return Type:</dt>
306 <dd>
307 list of str
308 </dd>
309 </dl>
310 <a NAME="EricFileSystemWatcher.directories" ID="EricFileSystemWatcher.directories"></a>
311 <h4>EricFileSystemWatcher.directories</h4>
312 <b>directories</b>(<i></i>)
313 <p>
314 Public method to return a list of paths to directories that are being watched.
315 </p>
316
317 <dl>
318 <dt>Return:</dt>
319 <dd>
320 list of watched directory paths
321 </dd>
322 </dl>
323 <dl>
324 <dt>Return Type:</dt>
325 <dd>
326 list of str
327 </dd>
328 </dl>
329 <a NAME="EricFileSystemWatcher.files" ID="EricFileSystemWatcher.files"></a>
330 <h4>EricFileSystemWatcher.files</h4>
331 <b>files</b>(<i></i>)
332 <p>
333 Public method to return a list of paths to files that are being watched.
334 </p>
335
336 <dl>
337 <dt>Return:</dt>
338 <dd>
339 list of watched file paths
340 </dd>
341 </dl>
342 <dl>
343 <dt>Return Type:</dt>
344 <dd>
345 list of str
346 </dd>
347 </dl>
348 <a NAME="EricFileSystemWatcher.paths" ID="EricFileSystemWatcher.paths"></a>
349 <h4>EricFileSystemWatcher.paths</h4>
350 <b>paths</b>(<i></i>)
351 <p>
352 Public method to return a list of paths that are being watched.
353 </p>
354
355 <dl>
356 <dt>Return:</dt>
357 <dd>
358 list of all watched paths
359 </dd>
360 </dl>
361 <dl>
362 <dt>Return Type:</dt>
363 <dd>
364 list of str
365 </dd>
366 </dl>
367 <a NAME="EricFileSystemWatcher.removePath" ID="EricFileSystemWatcher.removePath"></a>
368 <h4>EricFileSystemWatcher.removePath</h4>
369 <b>removePath</b>(<i>path</i>)
370 <p>
371 Public method to remove a given path from the list of monitored paths.
372 </p>
373
374 <dl>
375
376 <dt><i>path</i> (str)</dt>
377 <dd>
378 directory or file path to be removed
379 </dd>
380 </dl>
381 <dl>
382 <dt>Return:</dt>
383 <dd>
384 flag indicating a successful removal. The only reason for a failure is,
385 if the given path is not currently being monitored.
386 </dd>
387 </dl>
388 <dl>
389 <dt>Return Type:</dt>
390 <dd>
391 bool
392 </dd>
393 </dl>
394 <a NAME="EricFileSystemWatcher.removePaths" ID="EricFileSystemWatcher.removePaths"></a>
395 <h4>EricFileSystemWatcher.removePaths</h4>
396 <b>removePaths</b>(<i>paths</i>)
397 <p>
398 Public method to remove the specified paths from the list of monitored paths.
399 </p>
400
401 <dl>
402
403 <dt><i>paths</i> (list of str)</dt>
404 <dd>
405 list of directory or file paths to be removed
406 </dd>
407 </dl>
408 <dl>
409 <dt>Return:</dt>
410 <dd>
411 list of paths that could not be removed from the list of monitored paths
412 </dd>
413 </dl>
414 <dl>
415 <dt>Return Type:</dt>
416 <dd>
417 list of str
418 </dd>
419 </dl>
420 <a NAME="EricFileSystemWatcher.shutdown" ID="EricFileSystemWatcher.shutdown"></a>
421 <h4>EricFileSystemWatcher.shutdown</h4>
422 <b>shutdown</b>(<i></i>)
423 <p>
424 Public method to shut down the file system watcher instance.
425 </p>
426 <p>
427 This needs to be done in order to stop the monitoring threads doing their
428 work in the background. If this method was not called explicitly when the
429 instance is about to be destroyed, the special method '__del__' will do that.
430 </p>
431
432 <div align="right"><a href="#top">Up</a></div>
433 <hr />
434 <hr />
435 <a NAME="_EricFileSystemEventHandler" ID="_EricFileSystemEventHandler"></a>
436 <h2>_EricFileSystemEventHandler</h2>
437 <p>
438 Class implementing a QObject based file system event handler for watchdog.
439 </p>
440
441 <h3>Signals</h3>
442 <dl>
443
444 <dt>directoryChanged(path: str)</dt>
445 <dd>
446 emitted when the directory at a given path is
447 modified or removed from disk
448 </dd>
449 <dt>directoryCreated(path: str)</dt>
450 <dd>
451 emitted when a directory is created
452 </dd>
453 <dt>directoryDeleted(path: str)</dt>
454 <dd>
455 emitted when a directory is removed from disk
456 </dd>
457 <dt>directoryModified(path: str)</dt>
458 <dd>
459 emitted when a directory is modified
460 </dd>
461 <dt>directoryMoved(srcPath: str, dstPath: str)</dt>
462 <dd>
463 emitted when the directory at a
464 given source path is renamed or moved to destination path
465 </dd>
466 <dt>fileChanged(path: str)</dt>
467 <dd>
468 emitted when the file at a given path is modified
469 or removed from disk
470 </dd>
471 <dt>fileCreated(path: str)</dt>
472 <dd>
473 emitted when a file is created
474 </dd>
475 <dt>fileDeleted(path: str)</dt>
476 <dd>
477 emitted when a file is removed from disk
478 </dd>
479 <dt>fileModified(path: str)</dt>
480 <dd>
481 emitted when a file is modified
482 </dd>
483 <dt>fileMoved(srcPath: str, dstPath: str)</dt>
484 <dd>
485 emitted when the file at a
486 given source path is renamed or moved to destination path
487 </dd>
488 </dl>
489 <h3>Derived from</h3>
490 QObject, FileSystemEventHandler
491 <h3>Class Attributes</h3>
492 <table>
493 <tr><td>None</td></tr>
494 </table>
495
496 <h3>Class Methods</h3>
497 <table>
498 <tr><td>None</td></tr>
499 </table>
500
501 <h3>Methods</h3>
502 <table>
503 <tr>
504 <td><a href="#_EricFileSystemEventHandler.__init__">_EricFileSystemEventHandler</a></td>
505 <td>Constructor</td>
506 </tr>
507 <tr>
508 <td><a href="#_EricFileSystemEventHandler.on_any_event">on_any_event</a></td>
509 <td>Private method handling any file system event.</td>
510 </tr>
511 <tr>
512 <td><a href="#_EricFileSystemEventHandler.on_created">on_created</a></td>
513 <td>Private method to handle a creation event.</td>
514 </tr>
515 <tr>
516 <td><a href="#_EricFileSystemEventHandler.on_deleted">on_deleted</a></td>
517 <td>Private method to handle a deletion event.</td>
518 </tr>
519 <tr>
520 <td><a href="#_EricFileSystemEventHandler.on_modified">on_modified</a></td>
521 <td>Private method to handle a modification event.</td>
522 </tr>
523 <tr>
524 <td><a href="#_EricFileSystemEventHandler.on_moved">on_moved</a></td>
525 <td>Private method to handle a move or rename event.</td>
526 </tr>
527 </table>
528
529 <h3>Static Methods</h3>
530 <table>
531 <tr><td>None</td></tr>
532 </table>
533
534
535 <a NAME="_EricFileSystemEventHandler.__init__" ID="_EricFileSystemEventHandler.__init__"></a>
536 <h4>_EricFileSystemEventHandler (Constructor)</h4>
537 <b>_EricFileSystemEventHandler</b>(<i>parent=None</i>)
538 <p>
539 Constructor
540 </p>
541
542 <dl>
543
544 <dt><i>parent</i> (QObject (optional))</dt>
545 <dd>
546 reference to the parent object (defaults to None)
547 </dd>
548 </dl>
549 <a NAME="_EricFileSystemEventHandler.on_any_event" ID="_EricFileSystemEventHandler.on_any_event"></a>
550 <h4>_EricFileSystemEventHandler.on_any_event</h4>
551 <b>on_any_event</b>(<i>event</i>)
552 <p>
553 Private method handling any file system event.
554 </p>
555
556 <dl>
557
558 <dt><i>event</i> (watchdog.events.FileSystemEvent)</dt>
559 <dd>
560 event to be handled
561 </dd>
562 </dl>
563 <a NAME="_EricFileSystemEventHandler.on_created" ID="_EricFileSystemEventHandler.on_created"></a>
564 <h4>_EricFileSystemEventHandler.on_created</h4>
565 <b>on_created</b>(<i>event</i>)
566 <p>
567 Private method to handle a creation event.
568 </p>
569
570 <dl>
571
572 <dt><i>event</i> (watchdog.events.FileCreatedEvent or watchdog.event.DirCreatedEvent)</dt>
573 <dd>
574 event to be handled
575 </dd>
576 </dl>
577 <a NAME="_EricFileSystemEventHandler.on_deleted" ID="_EricFileSystemEventHandler.on_deleted"></a>
578 <h4>_EricFileSystemEventHandler.on_deleted</h4>
579 <b>on_deleted</b>(<i>event</i>)
580 <p>
581 Private method to handle a deletion event.
582 </p>
583
584 <dl>
585
586 <dt><i>event</i> (watchdog.events.FileDeletedEvent or watchdog.event.DirDeletedEvent)</dt>
587 <dd>
588 event to be handled
589 </dd>
590 </dl>
591 <a NAME="_EricFileSystemEventHandler.on_modified" ID="_EricFileSystemEventHandler.on_modified"></a>
592 <h4>_EricFileSystemEventHandler.on_modified</h4>
593 <b>on_modified</b>(<i>event</i>)
594 <p>
595 Private method to handle a modification event.
596 </p>
597
598 <dl>
599
600 <dt><i>event</i> (watchdog.events.FileModifiedEvent or watchdog.event.DirModifiedEvent)</dt>
601 <dd>
602 event to be handled
603 </dd>
604 </dl>
605 <a NAME="_EricFileSystemEventHandler.on_moved" ID="_EricFileSystemEventHandler.on_moved"></a>
606 <h4>_EricFileSystemEventHandler.on_moved</h4>
607 <b>on_moved</b>(<i>event</i>)
608 <p>
609 Private method to handle a move or rename event.
610 </p>
611
612 <dl>
613
614 <dt><i>event</i> (watchdog.events.FileMovedEvent or watchdog.event.DirMovedEvent)</dt>
615 <dd>
616 event to be handled
617 </dd>
618 </dl>
619 <div align="right"><a href="#top">Up</a></div>
620 <hr />
621 <hr />
622 <a NAME="instance" ID="instance"></a>
623 <h2>instance</h2>
624 <b>instance</b>(<i></i>)
625 <p>
626 Function to get a reference to the global file system monitor object.
627 </p>
628 <p>
629 If the global file system monitor does not exist yet, it will be created
630 automatically.
631 </p>
632
633 <dl>
634 <dt>Return:</dt>
635 <dd>
636 reference to the global file system monitor object
637 </dd>
638 </dl>
639 <dl>
640 <dt>Return Type:</dt>
641 <dd>
642 EricFileSystemWatcher
643 </dd>
644 </dl>
645 <div align="right"><a href="#top">Up</a></div>
646 <hr />
647 </body></html>

eric ide

mercurial