Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Documentation issue with python callbacks in FilesCatalog package #254
In the template file for user defined python callbacks it says:
... # As an example, here is how a callback function could be implemented. # This code mimics the default callback implemented in filescatalog.py:
After that there is a template callback. This callback function however does not do the filtering right. That is to say, it doesn't do it like the rest of the package.
for filter in profile.filters: if filter.match(entry): if not filter.inclusive: return None break
If there is only an inclusive filter, it doesn't exclude items that aren't matching.
My suggestion for an improvement:
include = len(profile.filters) == 0 # if there are no filters, always include for filter in profile.filters: if filter.match(entry): include = filter.inclusive break if not include: return None
Yes I forgot to replicate the modifications made to
In fact, the way filters is interpreted in that regard has been modified already for the next version as explained in #253 (comment), so the documentation has been updated already.
See the dev branch of the Packages repo for the details. Caution though:
So wait the template got updated, but it still doesn't do it like you commented:
Suppose you have one positive (inclusive) and one negative (exclusive) filter, like
... filters = + ext: .txt - ext: .exe
The default behavior would only put
With the next release (dev branch), the filters of your example will only include
The new behavior to be released is meant to be more intuitive than the current one. So if for some reason you believe it could be improved, shoot before I roll the release :)
You mean there's a bug in the dev branch? I will double-check.