Skip to main content

A Flyweight pattern for loading yaml files

Project description

[![Build Status](https://travis-ci.org/simongarisch/yamlsettings.svg?branch=master)](https://travis-ci.org/simongarisch/yamlsettings)
[![Coverage Status](https://coveralls.io/repos/github/simongarisch/yamlsettings/badge.svg?branch=master)](https://coveralls.io/github/simongarisch/yamlsettings?branch=master)

# pyyamlsettings

A Flyweight pattern for loading yaml files in Python.

## Installation
pyyamlsettings is python 2 and 3 compatible.
```bash
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"

level1:
a: 1
b: 2
level2:
a: 3
b: 4
```

We can load this file:
```python
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:
```python
result = settings.get_data("att1")
print(result) # 42

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


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

pyyamlsettings-0.0.1.tar.gz (3.9 kB view hashes)

Uploaded Source

Built Distributions

pyyamlsettings-0.0.1-py3-none-any.whl (6.0 kB view hashes)

Uploaded Python 3

pyyamlsettings-0.0.1-py2-none-any.whl (6.0 kB view hashes)

Uploaded Python 2

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