style: flake8
This commit is contained in:
parent
d1b65c5c54
commit
78cde86e85
8 changed files with 26 additions and 16 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -7,4 +7,3 @@ class File(AItem):
|
|||
|
||||
def __init__(self, path: Path) -> None:
|
||||
super().__init__(path)
|
||||
|
||||
|
|
|
|||
|
|
@ -23,4 +23,3 @@ class Folder(AItem):
|
|||
except FileNotFoundError:
|
||||
pass
|
||||
return items
|
||||
|
||||
|
|
|
|||
|
|
@ -3,16 +3,19 @@ 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:
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue