Rename dir_name -> path_segment since it can refer to a file

This commit is contained in:
Isaiah Odhner 2023-04-20 22:54:39 -04:00
parent 1f260aaeef
commit e9218e1c75

View File

@ -9,13 +9,13 @@ class EnhancedDirectoryTree(DirectoryTree):
node = self.root node = self.root
def get_node_name(node): def get_node_name(node):
return os.path.basename(node.data.path.rstrip(os.path.sep)) return os.path.basename(node.data.path.rstrip(os.path.sep))
for dir_name in target_path.split(os.path.sep): for path_segment in target_path.split(os.path.sep):
# Find the child node with the right name. # Find the child node with the right name.
for child in node.children: for child in node.children:
if get_node_name(child) == dir_name: if get_node_name(child) == path_segment:
node = child node = child
break break
if get_node_name(node) == dir_name: if get_node_name(node) == path_segment:
if node.data.is_dir: if node.data.is_dir:
if not node.is_expanded and not node.data.loaded: if not node.is_expanded and not node.data.loaded:
# load_directory also calls node.expand() # load_directory also calls node.expand()