feat: add is_navigable to item hierarchy

This commit is contained in:
lohhiiccc 2026-07-02 18:27:13 +02:00
parent 7d448de62a
commit 017217de7c
4 changed files with 16 additions and 1 deletions

View file

@ -1,4 +1,4 @@
from abc import ABC from abc import ABC, abstractmethod
from pathlib import Path from pathlib import Path
@ -27,6 +27,10 @@ class AItem(ABC):
def __str__(self) -> str: def __str__(self) -> str:
return f"{self.name}, {self.size}, {self.permissions}" return f"{self.name}, {self.size}, {self.permissions}"
@abstractmethod
def is_navigable(self) -> bool:
...
@property @property
def path(self) -> Path: def path(self) -> Path:
return self._path return self._path

View file

@ -7,3 +7,6 @@ class File(AItem):
def __init__(self, path: Path) -> None: def __init__(self, path: Path) -> None:
super().__init__(path) super().__init__(path)
def is_navigable(self) -> bool:
return False

View file

@ -23,3 +23,6 @@ class Folder(AItem):
except FileNotFoundError: except FileNotFoundError:
pass pass
return items return items
def is_navigable(self) -> bool:
return True

View file

@ -29,3 +29,8 @@ class Symlink(AItem):
@property @property
def point_to(self) -> Path: def point_to(self) -> Path:
return self._point_to return self._point_to
def is_navigable(self) -> bool:
if None is self.point_to:
return False
return self.point_to.is_dir()