Skip to main content

A simple way of using environment variables in TOML configs (via interpolation)

Project description

envtoml is an answer to a fairly simple problem: including values from environment variables in TOML configuration files. In this way, it is very similar to both envyaml and varyaml which provide very similar functionality for YAML and which greatly inspired this small package.

Example

Suppose we have the following configuration saved in config.toml

[db]
host = "$DB_HOST"
port = "$DB_PORT"
username = "$DB_USERNAME"
password = "$DB_PASSWORD"
name = "my_database"

with the environment variables being set to the following

DB_HOST=some-host.tld
DB_PORT=3306
DB_USERNAME=user01
DB_PASSWORD=veryToughPa$$w0rd

this config can then be parsed with envtoml in the following way:

from envtoml import load

cfg = load(open('./config.toml'))

print(cfg)
# {'db': {'host': 'some-host.tld',
#   'port': 3306,
#   'username': 'user01',
#   'password': 'veryToughPas$w0rd',
#   'name': 'my_database'}}

Tests

As this project makes use of Poetry, after installing it the tests can be ran by executing the following from the project’s root directory:

poetry run nosetests tests

They can also be ran with coverage:

poetry run nosetests --with-coverage tests

License

Licensed under the MIT license (see LICENSE file for more details).

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

envtoml-0.1.1.tar.gz (3.4 kB view details)

Uploaded Source

Built Distributions

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

envtoml-0.1.1-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

envTOML-0.1.1-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file envtoml-0.1.1.tar.gz.

File metadata

  • Download URL: envtoml-0.1.1.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.17 CPython/3.7.2 Linux/5.2.13-200.fc30.x86_64

File hashes

Hashes for envtoml-0.1.1.tar.gz
Algorithm Hash digest
SHA256 82f22a4114443ae0012476155b0759ce854b97e8b34a279e6f9b142e8efe3634
MD5 5e58c748f62b1efaacf7eab067006af8
BLAKE2b-256 85a32bdf5b743a53b7d2b835fb751bb209da1bbe73cd8dbb556948016c871963

See more details on using hashes here.

File details

Details for the file envtoml-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: envtoml-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.17 CPython/3.7.2 Linux/5.2.13-200.fc30.x86_64

File hashes

Hashes for envtoml-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f8a9af44734c975d0e5318a434a4594e00f622239183f69a378ecf2f471f7020
MD5 f797d49cf7e913eeb543eeb9247b8554
BLAKE2b-256 fd935181ed293300c1102a6aaa13dcc9390a933ea14aef064e49ff02e882cca8

See more details on using hashes here.

File details

Details for the file envTOML-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: envTOML-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.17 CPython/3.7.2 Linux/5.2.13-200.fc30.x86_64

File hashes

Hashes for envTOML-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 aecf6c5c8e53c0f180ba9788afd1f589f84a355908b7896fdd5940469891a5ca
MD5 f5b42c5e18fb3931b72f43074c034171
BLAKE2b-256 e4ce29ddc2ed69333102f3242a6153f9c52053499afa3da7786d491439bf47c1

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