# HG changeset patch # User k0s # Date 1261727987 18000 # Node ID 9f91acf9874c634668d32da397745c25532b871e # Parent fad6fa9037a51fc3fc3db64cd754126c10f77b73 * split on space in formatters to be consist with everything else * break filedata into its own function diff -r fad6fa9037a5 -r 9f91acf9874c decoupage/formatters.py --- 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): diff -r fad6fa9037a5 -r 9f91acf9874c decoupage/web.py --- 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: