Skip to main content

A Flyweight pattern for loading yaml files

Project description

[![Build Status](](
[![Coverage Status](](
[![PyPI version](](

# pyyamlsettings

A Flyweight pattern for loading yaml files in Python.

## Installation
pyyamlsettings is python 2 and 3 compatible.
pip install pyyamlsettings

## Overview
There is a YamlSettings class exposed by the package that allows you to load and query yaml files.
Suppose we have a yaml file with the structure:
att1: 42
att2: "This is a string"

a: 1
b: 2
a: 3
b: 4

We can load this file:
import os
import pyyamlsettings

yaml_file_path = os.path.join("tests", "test_yaml_file.yaml")
settings = pyyamlsettings.YamlSettings(yaml_file_path)

And read particular items with:
result = settings.get_data("att1")
print(result) # 42

result = settings.get_data("level1", "level2", "b")
print(result) # 4

## Notes
Due to a [deprecation message]( yaml.load was modified slightly.
yaml.load(input, Loader=yaml.FullLoader)

Users may have [issues installing PyYAML]( as a dependency with the error message:
Cannot uninstall 'PyYAML'. It is a distutils installed project and ...

One way around this is to run:
pip install --ignore-installed PyYAML

Project details

Download files

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

Files for pyyamlsettings, version 0.0.4
Filename, size File type Python version Upload date Hashes
Filename, size pyyamlsettings-0.0.4-py2-none-any.whl (7.4 kB) File type Wheel Python version py2 Upload date Hashes View hashes
Filename, size pyyamlsettings-0.0.4-py3-none-any.whl (7.4 kB) File type Wheel Python version py3 Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page