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 details)

Uploaded Source

Built Distributions

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

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

Uploaded Python 3

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

Uploaded Python 2

File details

Details for the file pyyamlsettings-0.0.1.tar.gz.

File metadata

  • Download URL: pyyamlsettings-0.0.1.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/2.7.15

File hashes

Hashes for pyyamlsettings-0.0.1.tar.gz
Algorithm Hash digest
SHA256 0fb991e40343c79c8e395e4917d8b81c46af926b70891313f61bdcb417a07cf2
MD5 bbae3571ef8372e96bef46ec08d1b8d9
BLAKE2b-256 da7b770e408cd4f3b81a9d9757fec3536b1b5b95ee3e786c6198389673695fae

See more details on using hashes here.

File details

Details for the file pyyamlsettings-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: pyyamlsettings-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.6

File hashes

Hashes for pyyamlsettings-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 382772e0109e99db52e1e64cd6f24844ae2959ab5505b4b95175dbe5248b33e2
MD5 c8a2f05cba026291f4c95db974a597a2
BLAKE2b-256 f488b7c6c4f698bb3c972dfe28a521ca124435a550d9fd435121e5d860a59e07

See more details on using hashes here.

File details

Details for the file pyyamlsettings-0.0.1-py2-none-any.whl.

File metadata

  • Download URL: pyyamlsettings-0.0.1-py2-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/2.7.15

File hashes

Hashes for pyyamlsettings-0.0.1-py2-none-any.whl
Algorithm Hash digest
SHA256 f30104a1eb7a4ae4a6aae133d54770314b09c7f87ed0c5bb9e1f914122243c9b
MD5 83c73e839d85dcbfc5ec103b86b4e1f1
BLAKE2b-256 9a8dd60d2c147be05201cb892e57c7792e7fb350104dd5c8baf3c47985d83da4

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