Skip to content

Latest commit

 

History

History
87 lines (57 loc) · 2.46 KB

doc_cred.md

File metadata and controls

87 lines (57 loc) · 2.46 KB

Cred Class Documentation

Overview

The Cred class represents a credential with various attributes such as name, URL, email, login, password, note, and share information.

Class: Cred

Attributes

  • 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.

Methods

__init__(self, name=None, url=None, email=None, login=None, password=None, note=None, share=None)

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.

to_dict(self)

Converts the Cred object to a dictionary.

Returns: A dictionary representation of the Cred object.

isempty(self)

Checks if the Cred object has all attributes empty.

Returns: True if all attributes are empty, False otherwise.

from_dict(dict_in) (static method)

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.

mock() (static method)

Creates a mock Cred object with example values.

Returns: A new Cred object with pre-filled attributes for testing purposes.

Usage

# 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.