Mercurial > hg > decoupage
comparison decoupage/web.py @ 56:0cc1af24602b
dont show size for directories
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Thu, 18 Nov 2010 08:25:00 -0800 |
parents | a2f09d749a3f |
children | 07cf168aa98c |
comparison
equal
deleted
inserted
replaced
55:47acf12d01e1 | 56:0cc1af24602b |
---|---|
210 ### internal methods | 210 ### internal methods |
211 | 211 |
212 def filedata(self, path, directory, conf=None): | 212 def filedata(self, path, directory, conf=None): |
213 conf = conf or {} | 213 conf = conf or {} |
214 files = [] | 214 files = [] |
215 | |
216 # get data for files | |
215 filenames = os.listdir(directory) | 217 filenames = os.listdir(directory) |
216 for i in filenames: | 218 for i in filenames: |
217 filepath = os.path.join(directory, i) | 219 filepath = os.path.join(directory, i) |
218 filetype = 'file' | 220 filetype = 'file' |
219 if os.path.isdir(filepath): | 221 if os.path.isdir(filepath): |
220 filetype = 'directory' | 222 filetype = 'directory' |
221 modified = os.path.getmtime(filepath) | 223 modified = os.path.getmtime(filepath) |
222 modified = datetime.fromtimestamp(modified) | 224 modified = datetime.fromtimestamp(modified) |
223 files.append({'path' : '%s/%s' % (path.rstrip('/'), i), | 225 data = {'path' : '%s/%s' % (path.rstrip('/'), i), |
224 'name': i, | 226 'name': i, |
225 'size': os.path.getsize(filepath), | 227 'modified': modified, |
226 'modified': modified, | 228 'type': filetype} |
227 'type': filetype}) | 229 if filetype == 'file': |
230 data['size'] = os.path.getsize(filepath) | |
231 files.append(data) | |
228 | 232 |
229 # TODO: deal with other links in conf | 233 # TODO: deal with other links in conf |
230 for i in conf: | 234 for i in conf: |
231 if i in filenames or i.startswith('/'): | 235 if i in filenames or i.startswith('/'): |
232 continue | 236 continue |