Add base class for directory visitor (#32008)
This commit is contained in:
@@ -729,7 +729,7 @@ def test_lexists_islink_isdir(tmpdir):
|
||||
assert fs.lexists_islink_isdir(symlink_to_symlink_to_file) == (True, True, False)
|
||||
|
||||
|
||||
class RegisterVisitor(object):
|
||||
class RegisterVisitor(fs.BaseDirectoryVisitor):
|
||||
"""A directory visitor that keeps track of all visited paths"""
|
||||
|
||||
def __init__(self, root, follow_dirs=True, follow_symlink_dirs=True):
|
||||
@@ -751,6 +751,9 @@ def visit_file(self, root, rel_path, depth):
|
||||
self.check(root, rel_path, depth)
|
||||
self.files.append(rel_path)
|
||||
|
||||
def visit_symlinked_file(self, root, rel_path, depth):
|
||||
self.visit_file(root, rel_path, depth)
|
||||
|
||||
def before_visit_dir(self, root, rel_path, depth):
|
||||
self.check(root, rel_path, depth)
|
||||
self.dirs_before.append(rel_path)
|
||||
|
||||
Reference in New Issue
Block a user