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 details)

Uploaded Source

File details

Details for the file el_config-0.1.14.tar.gz.

File metadata

  • Download URL: el_config-0.1.14.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.9

File hashes

Hashes for el_config-0.1.14.tar.gz
Algorithm Hash digest
SHA256 9d244d37e01a0304caa5b3c53d7e86a0781550f439da7e20705c34d2da96e4b2
MD5 917074b90ddd0679e6becd9546a2137a
BLAKE2b-256 705a7fefd13a4101d8fd3d1c5e778280903edbbefd1d4d7f8e923519ec9507d4

See more details on using hashes here.

Supported by

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