diff --git a/src/core/App.py b/src/core/App.py index 7e63a17..a06b509 100644 --- a/src/core/App.py +++ b/src/core/App.py @@ -7,10 +7,12 @@ import curses class App(): + """ Raise: FileNotFoundError can append in __init__ """ + def __init__(self, path: Path) -> None: self._history = [] self._items = [] @@ -34,13 +36,13 @@ class App(): try: self._current = Folder(self.history[-1]) except FileNotFoundError: - pass # doubt + pass stdscr.addstr(0, 0, str(self.history[-1])) self.UI.render(stdscr) stdscr.refresh() key = stdscr.getkey() self._items = self.current.children() - if False == self.input.handle(key): + if False is self.input.handle(key): break def run(self) -> None: diff --git a/src/core/Cursor.py b/src/core/Cursor.py index 7b81139..c79d7a6 100644 --- a/src/core/Cursor.py +++ b/src/core/Cursor.py @@ -3,6 +3,9 @@ class Cursor: def __init__(self) -> None: self._pos = 0 + def resete(self) -> None: + set._pos = 0 + def up(self) -> None: self._pos -= 1 if self.pos >= 1 else 0 diff --git a/src/items/AItems.py b/src/items/AItems.py index b8c6113..8022440 100644 --- a/src/items/AItems.py +++ b/src/items/AItems.py @@ -1,13 +1,16 @@ -from abc import ABC, abstractmethod +from abc import ABC from pathlib import Path class AItem(ABC): + """ Raises: FileNotFoundError: if the given path does not exist on the FS - PermissionError: if the process lacks permission to read the file metadata + PermissionError: if the process lacks permission to read the file + metadata """ + def __init__(self, path: Path) -> None: self._path = path self.update() @@ -43,4 +46,3 @@ class AItem(ABC): @property def color_pair(self) -> int: return self.COLOR - diff --git a/src/items/File.py b/src/items/File.py index 8920973..2ce0138 100644 --- a/src/items/File.py +++ b/src/items/File.py @@ -7,4 +7,3 @@ class File(AItem): def __init__(self, path: Path) -> None: super().__init__(path) - diff --git a/src/items/Folder.py b/src/items/Folder.py index eb949e4..2bf27fd 100644 --- a/src/items/Folder.py +++ b/src/items/Folder.py @@ -23,4 +23,3 @@ class Folder(AItem): except FileNotFoundError: pass return items - diff --git a/src/items/Symlink.py b/src/items/Symlink.py index aafe0df..4904ede 100644 --- a/src/items/Symlink.py +++ b/src/items/Symlink.py @@ -3,25 +3,28 @@ from .AItems import AItem from .File import File from .Folder import Folder + class Symlink(AItem): COLOR = 3 + def __init__(self, path: Path) -> None: super().__init__(path) self._point_to = path.resolve() - if False == self._point_to.exists(): + if not self._point_to.exists(): self._point_to = None def __str__(self) -> str: - return f"{self.name} -> {'(broken)' if None == self.point_to else self.point_to.name}" + return f"{self.name} -> {'(broken)' if self.point_to is None else + self.point_to.name}" @staticmethod def target_color(point_to: Path | None) -> int: - if point_to is None: - return 5 - elif point_to.is_dir(): - return Folder.COLOR - else: - return File.COLOR + if point_to is None: + return 5 + elif point_to.is_dir(): + return Folder.COLOR + else: + return File.COLOR @property def point_to(self) -> Path: diff --git a/src/items/factory.py b/src/items/factory.py index c0907f7..55b3e17 100644 --- a/src/items/factory.py +++ b/src/items/factory.py @@ -4,6 +4,7 @@ from .Folder import Folder from .Symlink import Symlink from pathlib import Path + def make_item(path: Path) -> AItem: if path.is_symlink(): return Symlink(path) diff --git a/src/main.py b/src/main.py index a22acef..ab2a8ce 100644 --- a/src/main.py +++ b/src/main.py @@ -2,6 +2,7 @@ from .core.App import App from pathlib import Path import sys + def main() -> int: path: None | Path = None try: @@ -14,6 +15,6 @@ def main() -> int: pyExp.run() return 0 + if __name__ == "__main__": main() -