Skip to main content

Read your YAML files easily

Project description

Simplify how you read configuration files using PyYAML

codecov Code style: black PyPI Python Unit Tests

Installation

The library is available on PyPI and can be installed using pip:

pip install pyaml-object

Usage

Having a service.yaml file such:

service:
    version: 1.0.0
    name: myservice
    secret_key: XXXXXX

We can read the config file through the Config API by applying the read method.

from pyyaml_object import Config
conf_manager = Config('service.yaml')
conf = conf_manager.read()

Now we have a conf object that embedes every key and value from our yaml file. For instance, we can reconstitute a constant SETTING variable such:

SETTINGS = {
    'VERSION': conf.service.version,
    'NAME': conf.service.name,
    'SECRET_KEY': conf.service.secret_key
}

print(SETTINGS)
#{'VERSION': '1.0.0', 'NAME': 'myservice', 'SECRET_KEY': 'XXXXXX'}

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

pyaml_object-2.0.1.post0.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

pyaml_object-2.0.1.post0-py3-none-any.whl (5.0 kB view hashes)

Uploaded Python 3

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