Skip to content

Latest commit

 

History

History
73 lines (48 loc) · 1.84 KB

File metadata and controls

73 lines (48 loc) · 1.84 KB

HedgeBuddy Python Library

Cross-platform environment variable management without system pollution.

Installation

pip install --user hedgebuddy

Quick Start

import hedgebuddy

# Required variable (raises error if missing)
api_key = hedgebuddy.var("API_KEY")

# Optional with fallback
api_url = hedgebuddy.var("API_URL", "https://api.example.com")

# Optional (None if missing)
email = hedgebuddy.var("REPORT_EMAIL", None)

API

Core Functions

hedgebuddy.var(name, default=...)  # Get variable
hedgebuddy.exists(name)            # Check if exists
hedgebuddy.all_vars()              # Get all as dict
hedgebuddy.inject_env()            # Inject into os.environ

Logging (for headless scripts)

hedgebuddy.enable_logging()        # Enable daily log files
print("This is logged!")           # Captured automatically

hedgebuddy.log("Message")          # Log directly
hedgebuddy.log_error("Error")
hedgebuddy.log_warning("Warning")

Log Location: %APPDATA%\hedgebuddy\logs\ (Windows) · ~/Library/Application Support/hedgebuddy/logs/ (macOS)

Exceptions

hedgebuddy.VariableNotFoundError   # Variable missing (no default)
hedgebuddy.StorageNotFoundError    # active profile vars.json not found
hedgebuddy.StorageCorruptedError   # Invalid JSON

Storage

  • Windows: %APPDATA%\HedgeBuddy\profiles\<active>\vars.json
  • macOS: ~/Library/Application Support/HedgeBuddy/profiles/<active>/vars.json

The library resolves the active profile from profiles.json automatically.

Desktop App

Download from Releases to manage variables with a GUI.

Links

GitHub · Issues · PyPI

MIT License