# HG changeset patch # User egj@socialplanning.org # Date 1262575721 0 # Node ID a8d36caa8f09bbb5ad89181a273c246f99a6e2c1 # Parent 64ae0d2f402befc49f6e9123131df98fdafcf6a2 add formatter diff -r 64ae0d2f402b -r a8d36caa8f09 decoupage/formatters.py --- 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""" diff -r 64ae0d2f402b -r a8d36caa8f09 setup.py --- a/setup.py Sun Jan 03 15:39:55 2010 -0500 +++ b/setup.py Mon Jan 04 03:28:41 2010 +0000 @@ -44,6 +44,7 @@ include = decoupage.formatters:Include describe = decoupage.formatters:FilenameDescription title = decoupage.formatters:TitleDescription + sort = decoupage.formatters:Sort """, )