Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
kennymckormick committed Mar 31, 2024
1 parent 156e999 commit a4e63a4
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions vlmeval/smp/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +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)
assert '+' in level
level = int(level[:-1])
res = []
for i in range(1, level + 1):
res.extend(ls(dirname, match=match, mode='file', level=i))
return res

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


Expand Down

0 comments on commit a4e63a4

Please sign in to comment.