diff --git a/src/__pycache__/tree.cpython-39.pyc b/src/__pycache__/tree.cpython-39.pyc index 3e3e2a0..2aa560a 100644 Binary files a/src/__pycache__/tree.cpython-39.pyc and b/src/__pycache__/tree.cpython-39.pyc differ diff --git a/src/tree.py b/src/tree.py index 6d0372a..33f49a0 100644 --- a/src/tree.py +++ b/src/tree.py @@ -60,6 +60,8 @@ class NerdTree(): ## rootnode for definition is always a folder rootnode = tosplit.split('/')[-1] + stat_dir_item = os.stat(startpath) + if path: path.append({ 'name' : rootnode, @@ -79,6 +81,7 @@ class NerdTree(): 'abs_path' : startpath, 'children' : [], 'path': path, + 'size' : stat_dir_item.st_size, } # using listdir @@ -93,21 +96,25 @@ class NerdTree(): if item in _tree_repr.ITEMS_TO_EXCLUDE: continue - if os.path.isdir(startpath+item): - d['children'].append(self.tree_struct(startpath+item, path=path[:])) + abs_path_item = startpath+item + 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: path_copy = path[:] path_copy.append({ 'name' : item, 'type' : 'f', - 'abs_path' : startpath + item + 'abs_path' : abs_path_item }) d['children'].append({ 'name' : item, 'type' : 'f', - 'abs_path' : startpath + item, + 'abs_path' : abs_path_item, 'path' : path_copy, + 'size' : stat_item.st_size, }) return d