Changeset 4855


Ignore:
Timestamp:
18 Jan 2010, 13:17:38 (15 years ago)
Author:
uli
Message:

Enable sorting of file list in newest-first order.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • waeup/branches/ulif-importers/src/waeup/datacenter.py

    r4849 r4855  
    6363        return result
    6464   
    65     def getFiles(self):
     65    def getFiles(self, sort='name'):
    6666        """Get a list of files stored in `storage`.
    6767
     
    7676                continue
    7777            result.append(DataCenterFile(fullpath))
     78        if sort == 'date':
     79            # sort results in newest-first order...
     80            result = sorted(result, key=lambda x: x.getTimeStamp(),
     81                            reverse=True)
    7882        return result
    7983
     
    210214        return date.strftime('%c')
    211215
     216    def getTimeStamp(self):
     217        """Get a (machine readable) timestamp.
     218        """
     219        return os.path.getctime(self.context)
     220   
    212221    def getSize(self):
    213222        """Get a human readable file size.
Note: See TracChangeset for help on using the changeset viewer.