Skip to main content

Python-box based custom config python package.

Project description

Easily Launch Config (el_config)

Python-box based custom config package for simple python projects.

Features

  • Python-box based config
  • Custom base config module
  • Load environment variables
  • YAML or JSON based configs
  • Update with extra configs
  • Pre-load config
  • Validate config
  • Freeze config
  • Config as dictioary

Installation

1. Prerequisites

  • Python (>= v3.7)
  • PyPi (>= v21)

2. Install el-config

A. [RECOMMENDED] PyPi install

# Install or upgrade el-config package:
pip install --upgrade el-config

# To uninstall package:
pip uninstall -y el-config

B. Manually add to PYTHONPATH (Recommended for development)

# Clone repository by git:
git clone git@bitbucket.org:ellexiinc/el_config.git
cd el_config

# Install python dependencies:
pip install --upgrade pip
cat requirements.txt | xargs -n 1 -L 1 pip install --no-cache-dir

# Add current path to PYTHONPATH:
export PYTHONPATH="${PWD}:${PYTHONPATH}"

C. Manually compile and setup (Not recommended)

# Clone repository by git:
git clone git@bitbucket.org:ellexiinc/el_config.git
cd el_config

# Building python package:
pip install --upgrade pip setuptools wheel
python setup.py build
# Install python dependencies with built package to current python environment:
python setup.py install --record installed_files.txt

# To remove only installed el-config package:
head -n 1 installed_files.txt | xargs rm -vrf
# Or to remove all installed files and packages:
cat installed_files.txt | xargs rm -vrf

Usage/Examples

from el_config import ConfigBase


def _pre_load(config):
    config.test = '123'
    return config

_valid_schema = {
    'test':
    {
        'type': 'integer',
        'coerce': int
    }
}

_cb = ConfigBase(pre_load=_pre_load, valid_schema=_valid_schema)
_cb.load()
config = _cb.config

print(config)

Running Tests

To run tests, run the following command:

pytest tests/test_*.py

References

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

el_config-0.1.14.tar.gz (4.9 kB view hashes)

Uploaded Source

Supported by

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