ozzyyaml 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ozzyyaml-0.1.0/Cargo.lock +236 -0
- ozzyyaml-0.1.0/Cargo.toml +11 -0
- ozzyyaml-0.1.0/PKG-INFO +106 -0
- ozzyyaml-0.1.0/README.md +84 -0
- ozzyyaml-0.1.0/crates/ozzyyaml/Cargo.toml +17 -0
- ozzyyaml-0.1.0/crates/ozzyyaml/README.md +85 -0
- ozzyyaml-0.1.0/crates/ozzyyaml/src/compose.rs +275 -0
- ozzyyaml-0.1.0/crates/ozzyyaml/src/error.rs +57 -0
- ozzyyaml-0.1.0/crates/ozzyyaml/src/lib.rs +19 -0
- ozzyyaml-0.1.0/crates/ozzyyaml/src/limits.rs +55 -0
- ozzyyaml-0.1.0/crates/ozzyyaml/src/schema/core.rs +236 -0
- ozzyyaml-0.1.0/crates/ozzyyaml/src/schema/mod.rs +3 -0
- ozzyyaml-0.1.0/crates/ozzyyaml/src/value.rs +126 -0
- ozzyyaml-0.1.0/crates/ozzyyaml/tests/compose.rs +182 -0
- ozzyyaml-0.1.0/crates/ozzyyaml/tests/suite_allowlist.txt +146 -0
- ozzyyaml-0.1.0/crates/ozzyyaml/tests/suite_shape_allowlist.txt +23 -0
- ozzyyaml-0.1.0/crates/ozzyyaml/tests/yaml_test_suite_compose.rs +81 -0
- ozzyyaml-0.1.0/crates/ozzyyaml/tests/yaml_test_suite_compose_shape.rs +84 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-emit/Cargo.toml +17 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-emit/README.md +65 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-emit/src/anchors.rs +103 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-emit/src/emit.rs +238 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-emit/src/error.rs +15 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-emit/src/lib.rs +14 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-emit/src/options.rs +24 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-emit/src/scalar.rs +89 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-emit/tests/emit_anchors.rs +221 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-emit/tests/emit_basic.rs +194 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-emit/tests/emit_stream.rs +94 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-parser/Cargo.toml +16 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-parser/README.md +76 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-parser/src/chars.rs +40 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-parser/src/error.rs +102 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-parser/src/event.rs +92 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-parser/src/lib.rs +20 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-parser/src/limits.rs +65 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-parser/src/mark.rs +60 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-parser/src/parser/document.rs +181 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-parser/src/parser/flow.rs +61 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-parser/src/parser/mod.rs +211 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-parser/src/parser/node.rs +168 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-parser/src/parser/tests.rs +85 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-parser/src/reader.rs +229 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-parser/src/scanner/block.rs +71 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-parser/src/scanner/document.rs +97 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-parser/src/scanner/flow.rs +59 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-parser/src/scanner/mod.rs +218 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-parser/src/scanner/scalar.rs +81 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-parser/src/scanner/tests.rs +240 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-parser/src/token.rs +129 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-parser/tests/collections.rs +445 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-parser/tests/documents.rs +332 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-parser/tests/suite_allowlist.txt +135 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-parser/tests/unicode_anchors.rs +83 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-parser/tests/yaml_test_suite.rs +177 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-python/Cargo.toml +19 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-python/src/graph.rs +234 -0
- ozzyyaml-0.1.0/crates/ozzyyaml-python/src/lib.rs +223 -0
- ozzyyaml-0.1.0/ozzyyaml/__init__.py +27 -0
- ozzyyaml-0.1.0/pyproject.toml +29 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 3
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "autocfg"
|
|
7
|
+
version = "1.5.1"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
|
|
10
|
+
|
|
11
|
+
[[package]]
|
|
12
|
+
name = "cfg-if"
|
|
13
|
+
version = "1.0.5"
|
|
14
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
15
|
+
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
|
|
16
|
+
|
|
17
|
+
[[package]]
|
|
18
|
+
name = "heck"
|
|
19
|
+
version = "0.5.0"
|
|
20
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
21
|
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
22
|
+
|
|
23
|
+
[[package]]
|
|
24
|
+
name = "indoc"
|
|
25
|
+
version = "2.0.8"
|
|
26
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
27
|
+
checksum = "a37b2691796cffeb8a8cd305ac66e65841559f147f4e63231d0eafa4db5384d1"
|
|
28
|
+
dependencies = [
|
|
29
|
+
"rustversion",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[[package]]
|
|
33
|
+
name = "libc"
|
|
34
|
+
version = "0.2.191"
|
|
35
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
36
|
+
checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
|
|
37
|
+
|
|
38
|
+
[[package]]
|
|
39
|
+
name = "memoffset"
|
|
40
|
+
version = "0.9.1"
|
|
41
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
42
|
+
checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
|
|
43
|
+
dependencies = [
|
|
44
|
+
"autocfg",
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
[[package]]
|
|
48
|
+
name = "once_cell"
|
|
49
|
+
version = "1.21.4"
|
|
50
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
51
|
+
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
|
52
|
+
|
|
53
|
+
[[package]]
|
|
54
|
+
name = "ozzyyaml"
|
|
55
|
+
version = "0.1.0"
|
|
56
|
+
dependencies = [
|
|
57
|
+
"ozzyyaml-parser",
|
|
58
|
+
"thiserror",
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
[[package]]
|
|
62
|
+
name = "ozzyyaml-emit"
|
|
63
|
+
version = "0.1.0"
|
|
64
|
+
dependencies = [
|
|
65
|
+
"ozzyyaml",
|
|
66
|
+
"thiserror",
|
|
67
|
+
]
|
|
68
|
+
|
|
69
|
+
[[package]]
|
|
70
|
+
name = "ozzyyaml-parser"
|
|
71
|
+
version = "0.1.0"
|
|
72
|
+
dependencies = [
|
|
73
|
+
"thiserror",
|
|
74
|
+
]
|
|
75
|
+
|
|
76
|
+
[[package]]
|
|
77
|
+
name = "ozzyyaml-python"
|
|
78
|
+
version = "0.1.0"
|
|
79
|
+
dependencies = [
|
|
80
|
+
"ozzyyaml",
|
|
81
|
+
"ozzyyaml-emit",
|
|
82
|
+
"pyo3",
|
|
83
|
+
]
|
|
84
|
+
|
|
85
|
+
[[package]]
|
|
86
|
+
name = "portable-atomic"
|
|
87
|
+
version = "1.15.0"
|
|
88
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
89
|
+
checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
|
|
90
|
+
|
|
91
|
+
[[package]]
|
|
92
|
+
name = "proc-macro2"
|
|
93
|
+
version = "1.0.107"
|
|
94
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
95
|
+
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
|
96
|
+
dependencies = [
|
|
97
|
+
"unicode-ident",
|
|
98
|
+
]
|
|
99
|
+
|
|
100
|
+
[[package]]
|
|
101
|
+
name = "pyo3"
|
|
102
|
+
version = "0.23.5"
|
|
103
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
104
|
+
checksum = "7778bffd85cf38175ac1f545509665d0b9b92a198ca7941f131f85f7a4f9a872"
|
|
105
|
+
dependencies = [
|
|
106
|
+
"cfg-if",
|
|
107
|
+
"indoc",
|
|
108
|
+
"libc",
|
|
109
|
+
"memoffset",
|
|
110
|
+
"once_cell",
|
|
111
|
+
"portable-atomic",
|
|
112
|
+
"pyo3-build-config",
|
|
113
|
+
"pyo3-ffi",
|
|
114
|
+
"pyo3-macros",
|
|
115
|
+
"unindent",
|
|
116
|
+
]
|
|
117
|
+
|
|
118
|
+
[[package]]
|
|
119
|
+
name = "pyo3-build-config"
|
|
120
|
+
version = "0.23.5"
|
|
121
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
122
|
+
checksum = "94f6cbe86ef3bf18998d9df6e0f3fc1050a8c5efa409bf712e661a4366e010fb"
|
|
123
|
+
dependencies = [
|
|
124
|
+
"once_cell",
|
|
125
|
+
"target-lexicon",
|
|
126
|
+
]
|
|
127
|
+
|
|
128
|
+
[[package]]
|
|
129
|
+
name = "pyo3-ffi"
|
|
130
|
+
version = "0.23.5"
|
|
131
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
132
|
+
checksum = "e9f1b4c431c0bb1c8fb0a338709859eed0d030ff6daa34368d3b152a63dfdd8d"
|
|
133
|
+
dependencies = [
|
|
134
|
+
"libc",
|
|
135
|
+
"pyo3-build-config",
|
|
136
|
+
]
|
|
137
|
+
|
|
138
|
+
[[package]]
|
|
139
|
+
name = "pyo3-macros"
|
|
140
|
+
version = "0.23.5"
|
|
141
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
142
|
+
checksum = "fbc2201328f63c4710f68abdf653c89d8dbc2858b88c5d88b0ff38a75288a9da"
|
|
143
|
+
dependencies = [
|
|
144
|
+
"proc-macro2",
|
|
145
|
+
"pyo3-macros-backend",
|
|
146
|
+
"quote",
|
|
147
|
+
"syn 2.0.119",
|
|
148
|
+
]
|
|
149
|
+
|
|
150
|
+
[[package]]
|
|
151
|
+
name = "pyo3-macros-backend"
|
|
152
|
+
version = "0.23.5"
|
|
153
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
154
|
+
checksum = "fca6726ad0f3da9c9de093d6f116a93c1a38e417ed73bf138472cf4064f72028"
|
|
155
|
+
dependencies = [
|
|
156
|
+
"heck",
|
|
157
|
+
"proc-macro2",
|
|
158
|
+
"pyo3-build-config",
|
|
159
|
+
"quote",
|
|
160
|
+
"syn 2.0.119",
|
|
161
|
+
]
|
|
162
|
+
|
|
163
|
+
[[package]]
|
|
164
|
+
name = "quote"
|
|
165
|
+
version = "1.0.47"
|
|
166
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
167
|
+
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
|
168
|
+
dependencies = [
|
|
169
|
+
"proc-macro2",
|
|
170
|
+
]
|
|
171
|
+
|
|
172
|
+
[[package]]
|
|
173
|
+
name = "rustversion"
|
|
174
|
+
version = "1.0.23"
|
|
175
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
176
|
+
checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
|
|
177
|
+
|
|
178
|
+
[[package]]
|
|
179
|
+
name = "syn"
|
|
180
|
+
version = "2.0.119"
|
|
181
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
182
|
+
checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
|
|
183
|
+
dependencies = [
|
|
184
|
+
"proc-macro2",
|
|
185
|
+
"quote",
|
|
186
|
+
"unicode-ident",
|
|
187
|
+
]
|
|
188
|
+
|
|
189
|
+
[[package]]
|
|
190
|
+
name = "syn"
|
|
191
|
+
version = "3.0.10"
|
|
192
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
193
|
+
checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79"
|
|
194
|
+
dependencies = [
|
|
195
|
+
"proc-macro2",
|
|
196
|
+
"quote",
|
|
197
|
+
"unicode-ident",
|
|
198
|
+
]
|
|
199
|
+
|
|
200
|
+
[[package]]
|
|
201
|
+
name = "target-lexicon"
|
|
202
|
+
version = "0.12.16"
|
|
203
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
204
|
+
checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
|
|
205
|
+
|
|
206
|
+
[[package]]
|
|
207
|
+
name = "thiserror"
|
|
208
|
+
version = "2.0.21"
|
|
209
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
210
|
+
checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e"
|
|
211
|
+
dependencies = [
|
|
212
|
+
"thiserror-impl",
|
|
213
|
+
]
|
|
214
|
+
|
|
215
|
+
[[package]]
|
|
216
|
+
name = "thiserror-impl"
|
|
217
|
+
version = "2.0.21"
|
|
218
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
219
|
+
checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524"
|
|
220
|
+
dependencies = [
|
|
221
|
+
"proc-macro2",
|
|
222
|
+
"quote",
|
|
223
|
+
"syn 3.0.10",
|
|
224
|
+
]
|
|
225
|
+
|
|
226
|
+
[[package]]
|
|
227
|
+
name = "unicode-ident"
|
|
228
|
+
version = "1.0.27"
|
|
229
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
230
|
+
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
|
|
231
|
+
|
|
232
|
+
[[package]]
|
|
233
|
+
name = "unindent"
|
|
234
|
+
version = "0.2.4"
|
|
235
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
236
|
+
checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3"
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
[workspace]
|
|
2
|
+
resolver = "2"
|
|
3
|
+
members = ["crates/ozzyyaml-parser", "crates/ozzyyaml", "crates/ozzyyaml-emit", "crates/ozzyyaml-python"]
|
|
4
|
+
|
|
5
|
+
[workspace.package]
|
|
6
|
+
version = "0.1.0"
|
|
7
|
+
edition = "2021"
|
|
8
|
+
license = "BSD-3-Clause"
|
|
9
|
+
repository = "https://github.com/peterkmurphy/ozzyyaml"
|
|
10
|
+
authors = ["Peter Murphy <peterkmurphy@gmail.com>"]
|
|
11
|
+
rust-version = "1.80"
|
ozzyyaml-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ozzyyaml
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Classifier: Development Status :: 3 - Alpha
|
|
5
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
11
|
+
Classifier: Programming Language :: Rust
|
|
12
|
+
Classifier: Topic :: Text Processing :: Markup
|
|
13
|
+
Summary: YAML 1.2.2 parser and emitter with Unicode anchor support
|
|
14
|
+
Author-email: Peter Murphy <peterkmurphy@gmail.com>
|
|
15
|
+
License: BSD-3-Clause
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
18
|
+
Project-URL: Homepage, https://github.com/peterkmurphy/ozzyyaml
|
|
19
|
+
Project-URL: Issues, https://github.com/peterkmurphy/ozzyyaml/issues
|
|
20
|
+
Project-URL: Repository, https://github.com/peterkmurphy/ozzyyaml
|
|
21
|
+
|
|
22
|
+
# ozzyyaml
|
|
23
|
+
|
|
24
|
+
**YAML 1.2.2** for Python, backed by a from-scratch Rust implementation.
|
|
25
|
+
Licensed under the BSD-3-Clause.
|
|
26
|
+
|
|
27
|
+
ozzyyaml exists because common stacks still struggle with parts of the 1.2.2
|
|
28
|
+
spec. In particular, **libyaml** (and therefore **PyYAML**) rejects Unicode in
|
|
29
|
+
anchor and alias names. ozzyyaml accepts them on purpose (`&汉`, `*😀`, and
|
|
30
|
+
similar).
|
|
31
|
+
|
|
32
|
+
## Install
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install ozzyyaml
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Wheels are built for Linux, macOS, and Windows. Until the first PyPI release is
|
|
39
|
+
up, install from a [git checkout](#develop-from-a-checkout) instead.
|
|
40
|
+
|
|
41
|
+
Requires Python 3.10 or newer.
|
|
42
|
+
|
|
43
|
+
## Quick start
|
|
44
|
+
|
|
45
|
+
Two APIs share the same parser:
|
|
46
|
+
|
|
47
|
+
- **Native** — ordinary `dict` / `list` / scalars (familiar, but cycles error)
|
|
48
|
+
- **Value** — structured nodes that keep alias identity, including cycles
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
import ozzyyaml
|
|
52
|
+
|
|
53
|
+
doc = ozzyyaml.load("{name: Ada, ok: true}\n")
|
|
54
|
+
assert doc == {"name": "Ada", "ok": True}
|
|
55
|
+
|
|
56
|
+
print(ozzyyaml.dump({"items": [1, 2]})) # flow style by default
|
|
57
|
+
|
|
58
|
+
# Shared aliases become the same Python object
|
|
59
|
+
v = ozzyyaml.load_value("[&a hello, *a]\n")
|
|
60
|
+
assert v[0] is v[1]
|
|
61
|
+
assert v[0].as_str() == "hello"
|
|
62
|
+
|
|
63
|
+
# Cycles need the Value API
|
|
64
|
+
cycle = ozzyyaml.load_value("&a [*a]\n")
|
|
65
|
+
assert cycle[0] is cycle[0][0]
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Dump styles are `"flow"` (default) and `"block"`. Multi-document streams use
|
|
69
|
+
`load_all` / `dump_all` (native) or `load_all_value` (structured).
|
|
70
|
+
|
|
71
|
+
Failures from the Rust stack raise `ozzyyaml.OzzyYamlError`.
|
|
72
|
+
|
|
73
|
+
## What you get
|
|
74
|
+
|
|
75
|
+
| Need | Use |
|
|
76
|
+
| --- | --- |
|
|
77
|
+
| Everyday config / data | `load` / `dump` |
|
|
78
|
+
| Aliases that form a DAG | either API (`a is b` for shared nodes) |
|
|
79
|
+
| Cycles | `load_value` / `dump_value` |
|
|
80
|
+
| Resource caps | `max_anchors`, `max_nesting_depth`, `max_input_bytes` keyword args |
|
|
81
|
+
|
|
82
|
+
The loader follows the YAML **1.2.2 Core** schema, so plain `yes` / `no` stay
|
|
83
|
+
strings rather than becoming booleans.
|
|
84
|
+
|
|
85
|
+
## Develop from a checkout
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
git clone https://github.com/peterkmurphy/ozzyyaml.git
|
|
89
|
+
cd ozzyyaml
|
|
90
|
+
git submodule update --init --recursive
|
|
91
|
+
cd python
|
|
92
|
+
python3 -m venv .venv
|
|
93
|
+
source .venv/bin/activate # Windows: .venv\Scripts\activate
|
|
94
|
+
pip install maturin pytest
|
|
95
|
+
maturin develop
|
|
96
|
+
pytest
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Learn more
|
|
100
|
+
|
|
101
|
+
- [Python guide](https://github.com/peterkmurphy/ozzyyaml/blob/main/docs/python.md) —
|
|
102
|
+
types, limits, and the full Value API
|
|
103
|
+
- [Architecture](https://github.com/peterkmurphy/ozzyyaml/blob/main/docs/architecture.md) —
|
|
104
|
+
how the Rust pipeline fits together
|
|
105
|
+
- [Repository](https://github.com/peterkmurphy/ozzyyaml) — Rust crates and CI
|
|
106
|
+
|
ozzyyaml-0.1.0/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# ozzyyaml
|
|
2
|
+
|
|
3
|
+
**YAML 1.2.2** for Python, backed by a from-scratch Rust implementation.
|
|
4
|
+
Licensed under the BSD-3-Clause.
|
|
5
|
+
|
|
6
|
+
ozzyyaml exists because common stacks still struggle with parts of the 1.2.2
|
|
7
|
+
spec. In particular, **libyaml** (and therefore **PyYAML**) rejects Unicode in
|
|
8
|
+
anchor and alias names. ozzyyaml accepts them on purpose (`&汉`, `*😀`, and
|
|
9
|
+
similar).
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install ozzyyaml
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Wheels are built for Linux, macOS, and Windows. Until the first PyPI release is
|
|
18
|
+
up, install from a [git checkout](#develop-from-a-checkout) instead.
|
|
19
|
+
|
|
20
|
+
Requires Python 3.10 or newer.
|
|
21
|
+
|
|
22
|
+
## Quick start
|
|
23
|
+
|
|
24
|
+
Two APIs share the same parser:
|
|
25
|
+
|
|
26
|
+
- **Native** — ordinary `dict` / `list` / scalars (familiar, but cycles error)
|
|
27
|
+
- **Value** — structured nodes that keep alias identity, including cycles
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
import ozzyyaml
|
|
31
|
+
|
|
32
|
+
doc = ozzyyaml.load("{name: Ada, ok: true}\n")
|
|
33
|
+
assert doc == {"name": "Ada", "ok": True}
|
|
34
|
+
|
|
35
|
+
print(ozzyyaml.dump({"items": [1, 2]})) # flow style by default
|
|
36
|
+
|
|
37
|
+
# Shared aliases become the same Python object
|
|
38
|
+
v = ozzyyaml.load_value("[&a hello, *a]\n")
|
|
39
|
+
assert v[0] is v[1]
|
|
40
|
+
assert v[0].as_str() == "hello"
|
|
41
|
+
|
|
42
|
+
# Cycles need the Value API
|
|
43
|
+
cycle = ozzyyaml.load_value("&a [*a]\n")
|
|
44
|
+
assert cycle[0] is cycle[0][0]
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Dump styles are `"flow"` (default) and `"block"`. Multi-document streams use
|
|
48
|
+
`load_all` / `dump_all` (native) or `load_all_value` (structured).
|
|
49
|
+
|
|
50
|
+
Failures from the Rust stack raise `ozzyyaml.OzzyYamlError`.
|
|
51
|
+
|
|
52
|
+
## What you get
|
|
53
|
+
|
|
54
|
+
| Need | Use |
|
|
55
|
+
| --- | --- |
|
|
56
|
+
| Everyday config / data | `load` / `dump` |
|
|
57
|
+
| Aliases that form a DAG | either API (`a is b` for shared nodes) |
|
|
58
|
+
| Cycles | `load_value` / `dump_value` |
|
|
59
|
+
| Resource caps | `max_anchors`, `max_nesting_depth`, `max_input_bytes` keyword args |
|
|
60
|
+
|
|
61
|
+
The loader follows the YAML **1.2.2 Core** schema, so plain `yes` / `no` stay
|
|
62
|
+
strings rather than becoming booleans.
|
|
63
|
+
|
|
64
|
+
## Develop from a checkout
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
git clone https://github.com/peterkmurphy/ozzyyaml.git
|
|
68
|
+
cd ozzyyaml
|
|
69
|
+
git submodule update --init --recursive
|
|
70
|
+
cd python
|
|
71
|
+
python3 -m venv .venv
|
|
72
|
+
source .venv/bin/activate # Windows: .venv\Scripts\activate
|
|
73
|
+
pip install maturin pytest
|
|
74
|
+
maturin develop
|
|
75
|
+
pytest
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Learn more
|
|
79
|
+
|
|
80
|
+
- [Python guide](https://github.com/peterkmurphy/ozzyyaml/blob/main/docs/python.md) —
|
|
81
|
+
types, limits, and the full Value API
|
|
82
|
+
- [Architecture](https://github.com/peterkmurphy/ozzyyaml/blob/main/docs/architecture.md) —
|
|
83
|
+
how the Rust pipeline fits together
|
|
84
|
+
- [Repository](https://github.com/peterkmurphy/ozzyyaml) — Rust crates and CI
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "ozzyyaml"
|
|
3
|
+
description = "YAML 1.2.2 Core-schema documents with shared aliases and cycles"
|
|
4
|
+
version.workspace = true
|
|
5
|
+
edition.workspace = true
|
|
6
|
+
license.workspace = true
|
|
7
|
+
repository.workspace = true
|
|
8
|
+
authors.workspace = true
|
|
9
|
+
rust-version.workspace = true
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
documentation = "https://docs.rs/ozzyyaml"
|
|
12
|
+
keywords = ["yaml", "compose", "core-schema", "anchors"]
|
|
13
|
+
categories = ["parser-implementations", "encoding", "data-structures"]
|
|
14
|
+
|
|
15
|
+
[dependencies]
|
|
16
|
+
ozzyyaml-parser = { version = "0.1.0", path = "../ozzyyaml-parser" }
|
|
17
|
+
thiserror = "2"
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# ozzyyaml
|
|
2
|
+
|
|
3
|
+
Build YAML **1.2.2** documents into a shared [`Value`](https://docs.rs/ozzyyaml/latest/ozzyyaml/enum.Value.html)
|
|
4
|
+
graph using the Core schema.
|
|
5
|
+
|
|
6
|
+
This is the compose layer of the
|
|
7
|
+
[ozzyyaml](https://github.com/peterkmurphy/ozzyyaml) stack: it consumes events
|
|
8
|
+
from [`ozzyyaml-parser`](https://crates.io/crates/ozzyyaml-parser) and gives you
|
|
9
|
+
something you can inspect, share, and (with
|
|
10
|
+
[`ozzyyaml-emit`](https://crates.io/crates/ozzyyaml-emit)) write back out.
|
|
11
|
+
|
|
12
|
+
Licensed under the BSD-3-Clause.
|
|
13
|
+
|
|
14
|
+
## Why this exists
|
|
15
|
+
|
|
16
|
+
Everyday YAML tools still miss pieces of 1.2.2 that show up in real documents.
|
|
17
|
+
Unicode anchor names are the headline example — libyaml rejects them;
|
|
18
|
+
ozzyyaml accepts `&汉` and friends. The compose layer also keeps alias
|
|
19
|
+
**identity** instead of exploding shared structure into deep copies, so
|
|
20
|
+
cycles such as `&a [*a]` are representable.
|
|
21
|
+
|
|
22
|
+
## Quick start
|
|
23
|
+
|
|
24
|
+
```rust
|
|
25
|
+
use ozzyyaml::{from_str, Value};
|
|
26
|
+
|
|
27
|
+
fn main() {
|
|
28
|
+
let value = from_str("{name: Ada, ok: true}\n").expect("valid YAML");
|
|
29
|
+
match value {
|
|
30
|
+
Value::Mapping(entries) => {
|
|
31
|
+
println!("{} entries", entries.borrow().len());
|
|
32
|
+
}
|
|
33
|
+
other => println!("{other:?}"),
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Multi-document streams:
|
|
39
|
+
|
|
40
|
+
```rust
|
|
41
|
+
use ozzyyaml::load_all;
|
|
42
|
+
|
|
43
|
+
let docs = load_all("1\n---\n2\n").unwrap();
|
|
44
|
+
assert_eq!(docs.len(), 2);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Each loader has a `*_with_limits` twin when you need tighter caps than the
|
|
48
|
+
defaults.
|
|
49
|
+
|
|
50
|
+
## Values, aliases, and cycles
|
|
51
|
+
|
|
52
|
+
Sequences and mappings store children behind `Rc` and `RefCell`. An alias is
|
|
53
|
+
an `Rc` clone of the anchored node — the same pointer, not a duplicate tree.
|
|
54
|
+
That is how ozzyyaml avoids classic “billion laughs” blow-ups from aggressive
|
|
55
|
+
expansion, and how cyclic graphs stay honest.
|
|
56
|
+
|
|
57
|
+
Under the **Core** schema, plain scalars become null, bool, int, float, or
|
|
58
|
+
string by the usual Core rules. Quoted scalars stay strings unless an explicit
|
|
59
|
+
Core tag says otherwise. Values such as `yes` / `no` / `on` / `off` remain
|
|
60
|
+
strings (they are not booleans in Core).
|
|
61
|
+
|
|
62
|
+
## Limits
|
|
63
|
+
|
|
64
|
+
[`Limits`](https://docs.rs/ozzyyaml/latest/ozzyyaml/struct.Limits.html) carries:
|
|
65
|
+
|
|
66
|
+
| Limit | When it bites |
|
|
67
|
+
| --- | --- |
|
|
68
|
+
| `max_anchors` | Compose time — primary DoS brake |
|
|
69
|
+
| `max_nesting_depth` | Parse time |
|
|
70
|
+
| `max_input_bytes` | Read time |
|
|
71
|
+
|
|
72
|
+
## In the wider stack
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
YAML text → ozzyyaml-parser (events) → ozzyyaml (Value) → ozzyyaml-emit (text)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
For a Python façade with the same Core behaviour, see the
|
|
79
|
+
[`ozzyyaml`](https://pypi.org/project/ozzyyaml/) package on PyPI.
|
|
80
|
+
|
|
81
|
+
## Learn more
|
|
82
|
+
|
|
83
|
+
- [Architecture overview](https://github.com/peterkmurphy/ozzyyaml/blob/main/docs/architecture.md)
|
|
84
|
+
- [Repository](https://github.com/peterkmurphy/ozzyyaml)
|
|
85
|
+
- [API docs](https://docs.rs/ozzyyaml)
|