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.
- 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.
- abstract get(key)¶
Get the value a key stored.
- abstract set(key, value, overwrite=True)¶
Set a value of a key.
- abstract 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.
- 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.
- static _store_data(filename, json_data)¶
Store json data into a file.
- 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
EnvironmentError – If it cannot store the file.
ValueError – If not overwrite and the key exists.
- 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.