Skip to main content

Find and load settings.yaml data into your project

Project description

get-settings-yaml

Small module for finding and parsing settings.yaml file in your project.

Setup

python -m pip install get-settings-yaml

API

Assuming the project structure:

  • myproject/
    • src/
      • run.py
  • my_settings.yaml

If you want to load my_settings.yaml from run.py script you should use this code inside:

import os
from get_settings_yaml import parse_settings


CURRENT_WORKING_DIR = os.path.dirname(__file__)
SETTINGS_FNAME = 'my_settings.yaml'
SETTINGS = parse_settings(base_path=CURRENT_WORKING_DIR, settings_filename=SETTINGS_FNAME)

if __name__ == '__main__':
    # Do something and use parsed settings
    pass

If you want to check path to the settings file:

import os
from get_settings_yaml import load_path


CURRENT_WORKING_DIR = os.path.dirname(__file__)
SETTINGS_FNAME = 'my_settings.yaml'
SETTINGS_PATH = load_path(base_path=CURRENT_WORKING_DIR, settings_filename=SETTINGS_FNAME)

if __name__ == '__main__':
    # Do something and load settings later
    pass

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

get-settings-yaml-1.0.0.tar.gz (3.7 kB view hashes)

Uploaded Source

Built Distribution

get_settings_yaml-1.0.0-py3-none-any.whl (3.8 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