yamlwav 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.
- yamlwav-0.1.0/LICENSE +21 -0
- yamlwav-0.1.0/PKG-INFO +228 -0
- yamlwav-0.1.0/README.md +201 -0
- yamlwav-0.1.0/pyproject.toml +37 -0
- yamlwav-0.1.0/setup.cfg +4 -0
- yamlwav-0.1.0/tests/test_roundtrip.py +203 -0
- yamlwav-0.1.0/tests/test_yaml_compliance.py +145 -0
- yamlwav-0.1.0/tests/test_yaml_parser.py +377 -0
- yamlwav-0.1.0/yamlwav/__init__.py +7 -0
- yamlwav-0.1.0/yamlwav/__main__.py +51 -0
- yamlwav-0.1.0/yamlwav/config.py +111 -0
- yamlwav-0.1.0/yamlwav/decoder.py +62 -0
- yamlwav-0.1.0/yamlwav/encoder.py +147 -0
- yamlwav-0.1.0/yamlwav/goertzel.py +49 -0
- yamlwav-0.1.0/yamlwav/yaml_parser.py +1660 -0
- yamlwav-0.1.0/yamlwav.egg-info/PKG-INFO +228 -0
- yamlwav-0.1.0/yamlwav.egg-info/SOURCES.txt +19 -0
- yamlwav-0.1.0/yamlwav.egg-info/dependency_links.txt +1 -0
- yamlwav-0.1.0/yamlwav.egg-info/entry_points.txt +2 -0
- yamlwav-0.1.0/yamlwav.egg-info/requires.txt +5 -0
- yamlwav-0.1.0/yamlwav.egg-info/top_level.txt +1 -0
yamlwav-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sarcasm Heavy Industries LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
yamlwav-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: yamlwav
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: YAML config files encoded as playable WAV audio. No external dependencies.
|
|
5
|
+
Author: Sarcasm Heavy Industries LLC
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/CryptoFewka/yamlwav
|
|
8
|
+
Project-URL: Repository, https://github.com/CryptoFewka/yamlwav
|
|
9
|
+
Project-URL: Issues, https://github.com/CryptoFewka/yamlwav/issues
|
|
10
|
+
Keywords: yaml,wav,audio,config,configuration
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pytest; extra == "dev"
|
|
24
|
+
Requires-Dist: ruamel.yaml; extra == "dev"
|
|
25
|
+
Requires-Dist: pyyaml; extra == "dev"
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
|
|
28
|
+

