feat: add is_navigable to item hierarchy
This commit is contained in:
parent
7d448de62a
commit
017217de7c
4 changed files with 16 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -7,3 +7,6 @@ class File(AItem):
|
|||
|
||||
def __init__(self, path: Path) -> None:
|
||||
super().__init__(path)
|
||||
|
||||
def is_navigable(self) -> bool:
|
||||
return False
|
||||
|
|
|
|||
|
|
@ -23,3 +23,6 @@ class Folder(AItem):
|
|||
except FileNotFoundError:
|
||||
pass
|
||||
return items
|
||||
|
||||
def is_navigable(self) -> bool:
|
||||
return True
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue