Differences between revisions 6 and 7
Revision 6 as of 2017-08-07 19:45:34
Size: 1382
Comment: Replaced cold link http://code.google.com/p/rietveld/source/browse/app.yaml with new link https://github.com/rietveld-codereview/rietveld/blob/master/app.yaml
Revision 7 as of 2021-03-28 17:41:23
Size: 1590
Editor: eriky
Comment: Some cleanup, spelling corrections, added part about safely using PyYAML (safe_load vs load)
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
YAML may be the most human friendly format for structured data invented so far. YAML is a human-friendly format for structured data, that is both easy to write for humans and still parsable by computers.
Line 5: Line 5:
YAML is a feature-overcrept language. Most packages below use its subset. YAML is a feature-rich language. Some packages that heavily depend on YAML are:
Line 12: Line 12:
=== Full YAML parsers === === PyYAML parser ===
Line 14: Line 14:
PyYAML - http://pyyaml.org/ - due to complexity of YAML spec, this is the only package that tried to be compliant. It is C-based. [[http://pyyaml.org/|PyYAML]] is the most-used and go-to YAML package, which tries to be as compliant as possible with the YAML specs. It is, at its core, C-based. It can both read and write YAML. You can read the [[https://pyyaml.org/wiki/PyYAMLDocumentation|official documentation]], or try the condensed/simplified version of these docs, with usable example code on this [[https://python.land/data-processing/python-yaml|Python YAML tutorial]].
Line 16: Line 16:
=== Parsers for YAML subsets ===

Luckily, you may not need the full YAML spec. These libraries can parse
only the sweetest parts of YAML spec that you may reuse in your configs.

Unfortunately, there doesn't seem to be any Python code that parses YAML
subset - pretty much every lib uses PyYAML. But still it worth to list
honorable mentions that may be modified to build mininal parsers:

 * rsolnite - https://pypi.python.org/pypi/rsonlite/0.1.0
 * kivy - https://github.com/kivy/kivy/blob/master/kivy/lang.py and http://kivy.org/docs/guide/lang.html
When using this package, be careful which function you use. The `load()` function is very powerful and allows arbitrary code execution, while the `safe_load()` function is enough for most use cases. It only allows a subset of the load function, making it a much safer choice. For more details, see also the [[https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation|load deprecation notice]].

YAML is a human-friendly format for structured data, that is both easy to write for humans and still parsable by computers.

YAML examples and usage in notable Python apps

YAML is a feature-rich language. Some packages that heavily depend on YAML are:

PyYAML parser

PyYAML is the most-used and go-to YAML package, which tries to be as compliant as possible with the YAML specs. It is, at its core, C-based. It can both read and write YAML. You can read the official documentation, or try the condensed/simplified version of these docs, with usable example code on this Python YAML tutorial.

When using this package, be careful which function you use. The load() function is very powerful and allows arbitrary code execution, while the safe_load() function is enough for most use cases. It only allows a subset of the load function, making it a much safer choice. For more details, see also the load deprecation notice.

YAML (last edited 2021-03-28 17:42:24 by eriky)

Unable to edit the page? See the FrontPage for instructions.