iterglob_infos_incl_excl#
- barecat.util.glob_helper.GlobHelper.iterglob_infos_incl_excl(rules, default_include=True, only_files=False, bufsize=None)[source]#
Iterate over infos matching rsync-style include/exclude rules.
Uses “first match wins” semantics: each file is tested against rules in order, and the first matching rule determines inclusion/exclusion.
- Parameters:
rules (list[tuple[str, str]]) – List of (sign, pattern) tuples. sign is ‘+’ for include, ‘-’ for exclude. Patterns use Python glob syntax with ** support.
default_include (bool) – If no rule matches, include (True) or exclude (False).
only_files (bool) – Whether to return only files, not directories.
bufsize (Optional[int]) – Buffer size for fetching rows.
- Returns:
Iterator over matching file/directory info objects.
- Return type:
Iterator[barecat.core.types.BarecatEntryInfo]
Example
- rules = [
(‘+’, ‘/thumbs/important.jpg’), # include this specific file (‘-’, ‘/thumbs/’), # exclude other thumbs (‘+’, ‘*/*.jpg’), # include all other jpgs
] # Files not matching any rule: included (default_include=True)