Skip to content

Documentation issue with python callbacks in FilesCatalog package #254

Description

@ueffel

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.
I stumbled upon this while write my own callback function and was confused that so many items weren't filtered out and landed in my catalog.
Here is the original bit of code that should do the filtering:

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions