Registry / devops / shyaml

shyaml

JSON →
library0.6.2pypypi✓ verified 22d ago

The original `shyaml` Python library (v0.6.2) is a command-line tool designed for reading and querying YAML files. It enables shell scripts to easily access YAML data using simple dot-notation paths. While it remains available on PyPI, this Python version is in a low-maintenance state with no new features planned. Active development has transitioned to `shyaml-rs`, a Rust rewrite that offers significant performance improvements and additional features like write capabilities, while maintaining command-line interface compatibility.

pip install shyaml
INSTALL
IMPORT
SIG · SHYAML
S
shyaml
devopspythonv0.6.2
Install
1.7s avg
Import
139ms
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.6.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.140s · 20MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.7s · import 0.138s · 21MB
18MB installed
● package 18MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

shyaml.do
import shyaml # ... then call shyaml.do(stdin_stream, args)
The Python `shyaml` library is primarily intended as a command-line tool. While a Python API exists via `shyaml.do()`, its typical usage involves piping YAML data from standard input to the `shyaml` executable rather than direct Python imports for general-purpose YAML manipulation.

The primary use of `shyaml` is via the command line to extract values from YAML. It reads YAML from standard input and outputs the requested value to standard output. Paths are specified using dot notation.

cat <<EOF > config.yaml database: host: localhost port: 5432 credentials: username: admin password: ${DB_PASSWORD:-fallback_pass} EOF DB_PASSWORD="secure_pass" \ cat config.yaml | shyaml get-value database.credentials.password
shyaml --version
Debug
Known issues
gotchaThe Python `shyaml` library is in maintenance mode. `shyaml-rs`, a Rust rewrite, is the actively developed and recommended replacement. `shyaml-rs` is designed as a drop-in CLI replacement, offering 14-42x faster performance and new write capabilities (e.g., `set-value`, `del`, `apply`) not present in the Python version.
fix
Consider migrating to `shyaml-rs` for performance and new features. If you rely solely on CLI parsing, `shyaml-rs` should work seamlessly: `cargo install shyaml-rs` (if Rust is installed) or download a pre-built binary.
affects: All versions of Python shyaml
breakingHandling of missing paths changed significantly in version 0.3. Prior to 0.3, if a specified key was not found, `shyaml` would return an empty string by default. From version 0.3 onwards (inclusive), if a key is not found and no default value is explicitly provided as the third argument, `shyaml` will print an error message and exit.
fix
Always provide a default value as the third argument to `shyaml get-value` if the key might be missing and you don't want an error: `cat file.yaml | shyaml get-value some.path 'my_default_value'`
affects: < 0.3 vs. >= 0.3
breakingOrdered mappings behavior changed in version 0.4.0. Before 0.4.0, `shyaml` would alphabetically re-order keys in mappings. While YAML specification considers mappings unordered, this behavior could be unexpected for users. From version 0.4.0 onwards, `shyaml` preserves the order of keys in mappings.
fix
Ensure your scripts do not rely on a specific (or alphabetically sorted) order of keys if using older versions, or upgrade to 0.4.0+ if order preservation is critical. The current version (0.6.2) preserves order.
affects: < 0.4.0 vs. >= 0.4.0
gotchaBy default, `shyaml` outputs simple string or number values directly without YAML quotes for convenience. This means the output is not strictly valid YAML in all cases. If you need strict YAML output (e.g., for piping to another YAML processor), you must use the `--yaml` or `-y` option.
fix
Use `shyaml --yaml get-value ...` or `shyaml -y get-value ...` to ensure strict YAML output for all values.
affects: All versions
Errors
Common errors & fixes
shyaml: command not found
The `shyaml` command-line executable is not located in your system's PATH, typically due to an incomplete installation or the Python scripts directory not being added to PATH.
fix
Ensure `shyaml` is installed by running `pip install shyaml`. Verify your system's PATH environment variable includes the directory where pip installs scripts (e.g., `~/.local/bin` on Linux or `Scripts` in your Python installation directory).
shyaml: ERROR: Cannot find file "config.yaml"
The specified YAML file, `config.yaml`, does not exist at the given path, or `shyaml` does not have the necessary permissions to access it.
fix
Double-check the filename and its full or relative path. Confirm that `config.yaml` exists and that `shyaml` has read permissions for the file and its parent directories.
shyaml: ERROR: Cannot parse YAML file "data.yaml"
The YAML file, `data.yaml`, contains syntax errors (e.g., incorrect indentation, missing colons, or invalid structure) that prevent `shyaml` (which uses PyYAML) from parsing it successfully.
fix
Review `data.yaml` for any syntax issues. Use a YAML linter or validator to pinpoint and correct errors in the file's structure.
ModuleNotFoundError: No module named 'shyaml'
The `shyaml` Python package is not installed in the currently active Python environment, or the Python interpreter is unable to locate it.
fix
Install the package by running `pip install shyaml` in your terminal. If you are using multiple Python environments, ensure the correct one is activated.
Upgrade
Version history
0.6.2latest on PyPI · released Dec 15, 2020
Audit
Dependencies
PyYAMLrequiredUsed for YAML parsing in the Python version.
Agent activity
10 hits · last 30 days
node
8
Resources
shyaml — pip install shyaml · libregistry