diff options
| author | Tom Christie | 2011-03-22 22:48:59 +0000 |
|---|---|---|
| committer | Tom Christie | 2011-03-22 22:48:59 +0000 |
| commit | 3acedec771bc2ca2afcbcc99a529ac1b309929f0 (patch) | |
| tree | 81fe63fb8ac5344d78f037444286de078b11f7d1 /examples/pygments_api/views.py | |
| parent | b4a076c8226223bb650605f4d04609f1f59b5913 (diff) | |
| download | django-rest-framework-3acedec771bc2ca2afcbcc99a529ac1b309929f0.tar.bz2 | |
Fix some examples
Diffstat (limited to 'examples/pygments_api/views.py')
| -rw-r--r-- | examples/pygments_api/views.py | 5 |
1 files changed, 2 insertions, 3 deletions
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): |
