ryaml 0.5.1__cp314-cp314t-win_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,34 @@
1
+ from ._ryaml import InvalidYamlError, loads, loads_all, dumps
2
+
3
+ from typing import IO, AnyStr, Any
4
+ import io
5
+
6
+
7
+ def _read_file(fp: IO[AnyStr]) -> str:
8
+ data = fp.read()
9
+ if isinstance(data, str):
10
+ return data
11
+ elif isinstance(data, bytes):
12
+ return data.decode("utf8")
13
+ else:
14
+ return bytes(data).decode('utf8')
15
+
16
+
17
+ def load(fp: IO[AnyStr]) -> Any:
18
+ if not isinstance(fp, io.IOBase):
19
+ raise TypeError("fp must be a file-like object")
20
+ return loads(_read_file(fp))
21
+
22
+
23
+ def load_all(fp: IO[AnyStr]) -> list[Any]:
24
+ if not isinstance(fp, io.IOBase):
25
+ raise TypeError("fp must be a file-like object")
26
+ return loads_all(_read_file(fp))
27
+
28
+
29
+ def dump(fp: IO[AnyStr], obj: Any) -> None:
30
+ yaml = dumps(obj)
31
+ if isinstance(fp, io.TextIOBase):
32
+ fp.write(yaml) # type: ignore
33
+ else:
34
+ fp.write(yaml.encode('utf8')) # type: ignore
Binary file
ryaml/_ryaml.pyi ADDED
@@ -0,0 +1,8 @@
1
+ # pyright: strict
2
+ from typing import Any
3
+
4
+ class InvalidYamlError(ValueError): ...
5
+
6
+ def loads(s: str) -> Any: ...
7
+ def loads_all(s: str) -> list[Any]: ...
8
+ def dumps(obj: Any) -> str: ...
ryaml/py.typed ADDED
File without changes
@@ -0,0 +1,135 @@
1
+ Metadata-Version: 2.4
2
+ Name: ryaml
3
+ Version: 0.5.1
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* fully compatible with PyYAML, and it has a similar design to the `json` module.
36
+ The hope is this will be used as a safe and fast yaml parser in lieu of PyYAML.
37
+
38
+ Like PyYAML, this library implements the YAML 1.1 specification.
39
+
40
+ ## Installation
41
+
42
+ We ship binary wheels for Windows, Linux, and macOS, so as long as you are using Python 3.10+,
43
+ you can run:
44
+
45
+ ```
46
+ $ python -m pip install ryaml
47
+ ```
48
+
49
+ Otherwise, you will need to build from source. To do so, first install Rust 1.41 stable.
50
+
51
+ Then you should be able to just
52
+
53
+ ```shell
54
+ $ git clone https://github.com/emmatyping/ryaml
55
+ $ cd ryaml
56
+ $ python -m pip install .
57
+ ```
58
+
59
+ Or if you want to build a wheel:
60
+
61
+ ```shell
62
+ $ git clone https://github.com/emmatyping/ryaml
63
+ $ cd ryaml
64
+ $ python -m pip install maturin
65
+ $ maturin build --release --no-sdist
66
+ # OR if you want an abi3 wheel (compatible with Python 3.10+)
67
+ $ maturin build --release --no-sdist --cargo-extra-args="--features=abi3"
68
+ ```
69
+
70
+ And a wheel will be created in `target/wheels` which you can install.
71
+
72
+ ## Usage
73
+
74
+ The API of `ryaml` is very similar to that of `json` in the standard library:
75
+
76
+ You can use `ryaml.loads` to read from a `str`:
77
+
78
+ ```python
79
+ import ryaml
80
+ obj = ryaml.loads('key: [10, "hi"]')
81
+ assert isinstance(obj, dict) # True
82
+ assert obj['key'][1] == "hi" # True
83
+ ```
84
+
85
+ And `ryaml.dumps` to dump an object into a yaml file:
86
+
87
+ ```python
88
+ import ryaml
89
+ s = ryaml.dumps({ 'key' : None })
90
+ print(s)
91
+ # prints:
92
+ # ---
93
+ # key: ~
94
+ ```
95
+
96
+ There are also `ryaml.load` and `ryaml.load_all` to read yaml document(s) from files:
97
+
98
+ ```python
99
+ import ryaml
100
+ obj = {'a': [{'b': 1}]}
101
+ with open('test.yaml', 'w') as w:
102
+ ryaml.dump(w, obj)
103
+ with open('test.yaml', 'r') as r:
104
+ assert ryaml.load(r) == obj
105
+ with open('multidoc.yaml', 'w') as multi:
106
+ multi.write('''
107
+ ---
108
+ a:
109
+ key:
110
+ ...
111
+ ---
112
+ b:
113
+ key:
114
+ ''')
115
+ with open('multidoc.yaml', 'r') as multi:
116
+ docs = ryaml.load_all(multi)
117
+ assert len(docs) == 2
118
+ assert docs[0]['a']['key'] is None
119
+ ```
120
+
121
+ `ryaml.load_all` will, as seen above, load multiple documents from a single file.
122
+
123
+
124
+ ## Thanks
125
+
126
+ This project is standing on the shoulders of giants, and would not be possible without:
127
+
128
+ [pyo3](https://pyo3.rs/)
129
+
130
+ [serde-yaml](https://github.com/dtolnay/serde-yaml)
131
+
132
+ [yaml-rust](https://github.com/chyh1990/yaml-rust)
133
+
134
+ [pythonize](https://github.com/davidhewitt/pythonize)
135
+
@@ -0,0 +1,8 @@
1
+ ryaml\__init__.py,sha256=SoCu5_8xZjcD2tf9Q2N2-sQhpoI7_xslV_4k2EQ8kbQ,922
2
+ ryaml\_ryaml.cp314t-win_arm64.pyd,sha256=YSS2Dp91quMZPGhCdRdJn32r5WZ8Ti60XUuoLZmB_6g,480256
3
+ ryaml\_ryaml.pyi,sha256=zitmJlENhJDrHVqQi3EPA20lwW9m2QTz-UsuayokvQQ,193
4
+ ryaml\py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ ryaml-0.5.1.dist-info\METADATA,sha256=d7BTjgQCKqtyycuYFa5kVvK4fzEm0lclZ9ay59auT48,3652
6
+ ryaml-0.5.1.dist-info\WHEEL,sha256=j6TxrWL6eSoRGgXGBPXV8d7UTQITaoAmQJXUnXY5IaU,98
7
+ ryaml-0.5.1.dist-info\licenses\LICENSE,sha256=WJcwKGmnAx7xHrrgLP8BNnLnkR6spwbigreSGuXkYuw,1058
8
+ ryaml-0.5.1.dist-info\RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.11.5)
3
+ Root-Is-Purelib: false
4
+ Tag: cp314-cp314t-win_arm64
@@ -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.