Skip to content
Simple tool for modifying and searching yaml files while keeping the original file formatting.
Python Shell
Branch: master
Clone or download
tonnydourado and jorisroovers Update pyyaml version (#6)
Python 3.7 support, dependency updates

Also fixed some minor pep8 issues.
Latest commit 804a41f Jul 11, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Initial support for aliases and comments Aug 23, 2016
yamlpal
.gitignore
.travis.yml
CHANGELOG.md 0.1.0 release Apr 14, 2016
LICENSE
README.md Fix markdown links Sep 20, 2017
Vagrantfile
requirements.txt
run_tests.sh
setup.cfg
setup.py
test-requirements.txt Update pyyaml version (#6) Jul 11, 2019

README.md

yamlpal

Build Status PyPi Package Supported Python Versions

Simple tool for modifying and searching yaml files while keeping the original file formatting.

Yamlpal uses its own version of 'yamlpath', a syntax similar to xpath, to identify elements in a yaml file.

Basic usage:

# Installation
pip install yamlpal
# Inserting new content into files (output is printed to stdout by default)
$ yamlpal insert  -f examples/sample1.yml "bill-to/address/city" "newkey: value"
$ yamlpal insert -f examples/sample1.yml "invoice" @examples/insert-multiline.txt

# Specify files via stdin and modify the files directly inline instead of printing to stdout
$ find examples -name \*.yml | yamlpal insert --inline "invoice" "newkey: value"

# Finding content in files
$ yamlpal find  -f examples/sample1.yml "bill-to/address/city"
city: Royal Oak

# Specify a custom output format (run "yamlpal find --help" for details on format strings)
$ yamlpal find -f examples/sample1.yml --format "%{linenr} %{key} %{value}" "bill-to/address/city"
11 city Royal Oak

# Check that value matches a given regex
$ yamlpal check "bill-to/address/city" "Royal Oak" -f examples/sample1.yml

# Run yamlpal <command> --help for command specific help.
$ yamlpal insert --help
Usage: yamlpal insert [OPTIONS] NEEDLE NEWCONTENT

  Insert new content into a yaml file.

Options:
  -f, --file PATH  File to insert new content in. Can by specified multiple
                   times to modify multiple files. Files are not modified
                   inline by default. You can also provide (additional) file
                   paths via stdin.
  -i, --inline     Edit file inline instead of dumping it to std out.
  --help           Show this message and exit.

Wishlist

We maintain a wishlist on our wiki.

You can’t perform that action at this time.