Bump copyright years.
[mailman.git] / src / mailman / interfaces / command.py
blob2a065684144b81190208a47f1a336b2812688c49
1 # Copyright (C) 2008-2014 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 """Interfaces defining email commands."""
20 from __future__ import absolute_import, unicode_literals
22 __metaclass__ = type
23 __all__ = [
24 'ContinueProcessing',
25 'ICLISubCommand',
26 'IEmailCommand',
27 'IEmailResults',
31 from enum import Enum
32 from zope.interface import Interface, Attribute
36 class ContinueProcessing(Enum):
37 """Should `IEmailCommand.process()` continue or not."""
38 no = 0
39 yes = 1
43 class IEmailResults(Interface):
44 """The email command results object."""
46 output = Attribute('An output file object for printing results to.')
50 class IEmailCommand(Interface):
51 """An email command."""
53 name = Attribute('Command name as seen in a -request email.')
55 argument_description = Attribute('Description of command arguments.')
57 description = Attribute('Command help.')
59 def process(mlist, msg, msgdata, arguments, results):
60 """Process the email command.
62 :param mlist: The mailing list target of the command.
63 :param msg: The original message object.
64 :param msgdata: The message metadata.
65 :param arguments: The command arguments tuple.
66 :param results: An IEmailResults object for these commands.
67 :return: A `ContinueProcessing` enum specifying whether to continue
68 processing or not.
69 """
73 class ICLISubCommand(Interface):
74 """A command line interface subcommand."""
76 name = Attribute('The command name; must be unique')
78 __doc__ = Attribute('The command short help')
80 def add(parser, command_parser):
81 """Add the subcommand to the subparser.
83 :param parser: The argument parser.
84 :type parser: `argparse.ArgumentParser`
85 :param subparser: The command subparser.
86 :type subparser: `argparse.ArgumentParser`
87 """
89 def process(args):
90 """Process the subcommand.
92 :param args: The namespace, as passed in by argparse.
93 :type args: `argparse.Namespace`
94 """