pydspam  1.4
Classes | Functions | Variables
Dspam Namespace Reference

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
 

Detailed Description

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.

Function Documentation

◆ _tag_part()

def Dspam._tag_part (   msg,
  sigkey 
)
private

Add tag to a non-multipart message.

Parameters
msgmime.Message - Message object for the part of an email to be tagged
sigkeystr

Referenced by add_signature_tag().

◆ 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.

Parameters
msgmime.Message - the original message to tag
sigkeystr - the signature tag
probfloat - probability for X-Dspam-Score header field if supplied
factorslist<float> - factors for X-Dspam-Factors header field if supplied

References _tag_part().

Referenced by Dspam.DSpamDirectory._add_sig().

◆ convert_eol()

def Dspam.convert_eol (   txt)

Convert message to unix end of line conventions.

Parameters
txtbytes - the original message
Returns
the message bytes with b'
' as line separator

Referenced by Dspam.DSpamDirectory.check_spam(), and Dspam.DSpamDirectory.write_web_stats().

◆ extract_signature_tags()

def Dspam.extract_signature_tags (   txt)

Extract all DSPAM tags from a message.

Parameters
txtemail message as bytes
Returns
<message bytes with tags removed> ,

Referenced by Dspam.DSpamDirectory.write_web_stats().

◆ parse_groups()

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'] }
 
Parameters
groupfilestr - filename of group list

Referenced by Dspam.DSpamDirectory.get_group(), and Dspam.DSpamDirectory.write_web_stats().

◆ put_signature()

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.

Parameters
dsthe dspam.ctx
sigthe signature from the dspam.ctx
sigfileif given, a bsddb database to use instead of the dspam driver

References create_signature_id().

Referenced by Dspam.DSpamDirectory._add_sig().

Variable Documentation

◆ CONFIGURE_ARGS

def Dspam.CONFIGURE_ARGS = _configure_dict()

Arguments passed to configure when building libdspam as a dict.

Flag arguments are mapped to True.

See also
dspam.CONFIGURE_ARGS
Since
1.3.1

◆ PKGLIBDIR

Dspam.PKGLIBDIR = os.path.join(CONFIGURE_ARGS['--libdir'],'dspam')

The directory where package specific dynamic libraries are stored.

This includes drivers and plugins.

Since
1.3.1