tree.py
This commit is contained in:
parent
c0db9563cb
commit
aec7377780
Binary file not shown.
15
src/tree.py
15
src/tree.py
|
@ -60,6 +60,8 @@ class NerdTree():
|
||||||
## rootnode for definition is always a folder
|
## rootnode for definition is always a folder
|
||||||
rootnode = tosplit.split('/')[-1]
|
rootnode = tosplit.split('/')[-1]
|
||||||
|
|
||||||
|
stat_dir_item = os.stat(startpath)
|
||||||
|
|
||||||
if path:
|
if path:
|
||||||
path.append({
|
path.append({
|
||||||
'name' : rootnode,
|
'name' : rootnode,
|
||||||
|
@ -79,6 +81,7 @@ class NerdTree():
|
||||||
'abs_path' : startpath,
|
'abs_path' : startpath,
|
||||||
'children' : [],
|
'children' : [],
|
||||||
'path': path,
|
'path': path,
|
||||||
|
'size' : stat_dir_item.st_size,
|
||||||
}
|
}
|
||||||
|
|
||||||
# using listdir
|
# using listdir
|
||||||
|
@ -93,21 +96,25 @@ class NerdTree():
|
||||||
if item in _tree_repr.ITEMS_TO_EXCLUDE:
|
if item in _tree_repr.ITEMS_TO_EXCLUDE:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if os.path.isdir(startpath+item):
|
abs_path_item = startpath+item
|
||||||
d['children'].append(self.tree_struct(startpath+item, path=path[:]))
|
stat_item = os.stat(abs_path_item)
|
||||||
|
|
||||||
|
if os.path.isdir(abs_path_item):
|
||||||
|
d['children'].append(self.tree_struct(abs_path_item, path=path[:]))
|
||||||
else:
|
else:
|
||||||
path_copy = path[:]
|
path_copy = path[:]
|
||||||
path_copy.append({
|
path_copy.append({
|
||||||
'name' : item,
|
'name' : item,
|
||||||
'type' : 'f',
|
'type' : 'f',
|
||||||
'abs_path' : startpath + item
|
'abs_path' : abs_path_item
|
||||||
})
|
})
|
||||||
|
|
||||||
d['children'].append({
|
d['children'].append({
|
||||||
'name' : item,
|
'name' : item,
|
||||||
'type' : 'f',
|
'type' : 'f',
|
||||||
'abs_path' : startpath + item,
|
'abs_path' : abs_path_item,
|
||||||
'path' : path_copy,
|
'path' : path_copy,
|
||||||
|
'size' : stat_item.st_size,
|
||||||
})
|
})
|
||||||
|
|
||||||
return d
|
return d
|
||||||
|
|
Loading…
Reference in New Issue