A Flyweight pattern for loading yaml files
Project description
[](https://travis-ci.org/simongarisch/yamlsettings)
[](https://coveralls.io/github/simongarisch/yamlsettings?branch=master)
[](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
```
[](https://coveralls.io/github/simongarisch/yamlsettings?branch=master)
[](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 Distribution
pyyamlsettings-0.0.2.tar.gz
(4.0 kB
view details)
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyyamlsettings-0.0.2.tar.gz.
File metadata
- Download URL: pyyamlsettings-0.0.2.tar.gz
- Upload date:
- Size: 4.0 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33588852e0e477d32ca2da809f63201cc849a27deee52c05bdd99a4bdf3d7406
|
|
| MD5 |
951673573a6a351650fdd9fdfddce6e7
|
|
| BLAKE2b-256 |
94e1cf212a79a0a0909a4e0d0b9b286bab41029923f227dd37b8c715429edfc2
|
File details
Details for the file pyyamlsettings-0.0.2-py3-none-any.whl.
File metadata
- Download URL: pyyamlsettings-0.0.2-py3-none-any.whl
- Upload date:
- Size: 6.1 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
203046558429fe0eab847729164a451e160b5b05b64a4c6c4337a33e036bc34f
|
|
| MD5 |
1b3acda56164d1c085aba751691ffcea
|
|
| BLAKE2b-256 |
e596d9c301f9b90400c4be530f487c3658fb8890e1c5c8b752dc28f2ae8c3d8c
|
File details
Details for the file pyyamlsettings-0.0.2-py2-none-any.whl.
File metadata
- Download URL: pyyamlsettings-0.0.2-py2-none-any.whl
- Upload date:
- Size: 6.2 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
565279d9f8b42648657fb2fa23d7b74612aa5bed686ccb9cc4579cd5ff0c683c
|
|
| MD5 |
49e561c2a2ade6773875d3f5ff400789
|
|
| BLAKE2b-256 |
0e717c4496b617b4a2040571dcef856407908a970675a3324d77906f5b310826
|