root / exclude.py

Revision ca5ddc5f5eea62c76b6be75a1fbdedf663dbcfd0, 0.7 kB (checked in by Sebastien Martini <ookoi@…>, 5 months ago)

Flag example files as 'Example'.

  • Property mode set to 100644
Line 
1# Example
2#
3import pyinotify
4import os
5
6excl_file = os.path.join(os.getcwd(), 'exclude.patterns')
7
8wm = pyinotify.WatchManager()
9notifier = pyinotify.Notifier(wm)
10
11
12### Method 1:
13# Exclude filter object
14excl = pyinotify.ExcludeFilter({excl_file: ('excl_lst1', 'excl_lst2')})
15# Add watches
16wm.add_watch(['/etc/*', '/var'], pyinotify.ALL_EVENTS,
17             rec=True, do_glob=True, exclude_filter=excl)
18
19
20### Method 2 (Equivalent)
21wm.add_watch('/etc/*', pyinotify.ALL_EVENTS, rec=True, do_glob=True,
22             exclude_filter=pyinotify.ExcludeFilter({excl_file:('excl_lst1',)}))
23wm.add_watch('/var', pyinotify.ALL_EVENTS, rec=True,
24             exclude_filter=pyinotify.ExcludeFilter({excl_file:('excl_lst2',)}))
25
26
27notifier.loop()
Note: See TracBrowser for help on using the browser.