import os from stat import * print ''' Webware CGI Examples Directory

Webware CGI Examples

''' def sizeSorter(a, b): """ Used for sorting when the elements are dictionaries and the attribute to sort by is 'size'. """ return a['size'] - b['size'] # Create a list of dictionaries, where each dictionary stores information about # a particular script. scripts = [] for filename in os.listdir(os.curdir): if len(filename) > 3 and filename[-3:] == '.py': script = {} script['pathname'] = filename script['size'] = os.stat(script['pathname'])[ST_SIZE] script['shortname'] = filename[:-3] scripts.append(script) scripts.sort(sizeSorter) print '

' print '' for script in scripts: print '', print '' % script['size'], print '' % (script['shortname'], script['shortname']), print '' % script['shortname'], print '' print '
Size Script View
%d %s view
' print ''' '''