|
|
29
|
+
|
|
30
|
+
# yamlwav - Configuration via .wav? Sounds good to me.
|
|
31
|
+
|
|
32
|
+
[](https://github.com/CryptoFewka/yamlwav/actions/workflows/yaml-compliance.yml)
|
|
33
|
+
|
|
34
|
+
A totally serious, production-ready configuration format that stores your YAML settings as playable WAV audio files.
|
|
35
|
+
|
|
36
|
+
## Why not just parse YAML directly?
|
|
37
|
+
|
|
38
|
+
Good question. Python does not ship with a YAML parser. Reading a `.yaml` file in plain Python requires either `PyYAML` (`pip install pyyaml`) or writing your own parser, both of which have well-documented failure modes:
|
|
39
|
+
|
|
40
|
+
- `PyYAML`'s default `yaml.load()` is a remote code execution vector — [CVE-2017-18342](https://nvd.nist.gov/vuln/detail/CVE-2017-18342) and friends. You have to remember to use `yaml.safe_load()`, and someone on your team eventually won't.
|
|
41
|
+
- `yaml.safe_load()` is safe but still pulls in an external C extension that can break across Python versions, platforms, and Alpine-based Docker images.
|
|
42
|
+
- Writing a hand-rolled YAML parser is a path that ends in tears and a multi-thousand-line state machine that still doesn't handle tabs correctly.
|
|
43
|
+
|
|
44
|
+
yamlwav sidesteps all of this. The `wave` module ships with every Python installation since 2.0. Decoding requires only `wave`, `struct`, and `math` — all stdlib. There is nothing to install, nothing to update, and no CVEs to track.
|
|
45
|
+
|
|
46
|
+
Additional advantages:
|
|
47
|
+
- **Auditable configs** — you can literally hear your settings. Does your production database sound right? Now you'll know.
|
|
48
|
+
- **Immutable by design** — configs encoded in audio are extremely annoying to edit by hand, discouraging unauthorized configuration drift.
|
|
49
|
+
- **Backup-friendly** — already indistinguishable from your music library. Your ops team will never accidentally delete it.
|
|
50
|
+
|
|
51
|
+
## Installation
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pip install yamlwav
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
No dependencies. Pure Python standard library. As it should be.
|
|
58
|
+
|
|
59
|
+
## Quick Start
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from yamlwav import encode, decode, WavConfig
|
|
63
|
+
|
|
64
|
+
# Convert your boring YAML config into rich, listenable audio
|
|
65
|
+
# Output defaults to <yaml_path>.wav — e.g. config.yaml → config.yaml.wav
|
|
66
|
+
encode("config.yaml")
|
|
67
|
+
|
|
68
|
+
# Or specify the output path explicitly
|
|
69
|
+
encode("config.yaml", "config.yaml.wav")
|
|
70
|
+
|
|
71
|
+
# Decode back to a plain dict (raw string values)
|
|
72
|
+
data = decode("config.yaml.wav")
|
|
73
|
+
|
|
74
|
+
# Or use the dict-like interface with automatic type coercion
|
|
75
|
+
cfg = WavConfig("config.yaml.wav")
|
|
76
|
+
print(cfg["port"]) # 8080 (int, not "8080")
|
|
77
|
+
print(cfg["debug"]) # True (bool, not "true")
|
|
78
|
+
|
|
79
|
+
# Nested YAML works too — keys flatten to dot-notation
|
|
80
|
+
print(cfg["db"]["host"]) # "localhost" (nested access)
|
|
81
|
+
print(cfg.to_nested()) # {"db": {"host": "localhost", "port": 5432}, ...}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## How It Works
|
|
85
|
+
|
|
86
|
+
Each YAML key becomes a separate audio channel. Nested keys are flattened to dot-notation (e.g. `db.host`) before encoding. Each character of a key's value is encoded as a pure sine wave tone held for 0.15 seconds:
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
frequency = 200 + (ASCII_code × 25) Hz
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
This maps all 256 byte values to the range 200 Hz – 6575 Hz. The key names are encoded in channel 0 as a null-byte-separated manifest. Decoding uses the [Goertzel algorithm](https://en.wikipedia.org/wiki/Goertzel_algorithm) to detect the dominant frequency in each 0.15-second window and recover the original character.
|
|
93
|
+
|
|
94
|
+
The resulting WAV file is 44100 Hz, 16-bit PCM and will play in any audio application, producing what can only be described as a demonic sine choir.
|
|
95
|
+
|
|
96
|
+
## YAML Compliance
|
|
97
|
+
|
|
98
|
+
In the course of eliminating YAML dependencies, we accidentally wrote a complete YAML 1.2 parser. It is 1,660 lines of pure Python, has zero external dependencies, and passes the official YAML test suite at a rate that may surprise you.
|
|
99
|
+
|
|
100
|
+
| Feature | yamlwav | PyYAML | ruamel.yaml |
|
|
101
|
+
|---|---|---|---|
|
|
102
|
+
| YAML spec version | 1.2 | 1.1 | 1.2 |
|
|
103
|
+
| Official test-suite pass rate | 231/231 (100%) | ~60% | ~99% |
|
|
104
|
+
| External dependencies | 0 | libyaml (C) | yes |
|
|
105
|
+
| Known RCE CVEs | 0 | CVE-2017-18342 | 0 |
|
|
106
|
+
| Also plays audio | yes | no | no |
|
|
107
|
+
|
|
108
|
+
The parser supports anchors and aliases, tags, multi-document streams, flow collections, block scalars (literal and folded with all chomping modes), single- and double-quoted strings with full escape sequences, YAML 1.2 Core Schema type resolution, Unicode, and directives.
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
from yamlwav.yaml_parser import parse, parse_all
|
|
112
|
+
|
|
113
|
+
doc = parse("port: 8080\ndebug: true") # single document
|
|
114
|
+
docs = parse_all("---\na: 1\n---\nb: 2\n") # multi-document stream
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Supported value types
|
|
118
|
+
|
|
119
|
+
`WavConfig` automatically converts decoded string values:
|
|
120
|
+
|
|
121
|
+
| YAML value | Python type |
|
|
122
|
+
|---|---|
|
|
123
|
+
| `"true"` / `"false"` | `bool` |
|
|
124
|
+
| `"null"` / `"~"` | `None` |
|
|
125
|
+
| `"42"` | `int` |
|
|
126
|
+
| `"3.14"` | `float` |
|
|
127
|
+
| anything else | `str` |
|
|
128
|
+
|
|
129
|
+
## Compression
|
|
130
|
+
|
|
131
|
+
By default yamlwav writes a standard, playable WAV file. To reduce file size, pass
|
|
132
|
+
`compress=True` — the output will be wrapped in a `zipfile.ZIP_DEFLATED` archive, typically
|
|
133
|
+
shrinking the file by ~95% (e.g. 5.3 MB → 271 KB). The extension stays `.yaml.wav` either way;
|
|
134
|
+
decoders auto-detect which format they received.
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
# Default: raw PCM WAV — playable in any audio application
|
|
138
|
+
encode("config.yaml")
|
|
139
|
+
|
|
140
|
+
# Opt in to compression for smaller files
|
|
141
|
+
encode("config.yaml", compress=True)
|
|
142
|
+
encode_dict(data, "config.yaml.wav", compress=True)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Output is deterministic — the same input always produces byte-identical WAV files, compressed or not.
|
|
146
|
+
|
|
147
|
+
## Command-line interface
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# Encode — output defaults to config.yaml.wav
|
|
151
|
+
yamlwav encode config.yaml
|
|
152
|
+
|
|
153
|
+
# Encode with compression
|
|
154
|
+
yamlwav encode config.yaml --compress
|
|
155
|
+
|
|
156
|
+
# Specify output path explicitly
|
|
157
|
+
yamlwav encode config.yaml output.yaml.wav
|
|
158
|
+
|
|
159
|
+
# Decode back to key: value pairs
|
|
160
|
+
yamlwav decode config.yaml.wav
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## API
|
|
164
|
+
|
|
165
|
+
```python
|
|
166
|
+
encode(yaml_path, wav_path=None, compress=False) # YAML file → WAV file (default output: <yaml_path>.wav)
|
|
167
|
+
encode_dict(data_dict, wav_path, compress=False) # dict → WAV file (nested dicts auto-flattened)
|
|
168
|
+
decode(wav_path) -> dict # WAV → dict[str, str] (auto-detects compression)
|
|
169
|
+
WavConfig(wav_path) # WAV → dict-like object with type coercion
|
|
170
|
+
WavConfig["section"]["key"] # nested access via dot-notation keys
|
|
171
|
+
WavConfig.to_nested() -> dict # reconstruct full nested dict
|
|
172
|
+
|
|
173
|
+
# Standalone YAML 1.2 parser (no WAV involved)
|
|
174
|
+
from yamlwav.yaml_parser import parse, parse_all
|
|
175
|
+
parse(text) -> object # parse a single YAML 1.2 document
|
|
176
|
+
parse_all(text) -> list # parse all documents in a YAML stream
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Decoding without installing yamlwav
|
|
180
|
+
|
|
181
|
+
The encoder requires `pip install yamlwav`, but decoding needs only the Python standard library. A copy-pasteable standalone decoder is provided in [`standalone_decoder.py`](standalone_decoder.py) at the project root.
|
|
182
|
+
|
|
183
|
+
Copy the `decode_yamlwav` function into your own Python file — no package installation required on the consuming end:
|
|
184
|
+
|
|
185
|
+
```python
|
|
186
|
+
# paste decode_yamlwav() from standalone_decoder.py here
|
|
187
|
+
|
|
188
|
+
config = decode_yamlwav("config.wav")
|
|
189
|
+
print(config["port"]) # "8080" (str — all values are strings)
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
The function is self-contained: it imports `wave`, `struct`, and `math` from inside its own body so it doesn't pollute your module's namespace. All helpers are nested within it.
|
|
193
|
+
|
|
194
|
+
If you want automatic type coercion on the reading side, add the `WavConfig` class from `yamlwav/config.py` — it is also pure stdlib and equally safe to paste.
|
|
195
|
+
|
|
196
|
+
## Security
|
|
197
|
+
|
|
198
|
+
**Do not store secrets (API keys, passwords, tokens) in yamlwav files.** WAV files are not encrypted. Anyone with access to the file can decode it by running `yamlwav.decode()`. The "security by obscurity" joke is a joke; actual credentials belong in a proper secrets manager (Vault, AWS Secrets Manager, environment variables, etc.).
|
|
199
|
+
|
|
200
|
+
yamlwav is designed for non-sensitive runtime configuration: hostnames, ports, feature flags, log levels — settings that are boring to look at whether they're in YAML or in audio.
|
|
201
|
+
|
|
202
|
+
## Limitations
|
|
203
|
+
|
|
204
|
+
- Nested YAML is supported but flattened internally to dot-notation keys. Deep nesting remains a sign of moral weakness.
|
|
205
|
+
- Decoding is O(N × 256) per character window and is implemented in pure Python. Performance scales linearly with the amount of config you have, which is a feature because it discourages large configs.
|
|
206
|
+
- WAV files for typical configs are several megabytes. Pass `compress=True` to reduce this substantially, at the cost of the file no longer being directly playable as audio.
|
|
207
|
+
|
|
208
|
+
## FAQ
|
|
209
|
+
|
|
210
|
+
- **Should I use this in production?**
|
|
211
|
+
|
|
212
|
+
- We cannot think of a reason why not.
|
|
213
|
+
|
|
214
|
+
- **My coworkers are upset that the CI pipeline now plays audio.**
|
|
215
|
+
|
|
216
|
+
- Progress is often uncomfortable.
|
|
217
|
+
|
|
218
|
+
- **Q: Is this HIPAA compliant?**
|
|
219
|
+
|
|
220
|
+
- No. Please do not store protected health information — or any sensitive data — in WAV files.
|
|
221
|
+
|
|
222
|
+
- **Q: What happens if I play the WAV at a team meeting?**
|
|
223
|
+
|
|
224
|
+
- Your team will hear the settings. This is the intended behavior.
|
|
225
|
+
|
|
226
|
+
## License
|
|
227
|
+
|
|
228
|
+
MIT
|
yamlwav-0.1.0/README.md
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
# yamlwav - Configuration via .wav? Sounds good to me.
|
|
4
|
+
|
|
5
|
+
[](https://github.com/CryptoFewka/yamlwav/actions/workflows/yaml-compliance.yml)
|
|
6
|
+
|
|
7
|
+
A totally serious, production-ready configuration format that stores your YAML settings as playable WAV audio files.
|
|
8
|
+
|
|
9
|
+
## Why not just parse YAML directly?
|
|
10
|
+
|
|
11
|
+
Good question. Python does not ship with a YAML parser. Reading a `.yaml` file in plain Python requires either `PyYAML` (`pip install pyyaml`) or writing your own parser, both of which have well-documented failure modes:
|
|
12
|
+
|
|
13
|
+
- `PyYAML`'s default `yaml.load()` is a remote code execution vector — [CVE-2017-18342](https://nvd.nist.gov/vuln/detail/CVE-2017-18342) and friends. You have to remember to use `yaml.safe_load()`, and someone on your team eventually won't.
|
|
14
|
+
- `yaml.safe_load()` is safe but still pulls in an external C extension that can break across Python versions, platforms, and Alpine-based Docker images.
|
|
15
|
+
- Writing a hand-rolled YAML parser is a path that ends in tears and a multi-thousand-line state machine that still doesn't handle tabs correctly.
|
|
16
|
+
|
|
17
|
+
yamlwav sidesteps all of this. The `wave` module ships with every Python installation since 2.0. Decoding requires only `wave`, `struct`, and `math` — all stdlib. There is nothing to install, nothing to update, and no CVEs to track.
|
|
18
|
+
|
|
19
|
+
Additional advantages:
|
|
20
|
+
- **Auditable configs** — you can literally hear your settings. Does your production database sound right? Now you'll know.
|
|
21
|
+
- **Immutable by design** — configs encoded in audio are extremely annoying to edit by hand, discouraging unauthorized configuration drift.
|
|
22
|
+
- **Backup-friendly** — already indistinguishable from your music library. Your ops team will never accidentally delete it.
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install yamlwav
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
No dependencies. Pure Python standard library. As it should be.
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from yamlwav import encode, decode, WavConfig
|
|
36
|
+
|
|
37
|
+
# Convert your boring YAML config into rich, listenable audio
|
|
38
|
+
# Output defaults to <yaml_path>.wav — e.g. config.yaml → config.yaml.wav
|
|
39
|
+
encode("config.yaml")
|
|
40
|
+
|
|
41
|
+
# Or specify the output path explicitly
|
|
42
|
+
encode("config.yaml", "config.yaml.wav")
|
|
43
|
+
|
|
44
|
+
# Decode back to a plain dict (raw string values)
|
|
45
|
+
data = decode("config.yaml.wav")
|
|
46
|
+
|
|
47
|
+
# Or use the dict-like interface with automatic type coercion
|
|
48
|
+
cfg = WavConfig("config.yaml.wav")
|
|
49
|
+
print(cfg["port"]) # 8080 (int, not "8080")
|
|
50
|
+
print(cfg["debug"]) # True (bool, not "true")
|
|
51
|
+
|
|
52
|
+
# Nested YAML works too — keys flatten to dot-notation
|
|
53
|
+
print(cfg["db"]["host"]) # "localhost" (nested access)
|
|
54
|
+
print(cfg.to_nested()) # {"db": {"host": "localhost", "port": 5432}, ...}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## How It Works
|
|
58
|
+
|
|
59
|
+
Each YAML key becomes a separate audio channel. Nested keys are flattened to dot-notation (e.g. `db.host`) before encoding. Each character of a key's value is encoded as a pure sine wave tone held for 0.15 seconds:
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
frequency = 200 + (ASCII_code × 25) Hz
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
This maps all 256 byte values to the range 200 Hz – 6575 Hz. The key names are encoded in channel 0 as a null-byte-separated manifest. Decoding uses the [Goertzel algorithm](https://en.wikipedia.org/wiki/Goertzel_algorithm) to detect the dominant frequency in each 0.15-second window and recover the original character.
|
|
66
|
+
|
|
67
|
+
The resulting WAV file is 44100 Hz, 16-bit PCM and will play in any audio application, producing what can only be described as a demonic sine choir.
|
|
68
|
+
|
|
69
|
+
## YAML Compliance
|
|
70
|
+
|
|
71
|
+
In the course of eliminating YAML dependencies, we accidentally wrote a complete YAML 1.2 parser. It is 1,660 lines of pure Python, has zero external dependencies, and passes the official YAML test suite at a rate that may surprise you.
|
|
72
|
+
|
|
73
|
+
| Feature | yamlwav | PyYAML | ruamel.yaml |
|
|
74
|
+
|---|---|---|---|
|
|
75
|
+
| YAML spec version | 1.2 | 1.1 | 1.2 |
|
|
76
|
+
| Official test-suite pass rate | 231/231 (100%) | ~60% | ~99% |
|
|
77
|
+
| External dependencies | 0 | libyaml (C) | yes |
|
|
78
|
+
| Known RCE CVEs | 0 | CVE-2017-18342 | 0 |
|
|
79
|
+
| Also plays audio | yes | no | no |
|
|
80
|
+
|
|
81
|
+
The parser supports anchors and aliases, tags, multi-document streams, flow collections, block scalars (literal and folded with all chomping modes), single- and double-quoted strings with full escape sequences, YAML 1.2 Core Schema type resolution, Unicode, and directives.
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from yamlwav.yaml_parser import parse, parse_all
|
|
85
|
+
|
|
86
|
+
doc = parse("port: 8080\ndebug: true") # single document
|
|
87
|
+
docs = parse_all("---\na: 1\n---\nb: 2\n") # multi-document stream
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Supported value types
|
|
91
|
+
|
|
92
|
+
`WavConfig` automatically converts decoded string values:
|
|
93
|
+
|
|
94
|
+
| YAML value | Python type |
|
|
95
|
+
|---|---|
|
|
96
|
+
| `"true"` / `"false"` | `bool` |
|
|
97
|
+
| `"null"` / `"~"` | `None` |
|
|
98
|
+
| `"42"` | `int` |
|
|
99
|
+
| `"3.14"` | `float` |
|
|
100
|
+
| anything else | `str` |
|
|
101
|
+
|
|
102
|
+
## Compression
|
|
103
|
+
|
|
104
|
+
By default yamlwav writes a standard, playable WAV file. To reduce file size, pass
|
|
105
|
+
`compress=True` — the output will be wrapped in a `zipfile.ZIP_DEFLATED` archive, typically
|
|
106
|
+
shrinking the file by ~95% (e.g. 5.3 MB → 271 KB). The extension stays `.yaml.wav` either way;
|
|
107
|
+
decoders auto-detect which format they received.
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
# Default: raw PCM WAV — playable in any audio application
|
|
111
|
+
encode("config.yaml")
|
|
112
|
+
|
|
113
|
+
# Opt in to compression for smaller files
|
|
114
|
+
encode("config.yaml", compress=True)
|
|
115
|
+
encode_dict(data, "config.yaml.wav", compress=True)
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Output is deterministic — the same input always produces byte-identical WAV files, compressed or not.
|
|
119
|
+
|
|
120
|
+
## Command-line interface
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
# Encode — output defaults to config.yaml.wav
|
|
124
|
+
yamlwav encode config.yaml
|
|
125
|
+
|
|
126
|
+
# Encode with compression
|
|
127
|
+
yamlwav encode config.yaml --compress
|
|
128
|
+
|
|
129
|
+
# Specify output path explicitly
|
|
130
|
+
yamlwav encode config.yaml output.yaml.wav
|
|
131
|
+
|
|
132
|
+
# Decode back to key: value pairs
|
|
133
|
+
yamlwav decode config.yaml.wav
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## API
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
encode(yaml_path, wav_path=None, compress=False) # YAML file → WAV file (default output: <yaml_path>.wav)
|
|
140
|
+
encode_dict(data_dict, wav_path, compress=False) # dict → WAV file (nested dicts auto-flattened)
|
|
141
|
+
decode(wav_path) -> dict # WAV → dict[str, str] (auto-detects compression)
|
|
142
|
+
WavConfig(wav_path) # WAV → dict-like object with type coercion
|
|
143
|
+
WavConfig["section"]["key"] # nested access via dot-notation keys
|
|
144
|
+
WavConfig.to_nested() -> dict # reconstruct full nested dict
|
|
145
|
+
|
|
146
|
+
# Standalone YAML 1.2 parser (no WAV involved)
|
|
147
|
+
from yamlwav.yaml_parser import parse, parse_all
|
|
148
|
+
parse(text) -> object # parse a single YAML 1.2 document
|
|
149
|
+
parse_all(text) -> list # parse all documents in a YAML stream
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Decoding without installing yamlwav
|
|
153
|
+
|
|
154
|
+
The encoder requires `pip install yamlwav`, but decoding needs only the Python standard library. A copy-pasteable standalone decoder is provided in [`standalone_decoder.py`](standalone_decoder.py) at the project root.
|
|
155
|
+
|
|
156
|
+
Copy the `decode_yamlwav` function into your own Python file — no package installation required on the consuming end:
|
|
157
|
+
|
|
158
|
+
```python
|
|
159
|
+
# paste decode_yamlwav() from standalone_decoder.py here
|
|
160
|
+
|
|
161
|
+
config = decode_yamlwav("config.wav")
|
|
162
|
+
print(config["port"]) # "8080" (str — all values are strings)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
The function is self-contained: it imports `wave`, `struct`, and `math` from inside its own body so it doesn't pollute your module's namespace. All helpers are nested within it.
|
|
166
|
+
|
|
167
|
+
If you want automatic type coercion on the reading side, add the `WavConfig` class from `yamlwav/config.py` — it is also pure stdlib and equally safe to paste.
|
|
168
|
+
|
|
169
|
+
## Security
|
|
170
|
+
|
|
171
|
+
**Do not store secrets (API keys, passwords, tokens) in yamlwav files.** WAV files are not encrypted. Anyone with access to the file can decode it by running `yamlwav.decode()`. The "security by obscurity" joke is a joke; actual credentials belong in a proper secrets manager (Vault, AWS Secrets Manager, environment variables, etc.).
|
|
172
|
+
|
|
173
|
+
yamlwav is designed for non-sensitive runtime configuration: hostnames, ports, feature flags, log levels — settings that are boring to look at whether they're in YAML or in audio.
|
|
174
|
+
|
|
175
|
+
## Limitations
|
|
176
|
+
|
|
177
|
+
- Nested YAML is supported but flattened internally to dot-notation keys. Deep nesting remains a sign of moral weakness.
|
|
178
|
+
- Decoding is O(N × 256) per character window and is implemented in pure Python. Performance scales linearly with the amount of config you have, which is a feature because it discourages large configs.
|
|
179
|
+
- WAV files for typical configs are several megabytes. Pass `compress=True` to reduce this substantially, at the cost of the file no longer being directly playable as audio.
|
|
180
|
+
|
|
181
|
+
## FAQ
|
|
182
|
+
|
|
183
|
+
- **Should I use this in production?**
|
|
184
|
+
|
|
185
|
+
- We cannot think of a reason why not.
|
|
186
|
+
|
|
187
|
+
- **My coworkers are upset that the CI pipeline now plays audio.**
|
|
188
|
+
|
|
189
|
+
- Progress is often uncomfortable.
|
|
190
|
+
|
|
191
|
+
- **Q: Is this HIPAA compliant?**
|
|
192
|
+
|
|
193
|
+
- No. Please do not store protected health information — or any sensitive data — in WAV files.
|
|
194
|
+
|
|
195
|
+
- **Q: What happens if I play the WAV at a team meeting?**
|
|
196
|
+
|
|
197
|
+
- Your team will hear the settings. This is the intended behavior.
|
|
198
|
+
|
|
199
|
+
## License
|
|
200
|
+
|
|
201
|
+
MIT
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "yamlwav"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "YAML config files encoded as playable WAV audio. No external dependencies."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Sarcasm Heavy Industries LLC"},
|
|
14
|
+
]
|
|
15
|
+
keywords = ["yaml", "wav", "audio", "config", "configuration"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.9",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Topic :: Software Development :: Libraries",
|
|
25
|
+
]
|
|
26
|
+
dependencies = []
|
|
27
|
+
|
|
28
|
+
[project.urls]
|
|
29
|
+
Homepage = "https://github.com/CryptoFewka/yamlwav"
|
|
30
|
+
Repository = "https://github.com/CryptoFewka/yamlwav"
|
|
31
|
+
Issues = "https://github.com/CryptoFewka/yamlwav/issues"
|
|
32
|
+
|
|
33
|
+
[project.scripts]
|
|
34
|
+
yamlwav = "yamlwav.__main__:main"
|
|
35
|
+
|
|
36
|
+
[project.optional-dependencies]
|
|
37
|
+
dev = ["pytest", "ruamel.yaml", "pyyaml"]
|
yamlwav-0.1.0/setup.cfg
ADDED