diff options
| author | Tom Christie | 2012-02-23 08:58:10 +0000 |
|---|---|---|
| committer | Tom Christie | 2012-02-23 08:58:10 +0000 |
| commit | 2b59df004a5bb7449aa4c07277ac846c330a79f7 (patch) | |
| tree | 3a5e20948d3cd0ea1ca4d25ff35d970646722a30 /examples/pygments_api/views.py | |
| parent | 8e0b9e55ecb0733369918d4562ba38ba505cdfe8 (diff) | |
| download | django-rest-framework-2b59df004a5bb7449aa4c07277ac846c330a79f7.tar.bz2 | |
reverse takes request as a kwarg for compatibility with django's reverse
Diffstat (limited to 'examples/pygments_api/views.py')
| -rw-r--r-- | examples/pygments_api/views.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/examples/pygments_api/views.py b/examples/pygments_api/views.py index b5396681..3dd55115 100644 --- a/examples/pygments_api/views.py +++ b/examples/pygments_api/views.py @@ -30,9 +30,13 @@ def list_dir_sorted_by_ctime(dir): """ Return a list of files sorted by creation time """ - filepaths = [os.path.join(dir, file) for file in os.listdir(dir) if not file.startswith('.')] - return [item[0] for item in sorted( [(path, os.path.getctime(path)) for path in filepaths], - key=operator.itemgetter(1), reverse=False) ] + filepaths = [os.path.join(dir, file) + for file in os.listdir(dir) + if not file.startswith('.')] + ctimes = [(path, os.path.getctime(path)) for path in filepaths] + ctimes = sorted(ctimes, key=operator.itemgetter(1), reverse=False) + return [filepath for filepath, ctime in ctimes] + def remove_oldest_files(dir, max_files): """ |
