aboutsummaryrefslogtreecommitdiffstats
path: root/examples/pygments_api
diff options
context:
space:
mode:
Diffstat (limited to 'examples/pygments_api')
-rw-r--r--examples/pygments_api/views.py10
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):
"""