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

add support for not splitting "contains" value #6773

Closed
wants to merge 1 commit into from

Conversation

zWolfrost
Copy link
Contributor

I've encountered situations where I wanted to filter out images with a blacklist of words in the filename (e.g. "low res", "lr", "preview", as well as their capitalized version) and the filter gets verbose really quickly. The "contains" function would be perfect to avoid this, but as of now you are forced to split the "values" parameter, which makes it unusable for filenames and such, and only useful for tags.
This could be a possible enhancement, where if the third parameter "separator" is set to "None" then the value won't get split, extending the function purposes.

@mikf
Copy link
Owner

mikf commented Jan 5, 2025

You can already avoid values being split into separate "tags" by providing it as a 1-element list or tuple instead of a plain string value:

contains((filename,), ("low res", "lr", "preview"))

Also, maybe using regular expressions like re.search(r'(?i)low res|lr|preview', filename) would be better than using contains(), which was initially added for tags only.

You can also define and add custom functions and symbols using the globals option and a separate .py file / Python module.

@zWolfrost
Copy link
Contributor Author

Hi, I'm afraid if the filename is contained in a 1-element tuple then the contains method will only check if one of the elements is in that tuple, or in other words if one of the elements is exactly equal to the filename, which is not what I want.
Nevertheless, the other options you've given me should work fine. Thanks for the help.

@zWolfrost zWolfrost closed this Jan 5, 2025
mikf added a commit that referenced this pull request Jan 6, 2025
by passing any "false" value as 'separator' argument except None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants