1# Copyright (C) 2007-2020 by the Free Software Foundation, Inc.
2#
3# This file is part of GNU Mailman.
4#
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.
9#
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.
14#
15# You should have received a copy of the GNU General Public License along with
16# GNU Mailman.  If not, see <https://www.gnu.org/licenses/>.
17
18"""Interface describing the basics of rules."""
19
20from public import public
21from zope.interface import Attribute, Interface
22
23
24@public
25class IRule(Interface):
26    """A basic rule."""
27
28    name = Attribute('Rule name; must be unique.')
29
30    description = Attribute('A brief description of the rule.')
31
32    record = Attribute(
33        """Should this rule's success or failure be recorded?
34
35        This is a boolean; if True then this rule's hit or miss will be
36        recorded in a message header.  If False, it won't.
37        """)
38
39    def check(mlist, msg, msgdata):
40        """Run the rule.
41
42        :param mlist: The mailing list object.
43        :param msg: The message object.
44        :param msgdata: The message metadata.
45        :returns: a boolean specifying whether the rule matched or not.
46        """
47