Adding size sort

This commit is contained in:
ville rantanen
2013-10-04 11:57:57 +03:00
parent f32b6d8edf
commit 690b7fa616
2 changed files with 15 additions and 0 deletions

View File

@@ -99,6 +99,13 @@ def getfiletimes(path,list):
times.append(int(os.path.getmtime(os.path.join(path,p))))
return times
def getfilesizes(path,list):
''' Returns a list of sizes '''
sizes=[]
for p in list:
sizes.append(int(os.path.getsize(os.path.join(path,p))))
return sizes
def getnonimagelist(path,options):
''' Returns a list of files not matching the image match regex '''
list=os.listdir(path)
@@ -172,6 +179,7 @@ def imagescript(path,list):
strout='<script language="javascript">var imagelist=['
descriptions=getdescriptions(path,list)
times=getfiletimes(path,list)
sizes=getfilesizes(path,list)
n=0
elements=[]
for i in list:
@@ -181,6 +189,7 @@ def imagescript(path,list):
desc=singlequotes.sub("\\'",filter(lambda x: x in string.printable, descriptions[n]).encode('ascii', 'xmlcharrefreplace'))
this_str='\n{name:"'+unicode(i,encoding="utf8").encode('ascii', 'xmlcharrefreplace')+'", '
this_str+='desc:\''+desc+'\', '
this_str+='size:\''+str(sizes[n])+'\', '
this_str+='time:'+str(times[n])+'}'
elements.append(this_str)
n+=1