Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: InotifyTree depth, or path mask #105

Open
EsipovPA opened this issue Sep 27, 2023 · 0 comments
Open

Feature: InotifyTree depth, or path mask #105

EsipovPA opened this issue Sep 27, 2023 · 0 comments

Comments

@EsipovPA
Copy link

EsipovPA commented Sep 27, 2023

Feature description
Add tree_depth parameter to an InotifyTree __init__, thus add option to limit the number of created watchers. Or add watch path_mask.

Problem at hand
I have a wast tree of directories that goes something like this:

- parent_dir
  - date
    - time
      - [some_data_files]

The files from date/time are being constantly removed from my system and new date and time directories are being added. Let's say this operations are performed at random order. For my purposes, it would be convenient to add watchers only to first 3 levels of this tree, or add a filter predicate at the beginning of the process.

Possible resulting interface
The resulting interface, as I see it, might be something like this:

import inotofy.adapters

tree_watcher = inotify.adapters.InotifyTree("/my/folder/path", tree_depth=2)

for event in tree_watcher.event_gen():
    # do my work here

or something like this:

import inotofy.adapters

tree_watcher = inotify.adapters.Inotfy()
watcher = tree_watcher.add_watch("/my/folder/path/*/*")

for event in watcher.event_gen():
    # do my work here

or even something like this

import inotofy.adapters

tree_watcher = inotify.adapters.InotifyTree("/my/folder/path", filter_mask="(.+)?.my.file.path.regex")

for event in watcher.event_gen():
    # do my work here

If I understand this correctly, there is no way to do it with current implementation. Or is there some way?
I think I'll try to add a patch on my side for this, but if this may be interesting to anyone here, I'd be glad to share it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant