Skip to main content

print-yaml

print-yaml is a CLI tool that prints yaml files according to the desired depth.

Installation

# using pip
$ pip install print_yaml

# using poetry
$ poetry add print_yaml

Usage

Let's say you have the following yaml file.

# data.yaml

a:
  b: 1
  c:
    - one
    - two
    - three:
        A: 6
        B: 7
    - four:
        - 8
        - 9
  d:
    e: 3
    f: 4
g: 5

Basic

The following values can be obtained using print_yaml

$ print_yaml tests/data.yaml -d 1

a: 
g: 
$ print_yaml tests/data.yaml -d 2

a:
  b: 
  c: 
  d: 
g: 5
$ print_yaml tests/data.yaml -d 3

a:
  b: 1
  c:
  - one
  - two
  - three: 
  - four: 
  d:
    e: 
    f: 
g: 5

With value

By default, only the "key" in the yaml file is output.
If you add the '--value' or '-v' option, it also outputs a single value.

$ print_yaml tests/data.yaml -d 1 -v

a: 
g: 5
$ print_yaml tests/data.yaml -d 2 -v
a:
  b: 1
  c: 
  d: 
g: 5
$ print_yaml tests/data.yaml -d 3 -v
a:
  b: 1
  c:
  - one
  - two
  - three: 
  - four: 
  d:
    e: 3
    f: 4
g: 5

All Commands

$ print_yaml --help
                                                                                                             
 Usage: print_yaml [OPTIONS] FILE_PATH                                                                       
                                                                                                             
╭─ Arguments ───────────────────────────────────────────────────────────────────────────────────────────────╮
│ *    file_path      TEXT  [default: None] [required]                                                      │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Options ─────────────────────────────────────────────────────────────────────────────────────────────────╮
│                       -d      INTEGER RANGE [x>=0]  [default: 0]                                          │
│ --value               -v                                                                                  │
│ --install-completion                                Install completion for the current shell.             │
│ --show-completion                                   Show completion for the current shell, to copy it or  │
│                                                     customize the installation.                           │
│ --help                                              Show this message and exit.                           │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Metadata

Release files for print-yaml 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for print-yaml 0.1.0
File Size Uploaded Provenance Actions
print-yaml-0.1.0.tar.gz 2.7 kB Without provenance Details for print-yaml-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for print-yaml 0.1.0
File Interpreter ABI Platform Actions
print_yaml-0.1.0-py3-none-any.whl Python 3 none any Details for print_yaml-0.1.0-py3-none-any.whl

Total release size: 5.5 kB

Security for print-yaml 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page