directory unreadability

This commit is contained in:
Amber 2024-01-17 13:20:18 +01:00
parent de81490a91
commit a11761ac01
3 changed files with 11 additions and 43 deletions

View File

@ -1,3 +1,4 @@
# nerd_tree # Nerd tree
A bad version of the unix-like tree command and a visual version of find command that shows the results found in a visual tree An ugly version of the unix-like tree command and a visual version of find command that shows the results found in a visual tree.
Branch is unstable and under development

Binary file not shown.

View File

@ -39,6 +39,8 @@ def nerd_tree_sort_dirfirst(startpath):
files = [] files = []
dirs = [] dirs = []
for item in os.listdir(startpath): for item in os.listdir(startpath):
if os.path.isdir(startpath + item): if os.path.isdir(startpath + item):
dirs.append(item) dirs.append(item)
@ -60,46 +62,6 @@ def nerd_tree_sort(startpath, dirfirst=True):
return os.listdir(startpath) return os.listdir(startpath)
def OLDnerd_tree(startpath, prec_seps=[]):
if not startpath.endswith('/'):
tosplit = startpath
startpath = startpath + '/'
else:
tosplit = startpath[:-1]
rootnode = tosplit.split('/')[-1]
items = nerd_tree_sort(startpath, dirfirst=True)
## rootnode is always a dir -> colorize
nerd_tree_txt = 'd_' + rootnode
for n, item in enumerate(items):
if item in ITEMS_TO_EXCLUDE:
continue
islast = (n==len(items) -1)
sep = CHILD_CONNECTOR
if islast:
sep = LAST_CHILD_CONNECTOR
if not islast:
psep_char = VERTICAL_CONNECTOR
else:
psep_char = ''
if os.path.isdir(startpath+item):
seps = prec_seps[:]
seps.append((psep_char, ''))
treeline = produce_treeline(prec_seps, (sep, ' ')) + ' ' + nerd_tree(startpath+item, prec_seps=seps)
else:
treeline = produce_treeline(prec_seps, (sep, item))
nerd_tree_txt += '\n' + treeline
return nerd_tree_txt
def nerd_tree_from_struct(rootnode, prec_seps=[]): def nerd_tree_from_struct(rootnode, prec_seps=[]):
''' '''
rootnode is a dict rootnode is a dict
@ -176,7 +138,12 @@ def nerd_tree_struct(startpath, path=[]):
} }
# using listdir # using listdir
try:
items = nerd_tree_sort(startpath, dirfirst=True) items = nerd_tree_sort(startpath, dirfirst=True)
except Exception as ss:
print(f'Path: {startpath} not readable because {ss}')
items = []
d.setdefault('not_readable', 1)
for item in items: for item in items:
if item in ITEMS_TO_EXCLUDE: if item in ITEMS_TO_EXCLUDE: