Permalink
Browse files

Sorting will now separate directories and files

  • Loading branch information...
1 parent a61bd30 commit 246b79175bee56a36bdc18456f47d453dda86049 Håkan Nilsson committed Jan 8, 2012
Showing with 5 additions and 3 deletions.
  1. +5 −3 krabapple.py
View
@@ -42,10 +42,10 @@ def json_list(path=''):
if not os.path.isdir(path):
raise HTTPError(403, "Path is not a directory") # Forbidden
time.sleep(0.3)
- files = sorted(os.listdir(path))
+ files = os.listdir(path)
content = [file_info(path, f) for f in files if is_visible(f)]
- return {"content": content
- }
+ content.sort(key=file_cmp_key)
+ return {"content": content}
@get('/file/:path#.+#')
def get_file(path):
@@ -105,6 +105,8 @@ def get_type(path):
else:
return "unknown"
+def file_cmp_key(f):
+ return (f['type'], f['name'])
#-----------------------------------------------------------------------------
# Main

0 comments on commit 246b791

Please sign in to comment.