Mercurial > hg > decoupage
changeset 22:a8d36caa8f09
add formatter
author | egj@socialplanning.org |
---|---|
date | Mon, 04 Jan 2010 03:28:41 +0000 |
parents | 64ae0d2f402b |
children | d1b1019d9254 |
files | decoupage/formatters.py setup.py |
diffstat | 2 files changed, 13 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/decoupage/formatters.py Sun Jan 03 15:39:55 2010 -0500 +++ b/decoupage/formatters.py Mon Jan 04 03:28:41 2010 +0000 @@ -78,6 +78,18 @@ _files.append(f) data['files'] = _files +class Sort(object): + """ determines how to sort the files in a directory """ + def __init__(self, pattern): + self.args = [i.strip() for i in pattern.split(',')] + + def __call__(self, request, data): + + data['files'] = sorted(data['files'], key=lambda x: x['name'].lower()) + + if 'reverse' in self.args: + data['files'] = reverse(data['files']) + class FilenameDescription(FormatterBase): """substitute the description for the filename"""