Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

snam-1.0.4.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

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

snam-1.0.4-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file snam-1.0.4.tar.gz.

File metadata

  • Download URL: snam-1.0.4.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for snam-1.0.4.tar.gz
Algorithm Hash digest
SHA256 7a2b40336d23886ae5434bcf678060a199cd9efe8a246037701902474faa8169
MD5 9fe97dd49d4dc1c71e24c237abc93412
BLAKE2b-256 004fe04888036794b2d1dcdf7af4262412fd0378b50f5c49c990e734d5fbe734

See more details on using hashes here.

Provenance

The following attestation bundles were made for snam-1.0.4.tar.gz:

Publisher: deploy.yml on pylover/snam

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file snam-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: snam-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for snam-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 367b72323f3663a7687ab63bbe129cfe858d9d2d4d8d8d2e71bf9a6791b412ba
MD5 84fccd8c9791a085febba5dc17c733e3
BLAKE2b-256 72c7759b36b26c5c7740a595c2e507f40747d215a16b9196b4276f3a7d867cda

See more details on using hashes here.

Provenance

The following attestation bundles were made for snam-1.0.4-py3-none-any.whl:

Publisher: deploy.yml on pylover/snam

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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