Skip to main content

Metaclass for handling configuration class objects using environment variables.

If an environment variable is specified, the metaclass will pull the variable from the environment, the variable defined on the class will be used.

This was built to be a dropin replacement for flask-env but supporting change environment variables after the meta class is loaded.

Config

There are 2 configuration options, that are set on the base class object.

ENV_LOAD_ALL = <True/False>

Setting this on the class will allow loading any environment variable even if it is not set on the base class.

ENV_PREFIX = <string>

Setting this will will be a prefix for variables in the environment.

Install

This should just be pip installed

python3 -m pip install figenv

Usage

The basic usecase is below.

import os

import figenv

class Config(metaclass=figenv.MetaConfig):

   ENV_LOAD_ALL = True
   ENV_PREFIX = 'ROCKSTEADY_'

   BLAH = True
   TIMEOUT = 5

assert Config.TIMEOUT == 5
assert Config.BLAH is True
try:
    Config.WHAT
except AttributeError:
    pass

os.environ.update({
    'ROCKSTEADY_BLAH': 'false',
    'ROCKSTEADY_TIMEOUT': '15',
    'ROCKSTEADY_WHAT': '2.9',
})

assert Config.TIMEOUT == 15
assert Config.BLAH is False
assert Config.WHAT == 2.9

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

figenv-0.1.3.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

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

figenv-0.1.3-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file figenv-0.1.3.tar.gz.

File metadata

  • Download URL: figenv-0.1.3.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for figenv-0.1.3.tar.gz
Algorithm Hash digest
SHA256 feb126d6ff6b6b8de37d7f8d5e8ab09395a903b54306bb52afeecfda455888c3
MD5 c6c4d305da2d4702789f28b7d98c6a96
BLAKE2b-256 4826043f5798944072c4691e8261a9a5845dacccd3fad925c9ba1565ede6cb98

See more details on using hashes here.

File details

Details for the file figenv-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: figenv-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for figenv-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 da0feb92b843e3368e3168d2a5ee55b9fbfa41d73e809165697a62436995b0ff
MD5 a52a2c5ada82e209d607a2237641e5fa
BLAKE2b-256 a5a38d5c4bb3e44738fd18a27a6c1b510d77c7de8724cbb5d983c4beed5187aa

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 Sentry Error logging StatusPage Status page