Skip to content

Commit c52860c

Browse files
committed
Group directories before fileswhen getting list.
1 parent c606811 commit c52860c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

zyngine/zynthian_engine.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,8 @@ def find_all_preset_files(path, fexts, recursion=1):
299299

300300
@classmethod
301301
def get_filelist(cls, dpath, fext, include_dirs=False, exclude_empty_dirs=True):
302-
res = []
302+
files = []
303+
dirs = []
303304
if isinstance(dpath, str):
304305
dpath = [('_', dpath)]
305306
if isinstance(fext, str):
@@ -321,16 +322,16 @@ def get_filelist(cls, dpath, fext, include_dirs=False, exclude_empty_dirs=True):
321322
if dn != '_':
322323
title = dn + '/' + title
323324
# print("filelist => " + title)
324-
res.append([os.path.join(dp, f), i, title, dn, f, ext])
325+
files.append([os.path.join(dp, f), i, title, dn, f, ext])
325326
i += 1
326327
elif include_dirs and os.path.isdir(path) and (not exclude_empty_dirs or cls.find_some_preset_file(path, fext)):
327-
res.append([path, i, "> " + f, dn, f])
328+
dirs.append([path, i, "> " + f, dn, f])
328329
i += 1
329330
except Exception as e:
330331
#logging.warning(f"Can't access directory '{dp}' => {e}")
331332
pass
332333

333-
return res
334+
return dirs + files
334335

335336
@staticmethod
336337
def get_dirlist(dpath, exclude_empty=True):

0 commit comments

Comments
 (0)