Skip to content

Commit

Permalink
update ls func
Browse files Browse the repository at this point in the history
  • Loading branch information
kennymckormick committed Mar 31, 2024
1 parent 973c6d3 commit 85f1588
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions vlmeval/smp/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ def update_to(self, b=1, bsize=1, tsize=None):


def ls(dirname='.', match=[], mode='all', level=1):
include = False
if isinstance(level, str):
if level[-1] == '+':
include = True
level = level[:-1]
level = int(level)

if dirname == '.':
ans = os.listdir(dirname)
else:
Expand All @@ -125,10 +132,13 @@ def ls(dirname='.', match=[], mode='all', level=1):
elif mode == 'file':
ans = [x for x in ans if not osp.isdir(x)]
else:
ans = [x for x in ans if osp.isdir(x)]
files = [x for x in ans if osp.isfile(x)]
dirs = [x for x in ans if osp.isdir(x)]
res = []
for d in ans:
for d in dirs:
res.extend(ls(d, match=match, mode=mode, level=level - 1))
if include:
res.extend(files)
ans = res
return ans

Expand Down

0 comments on commit 85f1588

Please sign in to comment.