# HG changeset patch # User k0s # Date 1261715617 18000 # Node ID ec2d0d850b83344d506558cdc5fc3d9c4dc49db1 # Parent 16d41af2d8ef5de5bce42cf563d3bb434675fbf1 add ability to print formatters with decoupage-formatters console_script diff -r 16d41af2d8ef -r ec2d0d850b83 decoupage/formatters.py --- a/decoupage/formatters.py Thu Dec 24 22:48:55 2009 -0500 +++ b/decoupage/formatters.py Thu Dec 24 23:33:37 2009 -0500 @@ -1,4 +1,8 @@ +#!/usr/bin/env python + +import sys from fnmatch import fnmatch +from pkg_resources import iter_entry_points ### abstract base classes for formatters @@ -49,7 +53,7 @@ class All(object): """ - only pass files of a certain pattern; + only pass files of a certain pattern; the inverse of ignore """ @@ -74,6 +78,7 @@ class FilenameDescription(FormatterBase): + """substitute the description for the filename""" def __call__(self, request, data): for f in data['files']: @@ -85,6 +90,9 @@ class TitleDescription(FormatterBase): + """splits a description into a title and a description with a separator""" + + defaults = { 'separator': ':' } def __call__(self, request, data): @@ -98,3 +106,19 @@ f['description'] = None +def formatters(): + formatters = {} + for entry_point in iter_entry_points('decoupage.formatters'): + try: + formatter = entry_point.load() + except: + continue + formatters[entry_point.name] = formatter + return formatters + +def main(args=sys.argv[1:]): + for name, formatter in formatters().items(): + print '%s%s' % (name, formatter.__doc__ and ': ' + formatter.__doc__ or '') + +if __name__ == '__main__': + main() diff -r 16d41af2d8ef -r ec2d0d850b83 setup.py --- a/setup.py Thu Dec 24 22:48:55 2009 -0500 +++ b/setup.py Thu Dec 24 23:33:37 2009 -0500 @@ -6,7 +6,7 @@ except IOError: description = '' -version = '0.3.1' +version = '0.3.2' setup(name='decoupage', version=version, @@ -32,6 +32,7 @@ # -*- Entry points: -*- [console_scripts] decoupage-templates = decoupage.templates:main + decoupage-formatters = decoupage.formatters:main [paste.app_factory] main = decoupage.factory:factory