def scandir_limited(top, limit, deep=<NUM_LIT:0>):
deep += <NUM_LIT:1><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 deep < limit:<EOL><INDENT>yield from scandir_limited(entry.path, limit, deep)<EOL><DEDENT>else:<EOL><INDENT>yield entry<EOL><DEDENT><DEDENT><DEDENT>
yields only directories with the given deep limit

:param top: source path
:param limit: how deep should be scanned?
:param deep: internal deep number
:return: yields os.DirEntry() instances