Monitoring a single file
The way to provide patterns for PatternMatchingEventHandler
is
from watchdog.events import PatternMatchingEventHandler
class MyHandler(PatternMatchingEventHandler):
patterns = ["*.xml", "*.log", "*/test.txt"] # */test.txt to watch that specifi file
If you want to watch a file path like C:/dict1/dict2/file.txt
, I think that's your pattern right there. There are no wildcards in, so it should be usable as-is.
As an aside, if Watchdog is giving you trouble, you could also consider Pyinotify: https://github.com/seb-m/pyinotify