JohannesWiesner / nisupply

A python module for data management of semi/unstructured neuroimaging datasets
MIT License
3 stars 0 forks source link

Allow to exclude files if they contain a specific order of unwanted directories #30

Open JohannesWiesner opened 2 weeks ago

JohannesWiesner commented 2 weeks ago

Example:

I only want files that include pre/standard_direct in their filepath but I want to drop files that contain pre/standard.

Because the string pre/standard_direct contains pre/standard it's hard to work with exact string matches. If I tell nisupply to exclude all strings that include pre/standard, I would also exclude pre/standard_direct.

This would be basically an extension to the exclude_dirs argument (maybe exclude_nested_dirs would be a good name for this argument?)

JohannesWiesner commented 2 weeks ago

This logic was already implemented in the past:

https://github.com/JohannesWiesner/nisupply/blob/fa69fac9b818b816488ece18a083c55b3ddeac55/nisupply.py#L90-L107

We can split up each filepath into its path components (break on os.sep). We can also split up the user input into it's path components. We can then check if the filepath contains a chain of path components that match the input path components.