syaml - YAML parser that environment variable is expanded
Install
$ pip install syaml
How to use it
A syaml is YAML parser that environment variable is expanded. It can use the path, name, here and environment variable in YAML file. It described in syntax of mako template. See http://www.makotemplates.org/ .
A path is absolute path to YAML file, and name is file name of YAML file, and here is absolute directory path the YAML file stored.
For example.
/path/to/test.yaml:
- ${here}
- ${name}
- ${path}
The above file is equivalent to the following a file.
- /path/to/ - test.yaml - /path/to/test.yaml
And, it can use environment variable in YAML file too.
/path/to/test.yaml:
- email: ${EMAIL}
If test@example.com the environment variable EMAIL is set, the above file is equivalent to the following a file.
- email: test@example.com
Load file and Load string
Example file /path/to/syaml/example.yml:
general:
- ${here}
- ${name}
- ${path}
Load file object:
>>> import syaml
>>> with open('example.yml', 'rb') as fp:
... syaml.load(fp)
...
{'general': ['/path/to/syaml', 'example.yml', '/path/to/syaml/example.yml']}
Load byte string object:
>>> syaml.loads(b'general:\n - ${here}\n - ${name}\n - ${path}\n')
{'general': ['', '', '']}
Load string object:
>>> syaml.loads('general:\n - ${here}\n - ${name}\n - ${path}\n')
{'general': ['', '', '']}
>>>
name and path and here will replace to empty string If you passed a string to syaml.loads function. They are for a file object. A string like object don’t have file path.
Use command line tool
syaml render
It render the SAYML file.
example.yml:
general:
- ${here}
- ${name}
- ${path}
Execute syaml render command:
$ syaml render example.yml general: - /path/to/syaml - example.yml - /path/to/syaml/example.yml
Execute syaml render command json style:
$ syaml render example.yml --json
{"general": ["/path/to/syaml", "example.yml", "/path/to/syaml/example.yml"]}
Execute syaml render command pre process only:
$ syaml render example.yml --pre general: - /path/to/syaml - example.yml - /path/to/syaml/example.yml
Unittest
This section describes the tools and tips used when unittest. Run these tests with the following command:
$ python -m unittest discover src
If all tests pass, you will see the following output:
.... ---------------------------------------------------------------------- Ran 4 tests in 0.018s OK
The number of tests performed may be higher than described in this document.
Test with docker
Build docker image:
$ docker buildx build -t syaml .
Run test:
$ docker run -it --rm --workdir="/app" --volume "$(pwd):/app" --name="syaml" syaml tox
Release flow
Bump version. Edit setup.cfg file.
Generate distribution files. python -m build.
- Check distribution files. twine check dist/*.
You need to make sure there are no “errors” displayed on the console.
Upload distribution files. twine upload dist/*.
Other
Metadata
Release files for syaml 2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| syaml-2.0.tar.gz | 19.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| syaml-2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 38.3 kB
Release files / syaml-2.0.tar.gz
| Download URL | syaml-2.0.tar.gz |
|---|---|
| Size | 19.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
433adec15f54764b0da0504a12b984ec6d76eafe8b0dd79a86aaf732fdb0c7e2
|
|
BLAKE2b-256 checksum How to use checksums |
8e070bce2eba53fbd762fd07fe561a3e1811a97276d5e778bef81af3adfda92c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
|
Release files / syaml-2.0-py3-none-any.whl
| Download URL | syaml-2.0-py3-none-any.whl |
|---|---|
| Size | 19.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
98eafd89ec6575927d91b4fffd5fac9cbc078c9572441132199d6cc8162d7114
|
|
BLAKE2b-256 checksum How to use checksums |
83c4d33663e34c699350bc7bc56495fcd6c0fc14d84aa66d96e7d2025f72a6b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
|
Security for syaml 2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.