Skip to main content

A lightweight configuration sync utility with environment variable interpolation

Project description

configsync-lite

A lightweight Python library for managing configuration files with environment variable interpolation and schema validation.

Installation

pip install configsync-lite

Quick Start

from configsync_lite import ConfigSync

cfg = ConfigSync("config.json")
db_host = cfg.get("database.host")

Features

  • JSON configuration file support
  • Dot notation access (cfg.get("database.host"))
  • Environment variable interpolation (${DB_HOST})
  • Schema validation
  • Deep merge of multiple configs
  • Zero dependencies

Usage

Basic Configuration

from configsync_lite import ConfigSync, load_config

# Load from file
cfg = ConfigSync("myapp.json")

# Get values with dot notation
host = cfg.get("server.host", default="localhost")
port = cfg.get("server.port", default=8080)

# Set and save
cfg.set("server.port", 9090)
cfg.save()

Environment Variable Interpolation

from configsync_lite import load_config, interpolate_env

raw = load_config("config.json")
# config.json contains: {"db": {"password": "${DB_PASSWORD}"}}

resolved = interpolate_env(raw)
# Replaces ${DB_PASSWORD} with actual env var value

Merging Configs

from configsync_lite import merge_configs

base = {"server": {"host": "localhost", "port": 8080}}
override = {"server": {"port": 9090}, "debug": True}

merged = merge_configs(base, override)
# {"server": {"host": "localhost", "port": 9090}, "debug": True}

Schema Validation

from configsync_lite import load_config, validate_schema

config = load_config("config.json")
schema = {
    "host": {"type": "str", "required": True},
    "port": {"type": "int", "required": True},
    "debug": {"type": "bool", "required": False}
}

errors = validate_schema(config, schema)
if errors:
    print("Config errors:", errors)

Contributing

See CONTRIBUTING.md for development setup and guidelines.

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

configsync_lite-0.1.2.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

configsync_lite-0.1.2-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file configsync_lite-0.1.2.tar.gz.

File metadata

  • Download URL: configsync_lite-0.1.2.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for configsync_lite-0.1.2.tar.gz
Algorithm Hash digest
SHA256 7e0f0c8150cb4ec08cbf47301a98519306c75daa1fa7c165d0e0966d66ae185f
MD5 8932865564c746af2ea973c940ea0468
BLAKE2b-256 cee558dd54f95ab3b5006e43e41755a6808fc6b18030bc324f28d350f308f15a

See more details on using hashes here.

File details

Details for the file configsync_lite-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for configsync_lite-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1aa684da5c2c228f7f85cbe10315d0af5570dd721cc935985ba9f68b1a1cf72e
MD5 a1c7d36e09f91f9e80c32a93f84e7667
BLAKE2b-256 9d6a563a5ba226aef0d0f410c40b5d4556b434a1ba1fc79375aa5c67f721be6e

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