yaml-rs 0.0.1__cp311-cp311-musllinux_1_2_i686.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.
Potentially problematic release.
This version of yaml-rs might be problematic. Click here for more details.
- yaml_rs/__init__.py +42 -0
- yaml_rs/__init__.pyi +8 -0
- yaml_rs/_yaml_rs.cpython-311-i386-linux-musl.so +0 -0
- yaml_rs/py.typed +0 -0
- yaml_rs-0.0.1.dist-info/METADATA +140 -0
- yaml_rs-0.0.1.dist-info/RECORD +9 -0
- yaml_rs-0.0.1.dist-info/WHEEL +4 -0
- yaml_rs-0.0.1.dist-info/licenses/UNLICENSE +24 -0
- yaml_rs.libs/libgcc_s-27e5a392.so.1 +0 -0
yaml_rs/__init__.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
__all__ = (
|
|
2
|
+
"YAMLDecodeError",
|
|
3
|
+
"__version__",
|
|
4
|
+
"load",
|
|
5
|
+
"loads",
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
from typing import Any, BinaryIO
|
|
9
|
+
|
|
10
|
+
from ._yaml_rs import (
|
|
11
|
+
YAMLDecodeError,
|
|
12
|
+
_loads,
|
|
13
|
+
_version,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
__version__: str = _version
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def load(
|
|
20
|
+
fp: BinaryIO,
|
|
21
|
+
/,
|
|
22
|
+
*,
|
|
23
|
+
parse_datetime: bool = True,
|
|
24
|
+
) -> dict[str, Any] | list[dict[str, Any]]:
|
|
25
|
+
_bytes = fp.read()
|
|
26
|
+
try:
|
|
27
|
+
_str = _bytes.decode()
|
|
28
|
+
except AttributeError:
|
|
29
|
+
msg = "File must be opened in binary mode, e.g. use `open('config.yaml', 'rb')`"
|
|
30
|
+
raise TypeError(msg) from None
|
|
31
|
+
return loads(_str, parse_datetime=parse_datetime)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def loads(
|
|
35
|
+
s: str,
|
|
36
|
+
/,
|
|
37
|
+
*,
|
|
38
|
+
parse_datetime: bool = True,
|
|
39
|
+
) -> dict[str, Any] | list[dict[str, Any]]:
|
|
40
|
+
if not isinstance(s, str):
|
|
41
|
+
raise TypeError(f"Expected str object, not '{type(s).__name__}'")
|
|
42
|
+
return _loads(s, parse_datetime=parse_datetime)
|
yaml_rs/__init__.pyi
ADDED
|
Binary file
|
yaml_rs/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: yaml-rs
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Classifier: Typing :: Typed
|
|
5
|
+
Classifier: Programming Language :: Rust
|
|
6
|
+
Classifier: Programming Language :: Python
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
13
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
14
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
15
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
16
|
+
Classifier: License :: OSI Approved :: The Unlicense (Unlicense)
|
|
17
|
+
License-File: UNLICENSE
|
|
18
|
+
Summary: A High-Performance YAML Parser for Python written in Rust
|
|
19
|
+
Author-email: chirizxc <chirizxc@proton.me>
|
|
20
|
+
Maintainer-email: chirizxc <chirizxc@proton.me>
|
|
21
|
+
License-Expression: UNLICENSE
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
24
|
+
Project-URL: Source, https://github.com/lava-sh/yaml-rs
|
|
25
|
+
Project-URL: Homepage, https://github.com/lava-sh/yaml-rs
|
|
26
|
+
Project-URL: Bug Tracker, https://github.com/lava-sh/yaml-rs/issues
|
|
27
|
+
|
|
28
|
+
<div align="center">
|
|
29
|
+
|
|
30
|
+
# yaml-rs
|
|
31
|
+
|
|
32
|
+
*A High-Performance YAML parser for Python written in Rust*
|
|
33
|
+
|
|
34
|
+
[](https://pypi.org/project/yaml_rs/)
|
|
35
|
+
[](https://pypi.org/project/yaml_rs/)
|
|
36
|
+
[](https://pypi.org/project/yaml_rs/)
|
|
37
|
+
|
|
38
|
+
[](https://pypi.org/project/yaml_rs/)
|
|
39
|
+
[](https://github.com/lava-sh/yaml-rs)
|
|
40
|
+
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
## Features
|
|
44
|
+
|
|
45
|
+
* The fastest YAML parser in Python (see [benchmarks](https://github.com/lava-sh/yaml-rs/tree/main/benchmark))
|
|
46
|
+
* Full YAML v1.2 spec support
|
|
47
|
+
|
|
48
|
+
## Installation
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Using pip
|
|
52
|
+
pip install yaml-rs
|
|
53
|
+
|
|
54
|
+
# Using uv
|
|
55
|
+
uv pip install yaml-rs
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Examples
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from pprint import pprint
|
|
62
|
+
|
|
63
|
+
import yaml_rs
|
|
64
|
+
|
|
65
|
+
yaml = """\
|
|
66
|
+
app:
|
|
67
|
+
name: service
|
|
68
|
+
environment: production
|
|
69
|
+
debug: false
|
|
70
|
+
version: 1.3.5
|
|
71
|
+
|
|
72
|
+
log:
|
|
73
|
+
level: INFO
|
|
74
|
+
file: /var/log/service/app.log
|
|
75
|
+
rotation:
|
|
76
|
+
enabled: true
|
|
77
|
+
max_size_mb: 50
|
|
78
|
+
|
|
79
|
+
database:
|
|
80
|
+
engine: mariadb
|
|
81
|
+
host: localhost
|
|
82
|
+
port: 3306
|
|
83
|
+
username: app_user
|
|
84
|
+
password: super_secret_password
|
|
85
|
+
pool_size: 10
|
|
86
|
+
timeout_seconds: 30
|
|
87
|
+
|
|
88
|
+
metadata:
|
|
89
|
+
author: "John Doe"
|
|
90
|
+
created_at: 2024-01-15T12:00:00Z
|
|
91
|
+
updated_at: 2025-11-09T10:30:00Z
|
|
92
|
+
"""
|
|
93
|
+
pprint(yaml_rs.loads(yaml))
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Why not [pyyaml](https://pypi.org/project/PyYAML), [ruamel.yaml](https://pypi.org/project/ruamel.yaml), [strictyaml](https://pypi.org/project/strictyaml)?
|
|
97
|
+
|
|
98
|
+
`PyYAML` and `ruamel.yaml` сan't parse example 2.23, 2.24, 2.27, 2.28, etc. from [YAML spec](https://yaml.org/spec/1.2.2)
|
|
99
|
+
and also do not pass all tests from [yaml-test-suite](https://github.com/yaml/yaml-test-suite).
|
|
100
|
+
|
|
101
|
+
`strictyaml` use `ruamel.yaml` as parser so all the bugs are repeated too.
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
import yaml as pyyaml
|
|
105
|
+
|
|
106
|
+
example_2_23 = """\
|
|
107
|
+
---
|
|
108
|
+
not-date: !!str 2002-04-28
|
|
109
|
+
|
|
110
|
+
picture: !!binary |
|
|
111
|
+
R0lGODlhDAAMAIQAAP//9/X
|
|
112
|
+
17unp5WZmZgAAAOfn515eXv
|
|
113
|
+
Pz7Y6OjuDg4J+fn5OTk6enp
|
|
114
|
+
56enmleECcgggoBADs=
|
|
115
|
+
|
|
116
|
+
application specific tag: !something |
|
|
117
|
+
The semantics of the tag
|
|
118
|
+
above may be different for
|
|
119
|
+
different documents.
|
|
120
|
+
"""
|
|
121
|
+
print(pyyaml.safe_load(example_2_23)) # yaml.constructor.ConstructorError
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
import yaml as pyyaml
|
|
127
|
+
from ruamel.yaml import YAML
|
|
128
|
+
|
|
129
|
+
yaml_safe = YAML(typ="safe")
|
|
130
|
+
|
|
131
|
+
yaml = "! 15" # must be str
|
|
132
|
+
|
|
133
|
+
pyyaml_load = pyyaml.safe_load(yaml)
|
|
134
|
+
ruamel_yaml_load = yaml_safe.load(yaml)
|
|
135
|
+
print(pyyaml_load) # 15
|
|
136
|
+
print(type(pyyaml_load)) # <class 'int'>
|
|
137
|
+
print(ruamel_yaml_load) # 15
|
|
138
|
+
print(type(ruamel_yaml_load)) # <class 'int'>
|
|
139
|
+
```
|
|
140
|
+
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
yaml_rs-0.0.1.dist-info/METADATA,sha256=jROuj312Sq50-b9bb4ttS-2RilQi61QvUKsHvQCyeAs,3980
|
|
2
|
+
yaml_rs-0.0.1.dist-info/WHEEL,sha256=v_6bQiZUWW9sEiazF3ivr-KfpVmNrcvmoVRCC4b1Djc,106
|
|
3
|
+
yaml_rs-0.0.1.dist-info/licenses/UNLICENSE,sha256=yiq99pWITHfqS0pbZMp7cy2dnbreTuvBwudsU-njvIM,1210
|
|
4
|
+
yaml_rs.libs/libgcc_s-27e5a392.so.1,sha256=x5sO63liVwXxrjGGP371wB0RyQe1KEnIynYm82T0G0M,449745
|
|
5
|
+
yaml_rs/__init__.py,sha256=dm49QazHAL4u65MwylYQJyyFvyC6OV5hJiPzTAKQUXw,916
|
|
6
|
+
yaml_rs/__init__.pyi,sha256=ozpx000IE-XHzD9z2TtQu4Ru7oBfmHUgIdQrgV3kg2Y,249
|
|
7
|
+
yaml_rs/_yaml_rs.cpython-311-i386-linux-musl.so,sha256=b40bPqBL2wGg-XCDsv7TEE3IyTEhPVtPe140L2MP1Z0,682269
|
|
8
|
+
yaml_rs/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
+
yaml_rs-0.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
This is free and unencumbered software released into the public domain.
|
|
2
|
+
|
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
4
|
+
distribute this software, either in source code form or as a compiled
|
|
5
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
|
6
|
+
means.
|
|
7
|
+
|
|
8
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
|
9
|
+
of this software dedicate any and all copyright interest in the
|
|
10
|
+
software to the public domain. We make this dedication for the benefit
|
|
11
|
+
of the public at large and to the detriment of our heirs and
|
|
12
|
+
successors. We intend this dedication to be an overt act of
|
|
13
|
+
relinquishment in perpetuity of all present and future rights to this
|
|
14
|
+
software under copyright law.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
20
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
21
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
|
|
24
|
+
For more information, please refer to <http://unlicense.org/>
|
|
Binary file
|