A thin wrapper around libdspam. More...
Classes | |
class | ctx |
Hold context for a DSPAM message operation Each context creates a new DSPAM_CTX struct within libdspam. More... | |
class | error |
Functions | |
def | userdir |
Return path of user or group specific file. | |
def | get_fcntl_lock |
Get fnctl lock for open file using libdspam conventions. | |
def | free_fcntl_lock |
Free the fnctl lock for an open file using libdspam conventions. | |
def | set_debug |
Set debugging output mode. | |
def | set_verified_user |
Set verified_user flag. | |
def | libdspam_init |
Initialize libdspam. | |
def | libdspam_shutdown |
Shutdown libdspam. | |
Variables | |
tuple | LIBDSPAM_VERSION = (3,6,0) |
The compile time libdspam version. | |
DSPAM flags for current operation context | |
int | DSF_SIGNATURE = 0x02 |
Signature is provided or requested. | |
int | DSF_BIAS = 0x04 |
Assign processor bias to unknown tokens. | |
int | DSF_NOISE = 0x08 |
Apply Bayesian Noise Reduction logic. | |
int | DSF_WHITELIST = 0x10 |
Use automatic whitelisting logic. | |
int | DSF_MERGED = 0x20 |
Merge user/group data in memory. | |
int | DSF_UNLEARN = 0x80 |
Unlearn the message. | |
DSPAM Processing mode | |
int | DSM_PROCESS = 0 |
Classify and learn the supplied message using whatever training mode is specified. | |
int | DSM_TOOLS = 1 |
Identifies that the calling function is from a utility, and no operation will be requested. | |
int | DSM_CLASSIFY = 2 |
Classify the supplied message only, do not learn or update any counters. | |
int | DSM_NONE = 0xff |
Classifications | |
int | DSR_ISSPAM = 1 |
The message is spam. | |
int | DSR_ISINNOCENT = 2 |
The message is not spam. | |
int | DSR_NONE = 0xff |
No classification is supplied by the caller. | |
Source of Classification | |
int | DSS_ERROR = 0 |
Misclassification by dspam. | |
int | DSS_CORPUS = 1 |
Corpus fed message. | |
int | DSS_INOCULATION = 2 |
Message inoculation. | |
int | DSS_NONE = 0xff |
No source - use only with DSR_NONE. | |
Tokenizers. | |
int | DSZ_WORD = 1 |
Use WORD (uniGram) tokenizer. | |
int | DSZ_CHAIN = 2 |
Use CHAIN (biGram) tokenizer. | |
int | DSZ_SBPH = 3 |
Use SBPH (Sparse Binary Polynomial Hashing) tokenizer. | |
int | DSZ_OSB = 4 |
Use OSB (Orthogonal Sparse biGram) tokenizer. | |
Training Modes. | |
int | DST_TEFT = 0 |
Train on everything. | |
int | DST_TOE = 1 |
Train on error. | |
int | DST_TUM = 2 |
Train until mature. | |
int | DST_NOTRAIN = 0xFE |
Algorithms. | |
int | DSA_GRAHAM = 1 |
Graham-Bayesian. | |
int | DSA_BURTON = 2 |
Burton-Bayesian. | |
int | DSA_ROBINSON = 4 |
Robinson's Geometric Mean Test. | |
int | DSA_CHI_SQUARE = 8 |
Fischer-Robinson's Chi-Square. | |
int | DSA_NAIVE = 0x80 |
Naive Bayesian. | |
P-Value computations. | |
int | DSP_GRAHAM = 0x10 |
Graham-Bayesian. | |
int | DSP_ROBINSON = 0x20 |
Robinson's Geometric Mean Test. | |
int | DSP_MARKOV = 0x40 |
Markov Weighted Technique. |
A thin wrapper around libdspam.
Most users will not import dspam directly, but will instead import Dspam. This module gives you ultimate low level control from python.
def dspam.free_fcntl_lock | ( | fd | ) |
Free the fnctl lock for an open file using libdspam conventions.
fd | the fileno of an open file |
def dspam.get_fcntl_lock | ( | fd | ) |
Get fnctl lock for open file using libdspam conventions.
fd | the fileno of an open file |
def dspam.libdspam_init | ( | driver | ) |
Initialize libdspam.
Currently this just means dynamically loading the storage driver. The driver path can be None only if it was statically configured when libdspam was compiled.
libdspam_init calls dspam_init_driver(NULL)
, and will actually pass a DRIVER_CTX *
when I figure out the multi-threading API.
driver | str pathname to storage driver |
def dspam.libdspam_shutdown | ( | ) |
Shutdown libdspam.
Currently this just means unloading the storage driver, unless statically configured at libdspam compile time.
libdspam_shutdown calls dspam_shutdown_driver(NULL)
, with the DRIVER_CTX *
used in libdspam_init.
def dspam.set_debug | ( | mode | ) |
Set debugging output mode.
Mode 2 is more efficient, but mode 1 ensures that you see all the output. This only works if libdspam was configured with --enable-debug when compiled, and pydspam has DEBUG uncommented at the top. I will recommend to upstream that DO_DEBUG be always exported - or perhaps dspam_set_debug(int).
def dspam.set_verified_user | ( | flag | ) |
Set verified_user flag.
Set to true for libdspam to autocreate user directories, and other behaviour I haven't speced out yet. I defaulted this to True, since that is the dspam default when external lookup is not configured.
def dspam.userdir | ( | home, | ||
user, | ||||
ext = None | ||||
) |
Return path of user or group specific file.
This calls the internal libdspam function _ds_userdir_path()
, which has compile time options for how the path name is computed (for example LARGEFILE, HOMEDIR, DOMAINSCALE). If the extension is None, the user directory is returned, otherwise the path of a user file is returned. For a user file with no extension, use an empty string for the extension.
int dspam.DSF_BIAS = 0x04 |
Assign processor bias to unknown tokens.
int dspam.DSF_MERGED = 0x20 |
Merge user/group data in memory.
int dspam.DSF_NOISE = 0x08 |
Apply Bayesian Noise Reduction logic.
int dspam.DSF_SIGNATURE = 0x02 |
Signature is provided or requested.
int dspam.DSF_UNLEARN = 0x80 |
Unlearn the message.
int dspam.DSF_WHITELIST = 0x10 |
Use automatic whitelisting logic.
int dspam.DSM_CLASSIFY = 2 |
Classify the supplied message only, do not learn or update any counters.
int dspam.DSM_PROCESS = 0 |
Classify and learn the supplied message using whatever training mode is specified.
int dspam.DSM_TOOLS = 1 |
Identifies that the calling function is from a utility, and no operation will be requested.
int dspam.DSR_ISINNOCENT = 2 |
The message is not spam.
int dspam.DSR_ISSPAM = 1 |
The message is spam.
int dspam.DSR_NONE = 0xff |
No classification is supplied by the caller.
tuple dspam.LIBDSPAM_VERSION = (3,6,0) |
The compile time libdspam version.
Python code might need to deal with several iterations of the libdspam API. This module constant is a tuple with the major, minor, and patch level of the library API at the time pydspam was compiled. This is not necessarily the same as the version of dspam running.