mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Rename _to_load to _load_queue
As per https://github.com/Textualize/textual/pull/2545#discussion_r1196580316
This commit is contained in:
@@ -118,7 +118,7 @@ class DirectoryTree(Tree[DirEntry]):
|
|||||||
classes: A space-separated list of classes, or None for no classes.
|
classes: A space-separated list of classes, or None for no classes.
|
||||||
disabled: Whether the directory tree is disabled or not.
|
disabled: Whether the directory tree is disabled or not.
|
||||||
"""
|
"""
|
||||||
self._to_load: Queue[TreeNode[DirEntry]] = Queue()
|
self._load_queue: Queue[TreeNode[DirEntry]] = Queue()
|
||||||
super().__init__(
|
super().__init__(
|
||||||
str(path),
|
str(path),
|
||||||
data=DirEntry(Path(path)),
|
data=DirEntry(Path(path)),
|
||||||
@@ -133,12 +133,12 @@ class DirectoryTree(Tree[DirEntry]):
|
|||||||
"""Reload the `DirectoryTree` contents."""
|
"""Reload the `DirectoryTree` contents."""
|
||||||
self.reset(str(self.path), DirEntry(Path(self.path)))
|
self.reset(str(self.path), DirEntry(Path(self.path)))
|
||||||
# Orphan the old queue...
|
# Orphan the old queue...
|
||||||
self._to_load = Queue()
|
self._load_queue = Queue()
|
||||||
# ...and replace the old load with a new one.
|
# ...and replace the old load with a new one.
|
||||||
self._loader()
|
self._loader()
|
||||||
# We have a fresh queue, we have a fresh loader, get the fresh root
|
# We have a fresh queue, we have a fresh loader, get the fresh root
|
||||||
# loading up.
|
# loading up.
|
||||||
self._to_load.put_nowait(self.root)
|
self._load_queue.put_nowait(self.root)
|
||||||
|
|
||||||
def validate_path(self, path: str | Path) -> Path:
|
def validate_path(self, path: str | Path) -> Path:
|
||||||
"""Ensure that the path is of the `Path` type.
|
"""Ensure that the path is of the `Path` type.
|
||||||
@@ -318,7 +318,7 @@ class DirectoryTree(Tree[DirEntry]):
|
|||||||
while not worker.is_cancelled:
|
while not worker.is_cancelled:
|
||||||
# Get the next node that needs loading off the queue. Note that
|
# Get the next node that needs loading off the queue. Note that
|
||||||
# this blocks if the queue is empty.
|
# this blocks if the queue is empty.
|
||||||
node = await self._to_load.get()
|
node = await self._load_queue.get()
|
||||||
content: list[Path] = []
|
content: list[Path] = []
|
||||||
try:
|
try:
|
||||||
# Spin up a short-lived thread that will load the content of
|
# Spin up a short-lived thread that will load the content of
|
||||||
@@ -337,7 +337,7 @@ class DirectoryTree(Tree[DirEntry]):
|
|||||||
if content:
|
if content:
|
||||||
self._populate_node(node, content)
|
self._populate_node(node, content)
|
||||||
# Mark this iteration as done.
|
# Mark this iteration as done.
|
||||||
self._to_load.task_done()
|
self._load_queue.task_done()
|
||||||
|
|
||||||
def _on_tree_node_expanded(self, event: Tree.NodeExpanded) -> None:
|
def _on_tree_node_expanded(self, event: Tree.NodeExpanded) -> None:
|
||||||
event.stop()
|
event.stop()
|
||||||
@@ -346,7 +346,7 @@ class DirectoryTree(Tree[DirEntry]):
|
|||||||
return
|
return
|
||||||
if self._safe_is_dir(dir_entry.path):
|
if self._safe_is_dir(dir_entry.path):
|
||||||
if not dir_entry.loaded:
|
if not dir_entry.loaded:
|
||||||
self._to_load.put_nowait(event.node)
|
self._load_queue.put_nowait(event.node)
|
||||||
else:
|
else:
|
||||||
self.post_message(self.FileSelected(self, event.node, dir_entry.path))
|
self.post_message(self.FileSelected(self, event.node, dir_entry.path))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user