Get rid of the mailman.rules entry point.
[mailman.git] / src / mailman / pipeline / __init__.py
blob97b3645a06d916cf1a23772f0ecdf46273b9ee4b
1 # Copyright (C) 2008-2009 by the Free Software Foundation, Inc.
3 # This file is part of GNU Mailman.
5 # GNU Mailman is free software: you can redistribute it and/or modify it under
6 # the terms of the GNU General Public License as published by the Free
7 # Software Foundation, either version 3 of the License, or (at your option)
8 # any later version.
10 # GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 # more details.
15 # You should have received a copy of the GNU General Public License along with
16 # GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
18 """The built in set of pipeline handlers."""
20 from __future__ import absolute_import, unicode_literals
22 __metaclass__ = type
23 __all__ = [
24 'builtin_handlers',
28 import os
29 import sys
31 from mailman.interfaces.handler import IHandler
35 def builtin_handlers():
36 """Return the built-in handlers.
38 Rules are auto-discovered by searching for IHandler implementations in all
39 importable modules in this subpackage.
40 """
41 # Find all rules found in all modules inside our package.
42 import mailman.pipeline
43 here = os.path.dirname(mailman.pipeline.__file__)
44 for filename in os.listdir(here):
45 basename, extension = os.path.splitext(filename)
46 if extension <> '.py':
47 continue
48 module_name = 'mailman.pipeline.' + basename
49 __import__(module_name, fromlist='*')
50 module = sys.modules[module_name]
51 for name in getattr(module, '__all__', ()):
52 handler = getattr(module, name)
53 if IHandler.implementedBy(handler):
54 yield handler