def scandir_walk(top, skip_dirs=(), on_skip=None):
<EOL>try:<EOL><INDENT>scandir_it = Path2(top).scandir()<EOL><DEDENT>except PermissionError as err:<EOL><INDENT>log.error("<STR_LIT>" % err)<EOL>return<EOL><DEDENT>for entry in scandir_it:<EOL><INDENT>if entry.is_dir(follow_symlinks=False):<EOL><INDENT>if entry.name in skip_dirs:<EOL><INDENT>on_skip(entry, entry.name)<EOL><DEDENT>else:<EOL><INDENT>yield from scandir_walk(entry.path, skip_dirs, on_skip)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>yield entry<EOL><DEDENT><DEDENT>
Just walk the filesystem tree top-down with os.scandir() and don't follow symlinks.
:param top: path to scan
:param skip_dirs: List of dir names to skip
    e.g.: "__pycache__", "temp", "tmp"
:param on_skip: function that will be called if 'skip_dirs' match.
    e.g.:
    def on_skip(entry, pattern):
        log.error("Skip pattern %r hit: %s" % (pattern, entry.path))
:return: yields os.DirEntry() instances