Skip to main content

A utility for working with pass

Project description

Clarence

A package for working with pass. It allows you to fetch and list secrets stored in the password store. It's named for an excellent passer.

Installation

Before using Clarence please ensure you have the pass command-line tool installed and properly configured.

Then using the package is simply:

# If using uv
uv add clarence

# Or with pip
pip install clarence

Usage

Fetching a secret

To fetch a secret from your password store:

from clarence import get_secret
secret = get_secret("path/to/secret")

The result of get_secret is an object of class Secret: this is basically just a regular str but with a print method that obscures the secret if you happen to print it to the console. While this helps make it harder to reveal a secret, you still must take care.

When you want to use your secret you need to use the reveal method. This makes it obvious when your code is using the unobscured secret.

connection_string = f"mssql+pymssql://1234567:{secret.reveal()}@example.com/testingdb"

Listing secrets

You can view all available secrets:

from clarence import list_secrets
list_secrets()

The result is a SecretsList object, which will print in the same way as the pass command-line utility.

Documentation

Functions

get_secret(path: str) -> Secret

Fetches a secret from the password store.

  • Args:
    • path (str): The path to the secret in the password store.
  • Returns:
    • Secret: The retrieved secret.

list_secrets() -> SecretsList

Lists all the secrets in the password store.

  • Returns:
    • SecretsList: An object containing the list of secrets.

Classes

Secret

Represents a secret as a string, obscured when printing.

  • Methods:
    • __init__(value: str): Initializes the secret with its actual value.
    • __str__() -> str: Returns an obscured string representation of the secret.
    • __repr__() -> str: Returns an obscured string representation for debugging.
    • __format__(format_spec: str) -> str: Returns the actual secret value when used in formatted strings.
    • reveal() -> str: Returns the actual secret value as a string.

SecretsList

Represents a list of secrets.

  • Methods:
    • __init__(tree: str): Initializes the SecretsList with a tree structure.
    • __str__() -> str: Returns the string representation of the tree.
    • __repr__() -> str: Returns the string representation of the tree for debugging.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clarence-0.2.1.tar.gz (28.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

clarence-0.2.1-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file clarence-0.2.1.tar.gz.

File metadata

  • Download URL: clarence-0.2.1.tar.gz
  • Upload date:
  • Size: 28.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.17

File hashes

Hashes for clarence-0.2.1.tar.gz
Algorithm Hash digest
SHA256 14fd0aa64e4b8f4c5b0830eb3c0ce2af8bcfeaf371e93f66c455a3cecf2e8c1f
MD5 bd53452c292cde32b6866f4debc195a3
BLAKE2b-256 993930961de7cbdb9b8b79a59a22c9a80da7d90d9923c5327914650ef51417bc

See more details on using hashes here.

File details

Details for the file clarence-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: clarence-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.17

File hashes

Hashes for clarence-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 acb8573a21c6ac8a96a31261bb16295ed4178d55f7b417e8e96867097658f8b9
MD5 2215712cb113ac8d7ca52a51160a52b9
BLAKE2b-256 7451d5c272ed8d9dfcd1a91e4f00e915c4630d40c0ae9c167c59bf68c382a9a9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page