Skip to content
/ yq Public

Pure Python implementation of a subset of the features of jq for YAML documents

Notifications You must be signed in to change notification settings

abesto/yq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yq

Pure Python implementation of a subset of the features of jq for YAML documents.

Status: No active development planned, maintenance work only. This repository is superseded by https://github.com/kislyuk/yq in PyPI, starting with version 2.0.0.

If you're looking for a way to do jq-like filtering on YAML documents, you'll probably be better off using the yq provided by y2j or kislyuk/yq. They provides a wrapper around jq that transforms the input YAML into JSON, calls out to jq, then transforms the result back. This means it automatically supports the full feature set of jq.

If for some reason you need a pure python implementation, this repo is for you.

Setup

pip install 'yq < 2.0.0'

What's implemented?

Everything from the Basic Filters section of the jq manual is supported - at least yq acts the same way as jq in the examples there. Object construction also more or less works.

Known limitations

The parsing technology used in this project (parser combinators) is not powerful enough to support parsing some of the more complex features of jq.

Hacking

virtualenv virtualenv
. virtualenv/bin/activate
pip install -r requirements.txt

# Optionally install as a package:
pip install .

There are basic unit-tests for some of the operators, but the meat of the test suite are the functional tests defined in functional_tests/*.yml files and run by run_functional_tests.py.

The whole test suite of jq is in functional_tests/jq.txt, run by run_jq_tests.py. Sections starting with a line containing skip are, surprisingly, skipped - until that functionality is implemented.

They're all started by nosetests

Roadmap

Here are some steps that'd need to be taken to bring the feature set of this yq closer to that of jq.

  • Work the same way as jq for the "Types and Values" section
  • Operators, functions
  • Check if operators can be refactored
  • Package, release
  • Conditionals, comparisons
  • "Advanced features", Assignment from the jq manual

About

Pure Python implementation of a subset of the features of jq for YAML documents

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages