|
|
@ -18,7 +18,7 @@ from catcli import nodes
|
|
|
|
from catcli.nodes import NodeAny, NodeStorage, \
|
|
|
|
from catcli.nodes import NodeAny, NodeStorage, \
|
|
|
|
NodeTop, NodeFile, NodeArchived, NodeDir, NodeMeta, \
|
|
|
|
NodeTop, NodeFile, NodeArchived, NodeDir, NodeMeta, \
|
|
|
|
typcast_node
|
|
|
|
typcast_node
|
|
|
|
from catcli.utils import md5sum, fix_badchars, has_attr
|
|
|
|
from catcli.utils import md5sum
|
|
|
|
from catcli.logger import Logger
|
|
|
|
from catcli.logger import Logger
|
|
|
|
from catcli.printer_native import NativePrinter
|
|
|
|
from catcli.printer_native import NativePrinter
|
|
|
|
from catcli.printer_csv import CsvPrinter
|
|
|
|
from catcli.printer_csv import CsvPrinter
|
|
|
@ -117,7 +117,7 @@ class Noder:
|
|
|
|
return node, False
|
|
|
|
return node, False
|
|
|
|
# force re-indexing if no maccess
|
|
|
|
# force re-indexing if no maccess
|
|
|
|
maccess = os.path.getmtime(path)
|
|
|
|
maccess = os.path.getmtime(path)
|
|
|
|
if not has_attr(node, 'maccess') or \
|
|
|
|
if not node.has_attr('maccess') or \
|
|
|
|
not node.maccess:
|
|
|
|
not node.maccess:
|
|
|
|
self._debug('\tchange: no maccess found')
|
|
|
|
self._debug('\tchange: no maccess found')
|
|
|
|
return node, True
|
|
|
|
return node, True
|
|
|
@ -336,7 +336,7 @@ class Noder:
|
|
|
|
typcast_node(node)
|
|
|
|
typcast_node(node)
|
|
|
|
if node.type == nodes.TYPE_TOP:
|
|
|
|
if node.type == nodes.TYPE_TOP:
|
|
|
|
# top node
|
|
|
|
# top node
|
|
|
|
self.native_printer.print_top(pre, node.name)
|
|
|
|
self.native_printer.print_top(pre, node.get_name())
|
|
|
|
elif node.type == nodes.TYPE_FILE:
|
|
|
|
elif node.type == nodes.TYPE_FILE:
|
|
|
|
# node of type file
|
|
|
|
# node of type file
|
|
|
|
self.native_printer.print_file(pre, node,
|
|
|
|
self.native_printer.print_file(pre, node,
|
|
|
@ -420,7 +420,7 @@ class Noder:
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
parents = rend.get_fullpath()
|
|
|
|
parents = rend.get_fullpath()
|
|
|
|
storage = rend.get_storage_node()
|
|
|
|
storage = rend.get_storage_node()
|
|
|
|
fullpath = os.path.join(storage.name, parents)
|
|
|
|
fullpath = os.path.join(storage.get_name(), parents)
|
|
|
|
the_nodes[fullpath] = rend
|
|
|
|
the_nodes[fullpath] = rend
|
|
|
|
# prompt with fzf
|
|
|
|
# prompt with fzf
|
|
|
|
paths = self._fzf_prompt(the_nodes.keys())
|
|
|
|
paths = self._fzf_prompt(the_nodes.keys())
|
|
|
@ -477,7 +477,7 @@ class Noder:
|
|
|
|
paths = {}
|
|
|
|
paths = {}
|
|
|
|
for item in found:
|
|
|
|
for item in found:
|
|
|
|
typcast_node(item)
|
|
|
|
typcast_node(item)
|
|
|
|
item.name = fix_badchars(item.name)
|
|
|
|
item.set_name(item.get_name())
|
|
|
|
key = item.get_fullpath()
|
|
|
|
key = item.get_fullpath()
|
|
|
|
paths[key] = item
|
|
|
|
paths[key] = item
|
|
|
|
|
|
|
|
|
|
|
@ -574,7 +574,7 @@ class Noder:
|
|
|
|
@fmt: output format
|
|
|
|
@fmt: output format
|
|
|
|
@raw: print raw size
|
|
|
|
@raw: print raw size
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
self._debug(f'ls walking path: \"{path}\" from \"{top.name}\"')
|
|
|
|
self._debug(f'ls walking path: \"{path}\" from \"{top.get_name()}\"')
|
|
|
|
resolv = anytree.resolver.Resolver('name')
|
|
|
|
resolv = anytree.resolver.Resolver('name')
|
|
|
|
found = []
|
|
|
|
found = []
|
|
|
|
try:
|
|
|
|
try:
|
|
|
@ -633,7 +633,7 @@ class Noder:
|
|
|
|
path: str,
|
|
|
|
path: str,
|
|
|
|
raw: bool = False) -> List[NodeAny]:
|
|
|
|
raw: bool = False) -> List[NodeAny]:
|
|
|
|
"""disk usage"""
|
|
|
|
"""disk usage"""
|
|
|
|
self._debug(f'du walking path: \"{path}\" from \"{top.name}\"')
|
|
|
|
self._debug(f'du walking path: \"{path}\" from \"{top.get_name()}\"')
|
|
|
|
resolv = anytree.resolver.Resolver('name')
|
|
|
|
resolv = anytree.resolver.Resolver('name')
|
|
|
|
found: NodeAny
|
|
|
|
found: NodeAny
|
|
|
|
try:
|
|
|
|
try:
|
|
|
@ -660,15 +660,15 @@ class Noder:
|
|
|
|
"""add an entry to the tree"""
|
|
|
|
"""add an entry to the tree"""
|
|
|
|
entries = name.rstrip(os.sep).split(os.sep)
|
|
|
|
entries = name.rstrip(os.sep).split(os.sep)
|
|
|
|
if len(entries) == 1:
|
|
|
|
if len(entries) == 1:
|
|
|
|
self.new_archive_node(name, top, top.name)
|
|
|
|
self.new_archive_node(name, top, top.get_name())
|
|
|
|
return
|
|
|
|
return
|
|
|
|
sub = os.sep.join(entries[:-1])
|
|
|
|
sub = os.sep.join(entries[:-1])
|
|
|
|
nodename = entries[-1]
|
|
|
|
nodename = entries[-1]
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
parent = resolv.get(top, sub)
|
|
|
|
parent = resolv.get(top, sub)
|
|
|
|
parent = self.new_archive_node(nodename, parent, top.name)
|
|
|
|
parent = self.new_archive_node(nodename, parent, top.get_name())
|
|
|
|
except anytree.resolver.ChildResolverError:
|
|
|
|
except anytree.resolver.ChildResolverError:
|
|
|
|
self.new_archive_node(nodename, top, top.name)
|
|
|
|
self.new_archive_node(nodename, top, top.get_name())
|
|
|
|
|
|
|
|
|
|
|
|
def list_to_tree(self, parent: NodeAny, names: List[str]) -> None:
|
|
|
|
def list_to_tree(self, parent: NodeAny, names: List[str]) -> None:
|
|
|
|
"""convert list of files to a tree"""
|
|
|
|
"""convert list of files to a tree"""
|
|
|
|