An open API service indexing awesome lists of open source software.

https://github.com/otvam/yaml_extension_python

Python Code for Extending the YAML Format
https://github.com/otvam/yaml_extension_python

include python yaml yaml-extension yaml-parser

Last synced: 22 days ago
JSON representation

Python Code for Extending the YAML Format

Awesome Lists containing this project

README

          

# Python Code for Extending the YAML Format

![license - BSD](https://img.shields.io/badge/license-BSD-green)
![language - python](https://img.shields.io/badge/language-python-blue)
![category - hobby](https://img.shields.io/badge/category-hobby-lightgrey)
![status - unmaintained](https://img.shields.io/badge/status-unmaintained-red)

This **Python** class offers extensions to the **YAML** format:
* include YAML file in YAML file
* include relative filesystem paths
* include Python expression

The extensions can be used as:
```
include_var: !include 'sub.yaml' #include the content file sub.yaml
path_var: !path 'sub.yaml' # parse the relative path with respect to the YAML file
exec_var: !exec '[1, 2, 3]' # evaluate the Python expression
```

The example [test_yaml.pym](test_yaml.py) demonstrates the YAML parsing with the extensions.

This class:
* was tested on "MS Windows" but should run with Linux
* was tested with Python 3.6 and 3.7 but should run with Python 2.7

This class uses "ast.literal_eval" for a "safe" parsing of Python expression. However the capabilities are limited.
For an advanced parsing "pyparsing" could be used.

## Author

**Thomas Guillod** - [GitHub Profile](https://github.com/otvam)

## License

This project is licensed under the **BSD License**, see [LICENSE.md](LICENSE.md).