diff --git a/.mypy.ini b/.mypy.ini index 20e0ae3..1e6851f 100644 --- a/.mypy.ini +++ b/.mypy.ini @@ -1,3 +1,4 @@ [mypy] strict = true -disable_error_code = import-untyped,import-not-found \ No newline at end of file +disable_error_code = import-untyped,import-not-found +ignore_missing_imports = True \ No newline at end of file diff --git a/catcli/catalog.py b/catcli/catalog.py index d075399..2744430 100644 --- a/catcli/catalog.py +++ b/catcli/catalog.py @@ -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 diff --git a/catcli/fuser.py b/catcli/fuser.py index f015e36..afbcfd2 100644 --- a/catcli/fuser.py +++ b/catcli/fuser.py @@ -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 diff --git a/catcli/noder.py b/catcli/noder.py index 104a95a..fbc0acc 100644 --- a/catcli/noder.py +++ b/catcli/noder.py @@ -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 diff --git a/catcli/nodes.py b/catcli/nodes.py index fe49ec9..e1524d9 100644 --- a/catcli/nodes.py +++ b/catcli/nodes.py @@ -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 diff --git a/catcli/printer_native.py b/catcli/printer_native.py index b9f86ce..38e4fdf 100644 --- a/catcli/printer_native.py +++ b/catcli/printer_native.py @@ -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}') diff --git a/catcli/utils.py b/catcli/utils.py index e509f25..8ae5e30 100644 --- a/catcli/utils.py +++ b/catcli/utils.py @@ -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] ? ') diff --git a/tests-ng/assets/github.catalog.json b/tests-ng/assets/github.catalog.json index d4fcf58..13e594f 100644 --- a/tests-ng/assets/github.catalog.json +++ b/tests-ng/assets/github.catalog.json @@ -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", diff --git a/tests-ng/assets/github.catalog.native.txt b/tests-ng/assets/github.catalog.native.txt index 0bc80a6..57d26b9 100644 --- a/tests-ng/assets/github.catalog.native.txt +++ b/tests-ng/assets/github.catalog.native.txt @@ -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]