Scheduling events to fire on HTML documents in a first-level subdirectory of a given directory

9 views
Skip to first unread message

Stuart Simon

unread,
Jul 7, 2016, 10:02:32 AM7/7/16
to watchdog-python
Hello!
I am new to Watchdog and Python event scheduling in general. I come from a JavaScript background and have experience in writing event handlers in Web pages. JavaScript events usually "bubble up" from child to parent in the document tree, so it is easy to make events trigger for elements not yet created in the document tree by attaching the event to a parent element that has been created already. Which is what I want to simulate here.

I would like to have an event fire whenever an HTML document is created or modified within a first-level subdirectory of a given directory, regardless of whether or not said subdirectory exists at the time I schedule the master watch on the parent directory. I know about pattern- and regex-matching event handlers: they are what I use to make sure that the events fire only on HTML documents. But I don't know if I can use them to match files by directory. If they cannot, then I would like to know to schedule an unknown number of watches.

If I can match files by directory, would the regex be "^\.\\[^\/\\]*\\[^\/\\]*\.html?$" on Windows? Thank you!

Stuart Simon
Reply all
Reply to author
Forward
0 new messages