Skip to content

Commit

Permalink
Sorting files (#137)
Browse files Browse the repository at this point in the history
1.txt, 2.txt, 3.txt instead of 
2.txt, 3.txt, 1.txt ... 

It's not natsort, but better than a random? representation.
  • Loading branch information
xavierfiechter authored Apr 3, 2021
1 parent a7cbb62 commit 34be7c9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/hosts/sd.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ def truncate(self, fname):
return fname[:18]+"..."+fname[-12:]

async def select_file(self, extensions):

files = sum([[f[0] for f in os.ilistdir(self.sdpath) if f[0].lower().endswith(ext) and f[1] == 0x8000] for ext in extensions], [])

if len(files) == 0:
raise HostError("\n\nNo matching files found on the SD card\nAllowed: %s" % ", ".join(extensions))
if len(files) == 1:
elif len(files) == 1:
return self.sdpath+"/"+ files[0]


files.sort()
buttons = []
for ext in extensions:
title = [(None, ext+" files")]
Expand All @@ -83,7 +83,7 @@ async def select_file(self, extensions):
buttons += [(None, "%s files - No files" % ext)]
else:
buttons += title + barr

fname = await self.manager.gui.menu(buttons, title="Select a file", last=(None, "Cancel"))
return fname

Expand Down

0 comments on commit 34be7c9

Please sign in to comment.