flexpass.Backend
- class flexpass.Backend(*, name: str, priority: int, readonly: bool, **options)
Bases:
objectBase class for backend implementations.
- __init__(*, name: str, priority: int, readonly: bool, **options)
Instanciate the backend.
Backend implementations should raise :exception:BackendNotAvailable from their __init__ in case the backend is not currently available.
- Raises:
BackendNotAvailable – The backend is not currently available.
BackendError – An other error occured while instanciating the backend.
Methods
__init__(*, name, priority, readonly, **options)Instanciate the backend.
close()Perform clean-up of resources before closing the backend.
delete_password(name[, warn_if_notfound])Delete the given password from the backend.
get_password(name[, warn_if_notfound])Return the password with the given name, or None if not found in the backend.
List all available passwords in the backend.
set_password(name, password, **options)Set the given password in the backend.
Attributes
Indicate whether the backend is read-only.
Name of the backend.
Priority of the backend.
Options passed to the backend.
- close()
Perform clean-up of resources before closing the backend.
- delete_password(name: str, warn_if_notfound=False) bool
Delete the given password from the backend.
Return True if the password was deleted, False if the password was not found.
- Parameters:
name (str) – Name of the password.
warn_if_notfound (bool, optional) – If True, emit a warning if no password with the given name is found (defaults to False).
- Returns:
True if the password was deleted, False if the password was not found.
- Return type:
bool
- get_password(name: str, warn_if_notfound=False) str | None
Return the password with the given name, or None if not found in the backend.
- Parameters:
name (str) – Name of the password.
warn_if_notfound (bool, optional) – If True, emit a warning if no password with the given name is found (defaults to False).
- Returns:
The value of the password if found, None if not found.
- Return type:
str or None
- list_passwords() list[PasswordInfo]
List all available passwords in the backend.
- Returns:
Password name and information from the backend.
- Return type:
list[PasswordInfo]
- name: str
Name of the backend.
- options: dict[str, Any]
Options passed to the backend.
- priority: int
Priority of the backend.
- readonly = False
Indicate whether the backend is read-only.
- set_password(name: str, password: str, **options) bool
Set the given password in the backend.
- Parameters:
name (str) – Name of the password.
password (str) – Value of the password.