Skip to main content

A Flyweight pattern for loading yaml files

Project description

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

# 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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

pyyamlsettings-0.0.3-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

pyyamlsettings-0.0.3-py2-none-any.whl (7.1 kB view details)

Uploaded Python 2

File details

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

File metadata

  • Download URL: pyyamlsettings-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.20.1 setuptools/41.0.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for pyyamlsettings-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1b2d108e887df256e3f6cf5173e1fd4908b50bcd5d8a62a61518009819babff8
MD5 3487e96e84006b3d435dd6cd8dd3a91d
BLAKE2b-256 34746fd2649a5c8c08d748e41c0c866b7e57c6c7130a7a2db69a8c8cc3dd5143

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyyamlsettings-0.0.3-py2-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.19.1 setuptools/41.0.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15

File hashes

Hashes for pyyamlsettings-0.0.3-py2-none-any.whl
Algorithm Hash digest
SHA256 0f4ee459479183dfff74766d0dff75a1de5ec2bba57a0177859899641c028eab
MD5 c95bd61bd2d9093136a902257bb93530
BLAKE2b-256 7fff79d9d7375120ff3efd536aae1e21d6ae84a1c6912ad26553c068a8d14fe3

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