edna
I had edna set up to serve mp3s from my laptop for the past couple years, but forgot to save my patches when I upgraded to 10.4. oops. anyway here's how to make edna sort by date instead of alphabetically.
def sort_dir(d):
l = filter(_usable_file, os.listdir(d))
# build a list including the date
date_file_list = [ ]
for name in l:
fullpath = os.path.join(d, name)
stats = os.stat(fullpath)
lastmod_date = time.localtime(stats[8])
date_file_tuple = lastmod_date, name
date_file_list.append(date_file_tuple)
# sort it
date_file_list.sort()
date_file_list.reverse()
# extract just the name again
dl = [ ]
for date_file in date_file_list:
#grab the 2nd half of the tuple
dl.append(date_file[1])
return dl
0 Comments:
Post a Comment
<< Home