The Cred
class represents a credential with various attributes such as name, URL, email, login, password, note, and share information.
name
(str): The name of the credential.url
(str): The URL associated with the credential.email
(str): The email address related to the credential.login
(str): The login username or identifier.password
(str): The password for the credential.note
(str): Additional notes about the credential.share
(str): Information on who the credential is shared with.
Initializes a new Cred object.
Parameters:
name
(str, optional): The name of the credential.url
(str, optional): The URL associated with the credential.email
(str, optional): The email address related to the credential.login
(str, optional): The login username or identifier.password
(str, optional): The password for the credential.note
(str, optional): Additional notes about the credential.share
(str, optional): Information on who the credential is shared with.
Returns: A new Cred object.
Converts the Cred object to a dictionary.
Returns: A dictionary representation of the Cred object.
Checks if the Cred object has all attributes empty.
Returns:
True
if all attributes are empty, False
otherwise.
Creates a Cred object from a dictionary.
Parameters:
dict_in
(dict): The input dictionary containing the attributes of the credential.
Returns: A new Cred object initialized with the values from the dictionary.
Creates a mock Cred object with example values.
Returns: A new Cred object with pre-filled attributes for testing purposes.
# Create a new credential
cred = Cred(name="Example", url="https://example.com", email="user@example.com")
# Convert to dictionary
cred_dict = cred.to_dict()
# Check if credential is empty
is_empty = cred.isempty()
# Create from dictionary
new_cred = Cred.from_dict(cred_dict)
# Create a mock credential
mock_cred = Cred.mock()
This class provides a structured way to handle credential information, with methods for conversion between object and dictionary formats, checking for emptiness, and creating mock objects for testing purposes.