This commit is contained in:
Amber 2024-01-25 16:44:00 +01:00
parent c0db9563cb
commit aec7377780
2 changed files with 11 additions and 4 deletions

Binary file not shown.

View File

@ -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