7.1.1.1.5. isbg.secrets module

Imap secrets module for isbg - IMAP Spam Begone.

New in version 2.1.0.

class isbg.secrets.Secret(imapset, hashlen=256)

Bases: object

Abstract class used to store secret info.

imapset

A imap setings object.

Type:isbg.imaputils.ImapSettings
hashlen

Length of the value hash. Must be a multiple of 16. Default 256.

Type:int
logger = <Logger isbg.secrets (WARNING)>

Logger object used to show debug info.

__init__(imapset, hashlen=256)

Initialize a SecretKeyring object.

get(key)

Get the value a key stored.

set(key, value, overwrite=True)

Set a value of a key.

delete(key)

Delete a stored key and his value.

class isbg.secrets.SecretIsbg(filename, imapset, hashlen=256)

Bases: isbg.secrets.Secret

Class used to store secret info using our own implementation.

filename

the filename used to read or store the key and values.

imapset

A imap setings object.

Type:isbg.imaputils.ImapSettings
hashlen

Length of the value hash. Must be a multiple of 16. Defaults to 256.

Type:int, optional
__init__(filename, imapset, hashlen=256)

Initialize a SecretISBG object.

get(key)

Get the value a key stored.

Parameters:key (str) – The key string requested.
Returns:The value of the key or None if it cannot be found.
set(key, value, overwrite=True)

Set a value of a key.

If it cannot find the file or their contents are not a right json data, it will overwrite it with the key and value pair.

Parameters:
  • key (str) – The key to store.
  • value (str) – The value to store.
  • overwrite (boolean, optional) – If True it should overwrite and existing key. Defaults to True.
Raises:
delete(key)

Delete a key.

If no more keys are stored, it deletes the file.

Parameters:key (str) – The key to store.
Raises:ValueError – If the key to delete is not found.