Mercurial > hg > decoupage
changeset 12:9f91acf9874c
* split on space in formatters to be consist with everything else
* break filedata into its own function
author | k0s <k0scist@gmail.com> |
---|---|
date | Fri, 25 Dec 2009 02:59:47 -0500 |
parents | fad6fa9037a5 |
children | ab0c2bb4d23d |
files | decoupage/formatters.py decoupage/web.py |
diffstat | 2 files changed, 12 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/decoupage/formatters.py Fri Dec 25 01:11:38 2009 -0500 +++ b/decoupage/formatters.py Fri Dec 25 02:59:47 2009 -0500 @@ -40,8 +40,7 @@ def __init__(self, ignore): - self.match = [ i.strip() for i in ignore.split(',') - if i.strip() ] + self.match = ignore.split() def __call__(self, request, data): _files = [] @@ -58,11 +57,11 @@ """ only pass files of a certain pattern; the inverse of ignore + calling all with no arguments means only files with descriptions are used """ def __init__(self, pattern): - self.match = [ i.strip() for i in pattern.split(',') - if i.strip() ] + self.match = pattern.split() def __call__(self, request, data):
--- a/decoupage/web.py Fri Dec 25 01:11:38 2009 -0500 +++ b/decoupage/web.py Fri Dec 25 02:59:47 2009 -0500 @@ -95,13 +95,8 @@ # get the configuraton conf = self.conf(path) - # add data for the files - files = [] - for i in os.listdir(directory): - files.append({'path' : '%s/%s' % (path.rstrip('/'), i), - 'name': i, - 'description': conf.get(i.lower(), None)}) # build data dictionary + files = self.filedata(path, directory, conf) data = {'path': path, 'files': files, 'request': request} # apply formatters @@ -121,7 +116,6 @@ formatter = self.formatters[name](conf.get('/%s' % name, '')) formatter(request, data) - # render the template template = conf.get('/template') if template is None: @@ -139,6 +133,14 @@ ### internal methods + def filedata(self, path, directory, conf): + files = [] + for i in os.listdir(directory): + files.append({'path' : '%s/%s' % (path.rstrip('/'), i), + 'name': i, + 'description': conf.get(i.lower(), None)}) + return files + def conf(self, path, cascade=None): """returns configuration dictionary appropriate to a path""" if cascade is None: