show symbolic link in rootnode dir
This commit is contained in:
parent
c7b65b9d78
commit
307bc5a15f
18
src/tree.py
18
src/tree.py
@ -26,8 +26,8 @@ class NerdTree():
|
|||||||
|
|
||||||
if path_object.is_dir():
|
if path_object.is_dir():
|
||||||
item_type = 'd'
|
item_type = 'd'
|
||||||
elif path_object.is_symlink():
|
# elif path_object.is_symlink():
|
||||||
item_type = 'l'
|
# item_type = 'l'
|
||||||
elif path_object.is_file():
|
elif path_object.is_file():
|
||||||
item_type = 'f'
|
item_type = 'f'
|
||||||
|
|
||||||
@ -81,7 +81,8 @@ class NerdTree():
|
|||||||
start_dir_item_type, start_dir_object = self.get_path_obj(startpath)
|
start_dir_item_type, start_dir_object = self.get_path_obj(startpath)
|
||||||
stat_dir_item = start_dir_object.lstat()
|
stat_dir_item = start_dir_object.lstat()
|
||||||
|
|
||||||
start_dir_target = start_dir_object.resolve() if start_dir_object.is_symlink() else ''
|
start_dir_is_symlink = start_dir_object.is_symlink()
|
||||||
|
start_dir_target = start_dir_object.resolve() if start_dir_is_symlink else ''
|
||||||
|
|
||||||
if path:
|
if path:
|
||||||
path.append({
|
path.append({
|
||||||
@ -90,6 +91,7 @@ class NerdTree():
|
|||||||
'abs_path' : startpath,
|
'abs_path' : startpath,
|
||||||
'size' : stat_dir_item.st_size,
|
'size' : stat_dir_item.st_size,
|
||||||
'target' : str(start_dir_target),
|
'target' : str(start_dir_target),
|
||||||
|
'is_symlink' : start_dir_is_symlink,
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
path = [{
|
path = [{
|
||||||
@ -98,6 +100,7 @@ class NerdTree():
|
|||||||
'abs_path' : startpath,
|
'abs_path' : startpath,
|
||||||
'size' : stat_dir_item.st_size,
|
'size' : stat_dir_item.st_size,
|
||||||
'target' : str(start_dir_target),
|
'target' : str(start_dir_target),
|
||||||
|
'is_symlink' : start_dir_is_symlink,
|
||||||
}]
|
}]
|
||||||
|
|
||||||
d = {
|
d = {
|
||||||
@ -108,6 +111,7 @@ class NerdTree():
|
|||||||
'path': path,
|
'path': path,
|
||||||
'size' : stat_dir_item.st_size,
|
'size' : stat_dir_item.st_size,
|
||||||
'target' : str(start_dir_target),
|
'target' : str(start_dir_target),
|
||||||
|
'is_symlink' : start_dir_is_symlink,
|
||||||
}
|
}
|
||||||
|
|
||||||
# using listdir
|
# using listdir
|
||||||
@ -130,7 +134,8 @@ class NerdTree():
|
|||||||
if path_object.is_dir():
|
if path_object.is_dir():
|
||||||
d['children'].append(self.tree_struct(abs_path_item, path=path[:]))
|
d['children'].append(self.tree_struct(abs_path_item, path=path[:]))
|
||||||
else:
|
else:
|
||||||
target = path_object.resolve() if path_object.is_symlink() else ''
|
is_symlink = path_object.is_symlink()
|
||||||
|
target = path_object.resolve() if is_symlink else ''
|
||||||
|
|
||||||
path_copy = path[:]
|
path_copy = path[:]
|
||||||
path_copy.append({
|
path_copy.append({
|
||||||
@ -138,6 +143,7 @@ class NerdTree():
|
|||||||
'type' : item_type,
|
'type' : item_type,
|
||||||
'abs_path' : abs_path_item,
|
'abs_path' : abs_path_item,
|
||||||
'target' : str(target),
|
'target' : str(target),
|
||||||
|
'is_symlink' : is_symlink,
|
||||||
})
|
})
|
||||||
|
|
||||||
d['children'].append({
|
d['children'].append({
|
||||||
@ -147,6 +153,7 @@ class NerdTree():
|
|||||||
'path' : path_copy,
|
'path' : path_copy,
|
||||||
'size' : stat_item.st_size,
|
'size' : stat_item.st_size,
|
||||||
'target' : str(target),
|
'target' : str(target),
|
||||||
|
'is_symlink' : is_symlink,
|
||||||
})
|
})
|
||||||
|
|
||||||
return d
|
return d
|
||||||
@ -199,6 +206,9 @@ class NerdTree():
|
|||||||
else:
|
else:
|
||||||
nerd_tree_txt = rootnode_name
|
nerd_tree_txt = rootnode_name
|
||||||
|
|
||||||
|
if (rootnode['is_symlink'] and rootnode.get('target', '')):
|
||||||
|
nerd_tree_txt += ' -> %s' % (rootnode['target'],)
|
||||||
|
|
||||||
nodefound = rootnode.get('found')
|
nodefound = rootnode.get('found')
|
||||||
if nodefound and self.opts['dont_show_children_nodes']:
|
if nodefound and self.opts['dont_show_children_nodes']:
|
||||||
if rootnode.get('subtree_items'):
|
if rootnode.get('subtree_items'):
|
||||||
|
@ -43,7 +43,7 @@ def produce_treeline(prec_seps, lsep):
|
|||||||
item_name = item['name']
|
item_name = item['name']
|
||||||
tomount = sep + item_name
|
tomount = sep + item_name
|
||||||
|
|
||||||
if item.get('type') == 'l' and item.get('target', ''):
|
if item.get('is_symlink') and item.get('target', ''):
|
||||||
tomount += ' -> %s' % ((item['target'],))
|
tomount += ' -> %s' % ((item['target'],))
|
||||||
|
|
||||||
# if item.get('type') == 'd':
|
# if item.get('type') == 'd':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user