Another YAML parser and builder featured by:
- Include other files.
- Expand environment varibales.
- Execute and use the shell commands standard output.
- Merge/Melt mappings.
pip install snamfrom 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']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)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 <<= fileUse 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 >>= fileInstall python-makelib.
Create virtual environment:
make venvDelete virtual environment:
make venv-deleteActivate the virtual environment:
source ./activate.shInstall this project as editable mode and all other development dependencies:
make envExecute all tests:
make testExecute specific test(s) using wildcard:
make test F=tests/test_db*
make test F=tests/test_form.py::test_querystringformrefer 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-htmlmake lintExecute these commands to create Python's standard distribution packages
at dist directory:
make sdist
make wheelExecute:
make cleanto clean-up previous dist/* and build/* directories.
WARNING: Do not do this if you'r not responsible as author and or maintainer of this project.
Execute
make clean
make pypito upload sdists and wheel packages on PyPI.
source activate.sh
make doc
make doclive
make doctestOr
source activate.sh
cd sphinx
make doctest
make html
make livehtml