Skip to main content

Directory-based configuration registry — file paths become env var names

Project description

uregistry: Directory-based configuration registry

Your config lives in plain files. File paths become env var names, file content becomes the value. No YAML, no JSON, no .env parsers — just a directory tree. 🌳

env/
  AI/
    DEFAULT_MODEL    → AI_DEFAULT_MODEL = "claude-sonnet-4-20250514"
    API_KEY          → AI_API_KEY = "sk-..."
  DEBUG              → DEBUG = "1"

Features

  • 📁 Files are config: Each file is one variable. The path is the name, the content is the value.
  • 🔀 Smart path resolution: Underscores become directories, or use / for explicit control.
  • 🎚️ Two-layer registry: System (shared) + local (project) — local values always win.
  • 🐚 Shell integration: Generate export statements for bash/zsh/fish — drop it into your rc file.
  • 🧹 Zero dependencies: Pure Python, nothing to install beyond the package itself.
  • 🔄 Read, write, delete: Full CRUD for your config with automatic directory cleanup.

Installation

pip install uregistry

Quick Start

from uregistry import load_env, get_env, set_env, delete_env, list_env, dump_shell

# Load all vars from env/ into os.environ
load_env()

# Read a single var (does not modify os.environ)
model = get_env("AI_DEFAULT_MODEL")
model = get_env("AI_DEFAULT_MODEL", default="gpt-4o")

# Write a var (creates dirs as needed, updates os.environ)
set_env("AI/API_KEY", "sk-new-key")
set_env("DEBUG", "1")

# Delete a var (removes file, cleans empty dirs)
delete_env("DEBUG")

# List all vars without modifying os.environ
all_vars = list_env()

# Generate shell export statements
print(dump_shell())                    # bash/zsh format
print(dump_shell(shell="fish"))        # fish format

System + Local Registry

uregistry supports two layers: system (shared/global defaults) and local (project-specific overrides). Local values always take priority. Writes always go to local.

# Load system defaults, then apply local overrides
load_env(system_dir="/etc/myapp/env")

# Same for reading — local wins over system
model = get_env("AI_DEFAULT_MODEL", system_dir="/etc/myapp/env")

# Writes always go to local registry
set_env("AI_DEFAULT_MODEL", "gpt-4o", system_dir="/etc/myapp/env")

# Delete from local — system value becomes visible again
delete_env("AI_DEFAULT_MODEL")

# List and dump merge both layers
all_vars = list_env(system_dir="/etc/myapp/env")
print(dump_shell(system_dir="/etc/myapp/env"))
/etc/myapp/env/              (system)        ./env/                  (local)
  AI/                                          AI/
    DEFAULT_MODEL = "gpt-4o"                     DEFAULT_MODEL = "claude-sonnet-4-20250514"  ← wins
    API_KEY = "sk-shared-..."                  DEBUG = "1"

If the system registry doesn't exist or system_dir is not specified — everything works with local only, same as before.

Path Resolution

Use / in names to set explicit directory boundaries:

set_env("AI/CRON_MODEL", "haiku")   # → env/AI/CRON_MODEL

Without /, underscores become directory separators automatically:

set_env("AI_MODEL", "sonnet")       # → env/AI/MODEL

If a file already exists that matches the full var name, it wins — no ambiguity.

Shell Integration

Drop this into your .bashrc / .zshrc and your env dir becomes the source of truth for your shell:

eval "$(python -m uregistry.registry)"

Or for fish, in config.fish:

python -m uregistry.registry --shell fish | source

Auto-detects your shell when run directly, so python -m uregistry.registry just works. 🐟

Why?

  • dotenv files get messy — merge conflicts, quoting bugs, one giant blob.
  • Directory trees are git-friendly, diffable, and you can manage individual vars with standard Unix tools (cat, echo >, rm).
  • Secret management fits naturally — just gitignore sensitive subtrees.

Contributing

Pull requests and issues are welcome!

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

License

MIT

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

uregistry-0.2.0.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

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

uregistry-0.2.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file uregistry-0.2.0.tar.gz.

File metadata

  • Download URL: uregistry-0.2.0.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for uregistry-0.2.0.tar.gz
Algorithm Hash digest
SHA256 b9c2ffaa560f62d6266404bbb6c3b4f383b65882aa5f5b0149a74eed31186057
MD5 077ee057e4353ab393867a1036dbc7ee
BLAKE2b-256 a919a07730bbcdda428cc089c38a0b33c38d8de3da773226df4e187b40ac28d1

See more details on using hashes here.

File details

Details for the file uregistry-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: uregistry-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for uregistry-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 335f9afba5f320143c696a3e2004543217b69cb22faaccdbe2ee8db760176fe7
MD5 8d9039c3741a86edc0d936a87a64735d
BLAKE2b-256 39cbbf307673e28e59fb1a50a4bd4522fb69409e9cb515c05d9899b7f5067d72

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