Skip to content

match_all_filters

match_all_filters(path, filters)

Check if input path satisfies all the filters.

.. versionadded:: 0.8.0

Parameters:

  • path (:obj:onetl.base.path_protocol.PathProtocol) –

    Path to check.

  • filters (iterable[:obj:(BaseFileFilter)]) –

    Filters to test path against.

Returns:

  • ``True`` if path matches all the filters, ``False`` otherwise.
  • If filters are empty, returns ``True``.

Examples:

>>> from onetl.file.filter import Glob, ExcludeDir, match_all_filters
>>> from onetl.impl import RemoteFile, RemotePathStat
>>> filters = [Glob("*.csv"), ExcludeDir("/excluded")]
>>> match_all_filters(RemoteFile("/path/to/file.csv", stats=RemotePathStat()), filters)
True
>>> match_all_filters(RemoteFile("/path/to/file.txt", stats=RemotePathStat()), filters)
False
>>> match_all_filters(RemoteFile("/excluded/path/file.csv", stats=RemotePathStat()), filters)
False