File: loading-dirty-yaml.md

package info (click to toggle)
python-strictyaml 1.7.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,708 kB
  • sloc: python: 12,836; sh: 48; makefile: 3
file content (50 lines) | stat: -rw-r--r-- 1,042 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
---
title: Dirty load
---


StrictYAML refuses to parse flow style and node anchors
by default, but since there have since been
[some requests](https://github.com/crdoconnor/strictyaml/issues/38)
to parse flow style, this now allowed with the "dirty_load" method.
If allow_flow_style is True, Map indentation is not checked for
consistency, as the indentation level is dependent on the map key length.




```python
from strictyaml import Map, Int, MapPattern, Seq, Str, Any, dirty_load

schema = Map({"foo": Map({"a": Any(), "b": Any(), "c": Any()}), "y": MapPattern(Str(), Str()), "z": Seq(Str())})

```



Flow style mapping:

```yaml
foo: { a: 1, b: 2, c: 3 }
y: {}
z: []

```


```python
assert dirty_load(yaml_snippet, schema, allow_flow_style=True) == {"foo": {"a": "1", "b": "2", "c": "3"}, "y": {}, "z": []}

```







!!! note "Executable specification"

    Documentation automatically generated from 
    <a href="https://github.com/crdoconnor/strictyaml/blob/master/hitch/story/dirty-load.story">dirty-load.story
    storytests.