changeset 56:0cc1af24602b

dont show size for directories
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 18 Nov 2010 08:25:00 -0800
parents 47acf12d01e1
children 884e6c805208
files decoupage/web.py
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/decoupage/web.py	Thu Nov 18 08:19:06 2010 -0800
+++ b/decoupage/web.py	Thu Nov 18 08:25:00 2010 -0800
@@ -212,6 +212,8 @@
     def filedata(self, path, directory, conf=None):
         conf = conf or {}
         files = []
+
+        # get data for files
         filenames = os.listdir(directory)
         for i in filenames:
             filepath = os.path.join(directory, i)
@@ -220,11 +222,13 @@
                 filetype = 'directory'
             modified = os.path.getmtime(filepath)
             modified = datetime.fromtimestamp(modified)
-            files.append({'path' : '%s/%s' % (path.rstrip('/'), i),
-                          'name': i,
-                          'size': os.path.getsize(filepath),
-                          'modified': modified,
-                          'type': filetype})
+            data = {'path' : '%s/%s' % (path.rstrip('/'), i),
+                    'name': i,
+                    'modified': modified,
+                    'type': filetype}
+            if filetype == 'file':
+                data['size'] =  os.path.getsize(filepath)
+            files.append(data)
         
         # TODO: deal with other links in conf
         for i in conf: