From 3acedec771bc2ca2afcbcc99a529ac1b309929f0 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Tue, 22 Mar 2011 22:48:59 +0000 Subject: Fix some examples --- examples/pygments_api/views.py | 5 ++--- 1 file changed, 2 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 91c6045b..6fb9217a 100644 --- a/examples/pygments_api/views.py +++ b/examples/pygments_api/views.py @@ -19,11 +19,11 @@ import operator # We need somewhere to store the code that we highlight HIGHLIGHTED_CODE_DIR = os.path.join(settings.MEDIA_ROOT, 'pygments') -MAX_FILES = 20 +MAX_FILES = 10 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)] + 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=True)] def remove_oldest_files(dir, max_files): @@ -46,7 +46,6 @@ class PygmentsRoot(Resource): def get(self, request, auth): """Return a list of all currently existing snippets.""" unique_ids = [os.path.split(f)[1] for f in list_dir_sorted_by_ctime(HIGHLIGHTED_CODE_DIR)] - unique_ids.reverse() return [reverse('pygments-instance', args=[unique_id]) for unique_id in unique_ids] def post(self, request, auth, content): -- cgit v1.2.3