features-42
deadc0de6 4 months ago
parent 4aaa073603
commit ff02f9bb97

@ -1,3 +1,4 @@
[mypy]
strict = true
disable_error_code = import-untyped,import-not-found
disable_error_code = import-untyped,import-not-found
ignore_missing_imports = True

@ -7,9 +7,9 @@ Class that represents the catcli catalog
import os
from typing import Optional, List, Dict, Tuple, Union, Any
from anytree.exporter import JsonExporter, DictExporter # type: ignore
from anytree.importer import JsonImporter # type: ignore
from anytree import AnyNode # type: ignore
from anytree.exporter import JsonExporter, DictExporter
from anytree.importer import JsonImporter
from anytree import AnyNode
# local imports
from catcli import nodes

@ -10,7 +10,7 @@ from time import time
from stat import S_IFDIR, S_IFREG
from typing import List, Dict, Any, Optional
try:
import fuse # type: ignore
import fuse
except ModuleNotFoundError:
pass

@ -10,8 +10,8 @@ import shutil
import time
from typing import List, Union, Tuple, Any, Optional, Dict, cast
import fnmatch
import anytree # type: ignore
from natsort import os_sort_keygen # type: ignore
import anytree
from natsort import os_sort_keygen
# local imports
from catcli import nodes
@ -407,7 +407,7 @@ class Noder:
def _fzf_prompt(strings: Any) -> Any:
"""prompt with fzf"""
try:
from pyfzf.pyfzf import FzfPrompt # type: ignore # pylint: disable=C0415 # noqa
from pyfzf.pyfzf import FzfPrompt # pylint: disable=C0415 # noqa
fzf = FzfPrompt()
selected = fzf.prompt(strings)
return selected

@ -8,7 +8,7 @@ Class that represents a node in the catalog tree
import os
from typing import Dict, Any, cast
from anytree import NodeMixin # type: ignore
from anytree import NodeMixin
from catcli.exceptions import CatcliException

@ -11,7 +11,7 @@ from catcli.nodes import NodeFile, NodeDir, NodeStorage
from catcli.colors import Colors
from catcli.logger import Logger
from catcli.utils import fix_badchars, size_to_str, \
has_attr, epoch_to_ls_str, get_node_fullpath
has_attr, epoch_to_str, get_node_fullpath
COLOR_STORAGE = Colors.YELLOW
@ -61,7 +61,7 @@ class NativePrinter:
attrs.append(f'du:{szused}/{sztotal}')
# timestamp
if has_attr(node, 'ts'):
attrs.append(f'date:{epoch_to_ls_str(node.ts)}')
attrs.append(f'date:{epoch_to_str(node.ts)}')
# print
out = f'{pre}{Colors.UND}{self.STORAGE}{Colors.RESET}: '
@ -98,7 +98,7 @@ class NativePrinter:
line = size_to_str(size, raw=raw)
out.append(f'{COLOR_SIZE}{line}{Colors.RESET}')
if has_attr(node, 'maccess'):
line = epoch_to_ls_str(node.maccess)
line = epoch_to_str(node.maccess)
out.append(f'{COLOR_TS}{line}{Colors.RESET}')
if attrs:
out.append(f'{Colors.GRAY}[{",".join(attrs)}]{Colors.RESET}')
@ -135,7 +135,7 @@ class NativePrinter:
line = size_to_str(size, raw=raw)
out.append(f'{COLOR_SIZE}{line}{Colors.RESET}')
if has_attr(node, 'maccess'):
line = epoch_to_ls_str(node.maccess)
line = epoch_to_str(node.maccess)
out.append(f'{COLOR_TS}{line}{Colors.RESET}')
if attrs:
out.append(f'{Colors.GRAY}[{",".join(attrs)}]{Colors.RESET}')

@ -17,8 +17,6 @@ from catcli.exceptions import CatcliException
WILD = '*'
TS_FORMAT_6 = '%b %d %H:%M'
TS_FORMAT_MORE = '%b %d %Y'
def path_to_top(path: str) -> str:
@ -97,18 +95,6 @@ def epoch_to_str(epoch: float) -> str:
return timestamp.strftime(fmt)
def epoch_to_ls_str(epoch: float) -> str:
"""convert epoch to string"""
if not epoch:
return ''
timestamp = datetime.datetime.fromtimestamp(epoch)
delta = datetime.date.today() - datetime.timedelta(days=6*365/12)
fmt = TS_FORMAT_MORE
if timestamp.date() < delta:
fmt = TS_FORMAT_6
return timestamp.strftime(fmt)
def ask(question: str) -> bool:
"""ask the user what to do"""
resp = input(f'{question} [y|N] ? ')

@ -44,14 +44,14 @@
"name": "github",
"size": 1662,
"total": 0,
"ts": 1704750073,
"ts": 1704913782,
"type": "storage"
},
{
"attr": {
"access": 1704750073,
"access": 1704913782,
"access_version": "0.9.6",
"created": 1704750073,
"created": 1704913782,
"created_version": "0.9.6"
},
"name": "meta",

@ -1,7 +1,7 @@
top
└── storage: github [nbfiles:3|totsize:1662|free:0.0%|du:0/0|date:Jan 08 2024]
├── FUNDING.yml 17 Oct 19 21:00 [md5:0c6407a84d412c514007313fb3bca4de]
├── codecov.yml 104 Jan 03 2024 [md5:4203204f75b43cd4bf032402beb3359d]
└── workflows 0 Jan 03 2024 [nbfiles:2]
├── pypi-release.yml 691 Oct 19 21:00 [md5:57699a7a6a03e20e864f220e19f8e197]
└── testing.yml 850 Jan 04 2024 [md5:691df1a4d2f254b5cd04c152e7c6ccaf]
└── storage: github [nbfiles:3|totsize:1662|free:0.0%|du:0/0|date:2023-03-09 16:20:59]
├── FUNDING.yml 17 2022-10-19 21:00:37 [md5:0c6407a84d412c514007313fb3bca4de]
├── codecov.yml 104 2024-01-03 23:25:10 [md5:4203204f75b43cd4bf032402beb3359d]
└── workflows 0 2024-01-03 23:25:27 [nbfiles:2]
├── pypi-release.yml 691 2022-10-19 21:00:37 [md5:57699a7a6a03e20e864f220e19f8e197]
└── testing.yml 850 2024-01-04 22:26:09 [md5:691df1a4d2f254b5cd04c152e7c6ccaf]

Loading…
Cancel
Save