From 2b59df004a5bb7449aa4c07277ac846c330a79f7 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 23 Feb 2012 08:58:10 +0000 Subject: reverse takes request as a kwarg for compatibility with django's reverse --- examples/pygments_api/views.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'examples/pygments_api/views.py') 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): """ -- cgit v1.2.3