# HG changeset patch # User Jeff Hammel # Date 1290097146 28800 # Node ID 47acf12d01e18668c2923ef952647596ede3aab4 # Parent 0e2b9e0507c5de7a6186eb6d218e9ec1e50da528# Parent a2f09d749a3fe332e2e63b8888fc1384278ef378 merge commit diff -r 0e2b9e0507c5 -r 47acf12d01e1 decoupage/formats.py --- a/decoupage/formats.py Thu Nov 18 08:18:49 2010 -0800 +++ b/decoupage/formats.py Thu Nov 18 08:19:06 2010 -0800 @@ -12,7 +12,8 @@ # fix datetime for f in data['files']: - f['modified'] = f['modified'].ctime() + if 'modified' in f: + f['modified'] = f['modified'].ctime() return 'application/json', json.dumps(data['files']) diff -r 0e2b9e0507c5 -r 47acf12d01e1 decoupage/web.py --- a/decoupage/web.py Thu Nov 18 08:18:49 2010 -0800 +++ b/decoupage/web.py Thu Nov 18 08:19:06 2010 -0800 @@ -133,6 +133,7 @@ conf = self.conf(path) ### build data dictionary + # TODO: separate these out into several formatters files = self.filedata(path, directory, conf) data = {'path': path, 'files': files, 'request': request } @@ -208,10 +209,11 @@ ### internal methods - def filedata(self, path, directory, conf): + def filedata(self, path, directory, conf=None): + conf = conf or {} files = [] - - for i in os.listdir(directory): + filenames = os.listdir(directory) + for i in filenames: filepath = os.path.join(directory, i) filetype = 'file' if os.path.isdir(filepath): @@ -222,10 +224,19 @@ 'name': i, 'size': os.path.getsize(filepath), 'modified': modified, - 'description': conf.get(i.lower(), None), 'type': filetype}) # TODO: deal with other links in conf + for i in conf: + if i in filenames or i.startswith('/'): + continue + if i.startswith('http://') or i.startswith('https://'): + files.append({'path': i, + 'name': i, + 'type': link}) + + for f in files: + f['description'] = conf.get(f['name'].lower(), None) return files