diff --git a/src/items/AItems.py b/src/items/AItems.py index 8022440..5d1d86d 100644 --- a/src/items/AItems.py +++ b/src/items/AItems.py @@ -1,4 +1,4 @@ -from abc import ABC +from abc import ABC, abstractmethod from pathlib import Path @@ -27,6 +27,10 @@ class AItem(ABC): def __str__(self) -> str: return f"{self.name}, {self.size}, {self.permissions}" + @abstractmethod + def is_navigable(self) -> bool: + ... + @property def path(self) -> Path: return self._path diff --git a/src/items/File.py b/src/items/File.py index 2ce0138..7fb9cf7 100644 --- a/src/items/File.py +++ b/src/items/File.py @@ -7,3 +7,6 @@ class File(AItem): def __init__(self, path: Path) -> None: super().__init__(path) + + def is_navigable(self) -> bool: + return False diff --git a/src/items/Folder.py b/src/items/Folder.py index 2bf27fd..2f6bb71 100644 --- a/src/items/Folder.py +++ b/src/items/Folder.py @@ -23,3 +23,6 @@ class Folder(AItem): except FileNotFoundError: pass return items + + def is_navigable(self) -> bool: + return True diff --git a/src/items/Symlink.py b/src/items/Symlink.py index 4904ede..bda2234 100644 --- a/src/items/Symlink.py +++ b/src/items/Symlink.py @@ -29,3 +29,8 @@ class Symlink(AItem): @property def point_to(self) -> Path: return self._point_to + + def is_navigable(self) -> bool: + if None is self.point_to: + return False + return self.point_to.is_dir()