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():
|
class App():
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Raise:
|
Raise:
|
||||||
FileNotFoundError can append in __init__
|
FileNotFoundError can append in __init__
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, path: Path) -> None:
|
def __init__(self, path: Path) -> None:
|
||||||
self._history = []
|
self._history = []
|
||||||
self._items = []
|
self._items = []
|
||||||
|
|
@ -34,13 +36,13 @@ class App():
|
||||||
try:
|
try:
|
||||||
self._current = Folder(self.history[-1])
|
self._current = Folder(self.history[-1])
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pass # doubt
|
pass
|
||||||
stdscr.addstr(0, 0, str(self.history[-1]))
|
stdscr.addstr(0, 0, str(self.history[-1]))
|
||||||
self.UI.render(stdscr)
|
self.UI.render(stdscr)
|
||||||
stdscr.refresh()
|
stdscr.refresh()
|
||||||
key = stdscr.getkey()
|
key = stdscr.getkey()
|
||||||
self._items = self.current.children()
|
self._items = self.current.children()
|
||||||
if False == self.input.handle(key):
|
if False is self.input.handle(key):
|
||||||
break
|
break
|
||||||
|
|
||||||
def run(self) -> None:
|
def run(self) -> None:
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,9 @@ class Cursor:
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self._pos = 0
|
self._pos = 0
|
||||||
|
|
||||||
|
def resete(self) -> None:
|
||||||
|
set._pos = 0
|
||||||
|
|
||||||
def up(self) -> None:
|
def up(self) -> None:
|
||||||
self._pos -= 1 if self.pos >= 1 else 0
|
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
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
class AItem(ABC):
|
class AItem(ABC):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Raises:
|
Raises:
|
||||||
FileNotFoundError: if the given path does not exist on the FS
|
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:
|
def __init__(self, path: Path) -> None:
|
||||||
self._path = path
|
self._path = path
|
||||||
self.update()
|
self.update()
|
||||||
|
|
@ -43,4 +46,3 @@ class AItem(ABC):
|
||||||
@property
|
@property
|
||||||
def color_pair(self) -> int:
|
def color_pair(self) -> int:
|
||||||
return self.COLOR
|
return self.COLOR
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,4 +7,3 @@ class File(AItem):
|
||||||
|
|
||||||
def __init__(self, path: Path) -> None:
|
def __init__(self, path: Path) -> None:
|
||||||
super().__init__(path)
|
super().__init__(path)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,4 +23,3 @@ class Folder(AItem):
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pass
|
pass
|
||||||
return items
|
return items
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,25 +3,28 @@ from .AItems import AItem
|
||||||
from .File import File
|
from .File import File
|
||||||
from .Folder import Folder
|
from .Folder import Folder
|
||||||
|
|
||||||
|
|
||||||
class Symlink(AItem):
|
class Symlink(AItem):
|
||||||
COLOR = 3
|
COLOR = 3
|
||||||
|
|
||||||
def __init__(self, path: Path) -> None:
|
def __init__(self, path: Path) -> None:
|
||||||
super().__init__(path)
|
super().__init__(path)
|
||||||
self._point_to = path.resolve()
|
self._point_to = path.resolve()
|
||||||
if False == self._point_to.exists():
|
if not self._point_to.exists():
|
||||||
self._point_to = None
|
self._point_to = None
|
||||||
|
|
||||||
def __str__(self) -> str:
|
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
|
@staticmethod
|
||||||
def target_color(point_to: Path | None) -> int:
|
def target_color(point_to: Path | None) -> int:
|
||||||
if point_to is None:
|
if point_to is None:
|
||||||
return 5
|
return 5
|
||||||
elif point_to.is_dir():
|
elif point_to.is_dir():
|
||||||
return Folder.COLOR
|
return Folder.COLOR
|
||||||
else:
|
else:
|
||||||
return File.COLOR
|
return File.COLOR
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def point_to(self) -> Path:
|
def point_to(self) -> Path:
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ from .Folder import Folder
|
||||||
from .Symlink import Symlink
|
from .Symlink import Symlink
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
def make_item(path: Path) -> AItem:
|
def make_item(path: Path) -> AItem:
|
||||||
if path.is_symlink():
|
if path.is_symlink():
|
||||||
return Symlink(path)
|
return Symlink(path)
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ from .core.App import App
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def main() -> int:
|
def main() -> int:
|
||||||
path: None | Path = None
|
path: None | Path = None
|
||||||
try:
|
try:
|
||||||
|
|
@ -14,6 +15,6 @@ def main() -> int:
|
||||||
pyExp.run()
|
pyExp.run()
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue