No project description provided
Project description
snam
Still Not A Markup!
Another YAML parser and builder featured by:
- Include other files.
- Expand environment varibales.
- Execute and use the shell commands standard output.
- Merge/Melt mappings.
Install
pip install snam
quickstart
from snam import loads
yamldoc = '''
foo:
enabled: true
title: BAR
rate: .73
user: !env USER
greeting: !shell echo Hello
fruites:
- cherry
- melon
- banana
- pineapple
'''
obj = loads(ymldoc)
assert obj.foo.enabled
assert obj.title == 'BAR'
assert obj.rate == 0.73
assert obj.fruites == ['cherry', 'melon', 'banana', 'pineapple']
Tutorial
Parsing
You may user loads(str) function to parse YAML string, and load(file)
to parse file-like object or filename. these functions return a
snam.Meld object. The Meld object is subclass of the Python's dictionary
but in addtion you can access the members by getattr, setattr and
delattr operations.
meld = loads('foo: bar')
assert meld.foo == 'bar'
meld = load('foo.yml')
with open('foo.yml') as file:
meld = load(file)
Merging/Melting
Using the |= operator you may merge any other dictionary or YAML-string
into a Meld.
meld |= '''
foo: bar
baz: 23
'''
And also using the <<= you may load a file-like object or a filename into a
Meld object.
meld <<= 'foo.yml'
with open('foo.yml') as file:
meld <<= file
Dump
Use snam.dumps(obj) -> str, snam.dump(obj, file) and also
meld >>= filename.
dumps(meld, indent=6, indentsize=2)
dump(meld, 'foo.yml', indent=6, indentsize=2)
with open('foo.yml', 'w') as file:
dump(meld, file, indent=6, indentsize=2)
meld >>= 'foo.yml'
with open('foo.yml', 'w') as file:
meld >>= file
Contribution
Dependencies
Install python-makelib.
Virtualenv
Create virtual environment:
make venv
Delete virtual environment:
make venv-delete
Activate the virtual environment:
source ./activate.sh
Install (editable mode)
Install this project as editable mode and all other development dependencies:
make env
Tests
Execute all tests:
make test
Execute specific test(s) using wildcard:
make test F=tests/test_db*
make test F=tests/test_form.py::test_querystringform
refer to pytest documentation for more info about invoking tests.
Execute tests and report coverage result:
make cover
make cover F=tests/test_static.py
make cover-html
Lint
make lint
Distribution
Execute these commands to create Python's standard distribution packages
at dist directory:
make sdist
make wheel
Clean build directory
Execute:
make clean
to clean-up previous dist/* and build/* directories.
PyPI
WARNING: Do not do this if you'r not responsible as author and or maintainer of this project.
Execute
make clean
make pypi
to upload sdists and wheel packages on PyPI.
Documentation
source activate.sh
make doc
make doclive
make doctest
Or
source activate.sh
cd sphinx
make doctest
make html
make livehtml
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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 snam-1.2.0.tar.gz.
File metadata
- Download URL: snam-1.2.0.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8136e53e364859c3a561293f5b6e4fa64e516bee9200d741e20906eec6d9949e
|
|
| MD5 |
4455b12c0027929dfc7ca9d493509c36
|
|
| BLAKE2b-256 |
f7db7d09045152417af62a58efc3abc2338408f698dd1c01a49a798863ff23c1
|
Provenance
The following attestation bundles were made for snam-1.2.0.tar.gz:
Publisher:
deploy.yml on pylover/snam
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
snam-1.2.0.tar.gz -
Subject digest:
8136e53e364859c3a561293f5b6e4fa64e516bee9200d741e20906eec6d9949e - Sigstore transparency entry: 1524912305
- Sigstore integration time:
-
Permalink:
pylover/snam@f9732eeb8b7e070aac779e1899c585226df4fae4 -
Branch / Tag:
refs/tags/v1.2.0 - Owner: https://github.com/pylover
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
deploy.yml@f9732eeb8b7e070aac779e1899c585226df4fae4 -
Trigger Event:
release
-
Statement type:
File details
Details for the file snam-1.2.0-py3-none-any.whl.
File metadata
- Download URL: snam-1.2.0-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64e11b883946954a512a6b76b7a13ecd23d5b05cb8e101cde7901e5a88d825c5
|
|
| MD5 |
9b8d571b14614b1bc04b77e4f82db6a8
|
|
| BLAKE2b-256 |
0739596e4cc15e952449f035314a4a0243b4d70b5b2182c89f0164f772afbef0
|
Provenance
The following attestation bundles were made for snam-1.2.0-py3-none-any.whl:
Publisher:
deploy.yml on pylover/snam
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
snam-1.2.0-py3-none-any.whl -
Subject digest:
64e11b883946954a512a6b76b7a13ecd23d5b05cb8e101cde7901e5a88d825c5 - Sigstore transparency entry: 1524912316
- Sigstore integration time:
-
Permalink:
pylover/snam@f9732eeb8b7e070aac779e1899c585226df4fae4 -
Branch / Tag:
refs/tags/v1.2.0 - Owner: https://github.com/pylover
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
deploy.yml@f9732eeb8b7e070aac779e1899c585226df4fae4 -
Trigger Event:
release
-
Statement type: