ryaml 0.5.0__cp310-cp310-macosx_11_0_arm64.whl

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.
ryaml/__init__.py ADDED
@@ -0,0 +1 @@
1
+ from ._ryaml import InvalidYamlError, load, load_all, loads, loads_all, dump, dumps
Binary file
ryaml/_ryaml.pyi ADDED
@@ -0,0 +1,13 @@
1
+ # pyright: strict
2
+ from typing import Any, AnyStr, IO
3
+
4
+ class InvalidYamlError(ValueError): ...
5
+
6
+ def load(fp: IO[AnyStr]) -> Any: ...
7
+ def load_all(fp: IO[AnyStr]) -> list[Any]: ...
8
+
9
+ def loads(s: str) -> Any: ...
10
+ def loads_all(s: str) -> list[Any]: ...
11
+
12
+ def dump(fp: IO[AnyStr], obj: Any) -> None: ...
13
+ def dumps(obj: Any) -> str: ...
ryaml/py.typed ADDED
File without changes
@@ -0,0 +1,149 @@
1
+ Metadata-Version: 2.4
2
+ Name: ryaml
3
+ Version: 0.5.0
4
+ Classifier: Programming Language :: Python
5
+ Classifier: Programming Language :: Rust
6
+ Classifier: Programming Language :: Python :: 3.10
7
+ Classifier: Programming Language :: Python :: 3.11
8
+ Classifier: Programming Language :: Python :: 3.12
9
+ Classifier: Programming Language :: Python :: 3.13
10
+ Classifier: Programming Language :: Python :: 3.14
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Operating System :: Microsoft :: Windows
13
+ Classifier: Operating System :: POSIX :: Linux
14
+ Classifier: Operating System :: MacOS
15
+ Classifier: Typing :: Typed
16
+ License-File: LICENSE
17
+ Summary: A simple yaml serializer and deserializer using Rust.
18
+ Keywords: yaml,parsing
19
+ Author-email: Emma Harper Smith <emma@emmatyping.dev>
20
+ License: MIT
21
+ Requires-Python: >=3.10, <4
22
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
23
+ Project-URL: homepage, https://github.com/emmatyping/ryaml
24
+ Project-URL: repository, https://github.com/emmatyping/ryaml
25
+
26
+ ryaml
27
+ =====
28
+
29
+ ### *Quickly and safely parse yaml*
30
+
31
+ ### What is ryaml?
32
+
33
+ ryaml is a Python library that wraps a Rust yaml parser, [serde-yaml](https://github.com/dtolnay/serde-yaml), to quickly and safely parse and dump yaml to and from Python objects.
34
+
35
+ It is *not* compatible with PyYAML, and it has a similar design to the `json` module. Furthermore PyYAML implements version 1.1 of the yaml spec whereas ryaml implements version 1.2 of the spec.
36
+
37
+ Notable differences between version 1.1 and 1.2 are
38
+
39
+ - YAML 1.2 dropped support for several features unquoted `Yes`,
40
+ `No`, `On`, `Off`
41
+ - YAML 1.2 no longer accepts strings that start with a `0` and solely
42
+ consist of number characters as octal, you need to specify such strings with
43
+ `0o[0-7]+` (zero + lower-case o for octal + one or more octal characters).
44
+ - YAML 1.2 no longer supports `sexagesimals
45
+ <https://en.wikipedia.org/wiki/Sexagesimal>`_, so the string scalar
46
+ `12:34:56` doesn't need quoting.
47
+ - `\/` escape for JSON compatibility
48
+ - correct parsing of floating point scalars with exponentials
49
+
50
+ The hope is this will be used as a safe and fast yaml parser in lieu of PyYAML.
51
+
52
+ ## Installation
53
+
54
+ We ship binary wheels for Windows, Linux, and macOS, so as long as you are using Python 3.10+,
55
+ you can run:
56
+
57
+ ```
58
+ $ python -m pip install ryaml
59
+ ```
60
+
61
+ Otherwise, you will need to build from source. To do so, first install Rust 1.41 stable.
62
+
63
+ Then you should be able to just
64
+
65
+ ```shell
66
+ $ git clone https://github.com/emmatyping/ryaml
67
+ $ cd ryaml
68
+ $ python -m pip install .
69
+ ```
70
+
71
+ Or if you want to build a wheel:
72
+
73
+ ```shell
74
+ $ git clone https://github.com/emmatyping/ryaml
75
+ $ cd ryaml
76
+ $ python -m pip install maturin
77
+ $ maturin build --release --no-sdist
78
+ # OR if you want an abi3 wheel (compatible with Python 3.10+)
79
+ $ maturin build --release --no-sdist --cargo-extra-args="--features=abi3"
80
+ ```
81
+
82
+ And a wheel will be created in `target/wheels` which you can install.
83
+
84
+ ## Usage
85
+
86
+ The API of `ryaml` is very similar to that of `json` in the standard library:
87
+
88
+ You can use `ryaml.loads` to read from a `str`:
89
+
90
+ ```python
91
+ import ryaml
92
+ obj = ryaml.loads('key: [10, "hi"]')
93
+ assert isinstance(obj, dict) # True
94
+ assert obj['key'][1] == "hi" # True
95
+ ```
96
+
97
+ And `ryaml.dumps` to dump an object into a yaml file:
98
+
99
+ ```python
100
+ import ryaml
101
+ s = ryaml.dumps({ 'key' : None })
102
+ print(s)
103
+ # prints:
104
+ # ---
105
+ # key: ~
106
+ ```
107
+
108
+ There are also `ryaml.load` and `ryaml.load_all` to read yaml document(s) from files:
109
+
110
+ ```python
111
+ import ryaml
112
+ obj = {'a': [{'b': 1}]}
113
+ with open('test.yaml', 'w') as w:
114
+ ryaml.dump(w, obj)
115
+ with open('test.yaml', 'r') as r:
116
+ assert ryaml.load(r) == obj
117
+ with open('multidoc.yaml', 'w') as multi:
118
+ multi.write('''
119
+ ---
120
+ a:
121
+ key:
122
+ ...
123
+ ---
124
+ b:
125
+ key:
126
+ ''')
127
+ with open('multidoc.yaml', 'r') as multi:
128
+ docs = ryaml.load_all(multi)
129
+ assert len(docs) == 2
130
+ assert docs[0]['a']['key'] is None
131
+ ```
132
+
133
+ `ryaml.load_all` will, as seen above, load multiple documents from a single file.
134
+
135
+
136
+ ## Thanks
137
+
138
+ This project is standing on the shoulders of giants, and would not be possible without:
139
+
140
+ [pyo3](https://pyo3.rs/)
141
+
142
+ [serde-yaml](https://github.com/dtolnay/serde-yaml)
143
+
144
+ [yaml-rust](https://github.com/chyh1990/yaml-rust)
145
+
146
+ [pyo3-file](https://github.com/omerbenamram/pyo3-file)
147
+
148
+ [pythonize](https://github.com/davidhewitt/pythonize)
149
+
@@ -0,0 +1,8 @@
1
+ ryaml/_ryaml.cpython-310-darwin.so,sha256=ZFGDTd4A3icpqBE2D1P1CfnlRh2RRH0IXDhuCM7KtQA,892048
2
+ ryaml/__init__.py,sha256=Fop8SKMTpEwcVrFlf17BzSzplE_nOQsMcJHPMNw4enM,84
3
+ ryaml/_ryaml.pyi,sha256=uhhaBiCq-6Let3BpSOcgJ0COqc-oulbHQ01MAQaxYhM,331
4
+ ryaml/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ ryaml-0.5.0.dist-info/RECORD,,
6
+ ryaml-0.5.0.dist-info/WHEEL,sha256=Sp6ArW1hHb0TD2pIatr9ldysDxi0aO68XlZfkI55pLw,133
7
+ ryaml-0.5.0.dist-info/METADATA,sha256=At4zO-SbpxzeISRQkAq_Bg5u6EAoIAqbkXKuCd7PF14,4249
8
+ ryaml-0.5.0.dist-info/licenses/LICENSE,sha256=52M823F7Jiop4_cMBCNgKDnFRK2oTnahO_3vGYAzX3Y,1051
@@ -0,0 +1,6 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.10.2)
3
+ Root-Is-Purelib: false
4
+ Tag: cp310-cp310-macosx_11_0_arm64
5
+ Generator: delocate 0.13.0
6
+
@@ -0,0 +1,7 @@
1
+ Copyright 2021 Ethan Smith
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.