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