def iter_filtered_dir_entry(dir_entries, match_patterns, on_skip):
def match(dir_entry_path, match_patterns, on_skip):<EOL><INDENT>for match_pattern in match_patterns:<EOL><INDENT>if dir_entry_path.path_instance.match(match_pattern):<EOL><INDENT>on_skip(dir_entry_path, match_pattern)<EOL>return True<EOL><DEDENT><DEDENT>return False<EOL><DEDENT>for entry in dir_entries:<EOL><INDENT>try:<EOL><INDENT>dir_entry_path = DirEntryPath(entry)<EOL><DEDENT>except FileNotFoundError as err:<EOL><INDENT>log.error("<STR_LIT>" % err)<EOL>continue<EOL><DEDENT>if match(dir_entry_path, match_patterns, on_skip):<EOL><INDENT>yield None<EOL><DEDENT>else:<EOL><INDENT>yield dir_entry_path<EOL><DEDENT><DEDENT>
Filter a list of DirEntryPath instances with the given pattern

:param dir_entries: list of DirEntryPath instances
:param match_patterns: used with Path.match()
    e.g.: "__pycache__/*", "*.tmp", "*.cache"
:param on_skip: function that will be called if 'match_patterns' hits.
    e.g.:
    def on_skip(entry, pattern):
        log.error("Skip pattern %r hit: %s" % (pattern, entry.path))
:return: yields None or DirEntryPath instances