do not depend on fusepy and pyfzf

fix-36
deadc0de6 1 year ago
parent 59333441ee
commit 59cb7bc953

@ -23,7 +23,6 @@ from catcli.catalog import Catalog
from catcli.walker import Walker
from catcli.noder import Noder
from catcli.utils import ask, edit, path_to_search_all
from catcli.fuser import Fuser
from catcli.exceptions import BadFormatException, CatcliException
NAME = 'catcli'
@ -82,12 +81,18 @@ Options:
def cmd_mount(args: Dict[str, Any],
top: NodeTop,
noder: Noder) -> None:
noder: Noder) -> bool:
"""mount action"""
mountpoint = args['<mountpoint>']
debug = args['--verbose']
Fuser(mountpoint, top, noder,
debug=debug)
try:
from catcli.fuser import Fuser # pylint: disable=C0415
Fuser(mountpoint, top, noder,
debug=debug)
except ModuleNotFoundError:
Logger.err('install fusepy to use mount')
return False
return True
def cmd_index(args: Dict[str, Any],
@ -346,7 +351,8 @@ def main() -> bool:
if not catalog.exists():
Logger.err(f'no such catalog: {catalog_path}')
return False
cmd_mount(args, top, noder)
if not cmd_mount(args, top, noder):
return False
elif args['rm']:
if not catalog.exists():
Logger.err(f'no such catalog: {catalog_path}')

@ -9,7 +9,10 @@ import os
from time import time
from stat import S_IFDIR, S_IFREG
from typing import List, Dict, Any, Optional
import fuse # type: ignore
try:
import fuse # type: ignore
except ModuleNotFoundError:
pass
# local imports
from catcli.noder import Noder

@ -10,7 +10,6 @@ import shutil
import time
from typing import List, Union, Tuple, Any, Optional, Dict, cast
import anytree # type: ignore
from pyfzf.pyfzf import FzfPrompt # type: ignore
# local imports
from catcli import nodes
@ -506,10 +505,15 @@ class Noder:
@staticmethod
def _fzf_prompt(strings: Any) -> Any:
# prompt with fzf
fzf = FzfPrompt()
selected = fzf.prompt(strings)
return selected
"""prompt with fzf"""
try:
from pyfzf.pyfzf import FzfPrompt # type: ignore # pylint: disable=C0415 # noqa
fzf = FzfPrompt()
selected = fzf.prompt(strings)
return selected
except ModuleNotFoundError:
Logger.err('install pyfzf to use fzf')
return None
def _to_fzf(self, node: NodeAny, fmt: str) -> None:
"""

Loading…
Cancel
Save