pydspam
1.4
|
Classes | |
class | DSpamDirectory |
Operations on the DSPAM directory. More... | |
Functions | |
def | _configure_dict () |
def | file_lock (fname) |
def | create_signature_id () |
Create a mostly unique tag for a signature. | |
def | put_signature (ds, sig, sigfile=None) |
Add signature to database. More... | |
def | _tag_part (msg, sigkey) |
Add tag to a non-multipart message. More... | |
def | add_signature_tag (msg, sigkey, prob=None, factors=None, trace=False) |
Add DSPAM tag to message. More... | |
def | extract_signature_tags (txt) |
Extract all DSPAM tags from a message. More... | |
def | parse_groups (groupfile, dups=False) |
Parse old group file. More... | |
def | convert_eol (txt) |
Convert message to unix end of line conventions. More... | |
Variables | |
bsddb = None | |
long = int | |
def | CONFIGURE_ARGS = _configure_dict() |
Arguments passed to configure when building libdspam as a dict. More... | |
PKGLIBDIR = os.path.join(CONFIGURE_ARGS['--libdir'],'dspam') | |
The directory where package specific dynamic libraries are stored. More... | |
string | VERSION = "1.3.1" |
_seq_lock = threading.Lock() | |
int | _seq = 0 |
A high level framework for using dspam from a python application.
The Dspam module currently hardwires the "hash" storage driver. This driver generally requires that your application have an effective group id of "mail", and have a umask that will allow other applications in the mail group read/write/execute access.
COPYRIGHT (C) 2003-2020 Stuart D. Gathman
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
private |
Add tag to a non-multipart message.
msg | mime.Message - Message object for the part of an email to be tagged |
sigkey | str |
Referenced by add_signature_tag().
def Dspam.add_signature_tag | ( | msg, | |
sigkey, | |||
prob = None , |
|||
factors = None , |
|||
trace = False |
|||
) |
Add DSPAM tag to message.
We do this the old htmlish way.
msg | mime.Message - the original message to tag |
sigkey | str - the signature tag |
prob | float - probability for X-Dspam-Score header field if supplied |
factors | list<float> - factors for X-Dspam-Factors header field if supplied |
References _tag_part().
Referenced by Dspam.DSpamDirectory._add_sig().
def Dspam.convert_eol | ( | txt | ) |
Convert message to unix end of line conventions.
txt | bytes - the original message |
Referenced by Dspam.DSpamDirectory.check_spam(), and Dspam.DSpamDirectory.write_web_stats().
def Dspam.extract_signature_tags | ( | txt | ) |
Extract all DSPAM tags from a message.
txt | email message as bytes |
Referenced by Dspam.DSpamDirectory.write_web_stats().
def Dspam.parse_groups | ( | groupfile, | |
dups = False |
|||
) |
Parse old group file.
This version parses the old dspam-2.6 group file, which we will keep around a while for compatibility. Syntax is very simple:
group1: user1,user2 group2: user1,user3,user4
returns the map:
{ 'user1': ['group1','group2'], 'user2': ['group1'], 'user3': ['group2'], 'user4': ['group2'] }
groupfile | str - filename of group list |
Referenced by Dspam.DSpamDirectory.get_group(), and Dspam.DSpamDirectory.write_web_stats().
def Dspam.put_signature | ( | ds, | |
sig, | |||
sigfile = None |
|||
) |
Add signature to database.
By default, use the signature database provided by the dspam database driver. If sigfile is supplied, it is a bsdddb database that we manage ourselves (including purging old entries, since dspam no longer does that). I suspect we do not really need the bsddb option, but it is there for now.
ds | the dspam.ctx |
sig | the signature from the dspam.ctx |
sigfile | if given, a bsddb database to use instead of the dspam driver |
References create_signature_id().
Referenced by Dspam.DSpamDirectory._add_sig().
def Dspam.CONFIGURE_ARGS = _configure_dict() |
Arguments passed to configure when building libdspam as a dict.
Flag arguments are mapped to True.
Dspam.PKGLIBDIR = os.path.join(CONFIGURE_ARGS['--libdir'],'dspam') |
The directory where package specific dynamic libraries are stored.
This includes drivers and plugins.