show symbolic link

This commit is contained in:
Amber
2024-02-05 17:05:39 +01:00
parent 3a1d340f2d
commit 4976611793
3 changed files with 24 additions and 6 deletions

View File

@ -26,10 +26,10 @@ class NerdTree():
if path_object.is_dir():
item_type = 'd'
elif path_object.is_file():
item_type = 'f'
elif path_object.is_symlink():
item_type = 'l'
elif path_object.is_file():
item_type = 'f'
assert item_type
@ -81,12 +81,15 @@ class NerdTree():
start_dir_item_type, start_dir_object = self.get_path_obj(startpath)
stat_dir_item = start_dir_object.lstat()
start_dir_target = start_dir_object.resolve() if start_dir_object.is_symlink() else ''
if path:
path.append({
'name' : rootnode,
'type' : start_dir_item_type,
'abs_path' : startpath,
'size' : stat_dir_item.st_size,
'target' : str(start_dir_target),
})
else:
path = [{
@ -94,6 +97,7 @@ class NerdTree():
'type' : start_dir_item_type,
'abs_path' : startpath,
'size' : stat_dir_item.st_size,
'target' : str(start_dir_target),
}]
d = {
@ -103,6 +107,7 @@ class NerdTree():
'children' : [],
'path': path,
'size' : stat_dir_item.st_size,
'target' : str(start_dir_target),
}
# using listdir
@ -114,7 +119,7 @@ class NerdTree():
d.setdefault('not_readable', 1)
for item in items:
if item in self.opts.get('items_to_exclude') or []:
if item in (self.opts.get('items_to_exclude') or []):
continue
abs_path_item = startpath+item
@ -125,11 +130,14 @@ class NerdTree():
if path_object.is_dir():
d['children'].append(self.tree_struct(abs_path_item, path=path[:]))
else:
target = path_object.resolve() if path_object.is_symlink() else ''
path_copy = path[:]
path_copy.append({
'name' : item,
'type' : item_type,
'abs_path' : abs_path_item
'abs_path' : abs_path_item,
'target' : str(target),
})
d['children'].append({
@ -138,6 +146,7 @@ class NerdTree():
'abs_path' : abs_path_item,
'path' : path_copy,
'size' : stat_item.st_size,
'target' : str(target),
})
return d

View File

@ -43,6 +43,9 @@ def produce_treeline(prec_seps, lsep):
item_name = item['name']
tomount = sep + item_name
if item['type'] == 'l' and item['target']:
tomount += ' -> %s' % ((item['target'],))
# if item.get('type') == 'd':
# if item.get('nchildren') is not None:
# tomount += '(%s)' % (item['nchildren'],)