pax_global_header 0000666 0000000 0000000 00000000064 14477163243 0014525 g ustar 00root root 0000000 0000000 52 comment=ee87412fa89add226d263ec7885193e07243aa4c
yq-3.2.3/ 0000775 0000000 0000000 00000000000 14477163243 0012163 5 ustar 00root root 0000000 0000000 yq-3.2.3/.github/ 0000775 0000000 0000000 00000000000 14477163243 0013523 5 ustar 00root root 0000000 0000000 yq-3.2.3/.github/FUNDING.yml 0000664 0000000 0000000 00000000022 14477163243 0015332 0 ustar 00root root 0000000 0000000 github: [kislyuk]
yq-3.2.3/.github/workflows/ 0000775 0000000 0000000 00000000000 14477163243 0015560 5 ustar 00root root 0000000 0000000 yq-3.2.3/.github/workflows/ci.yml 0000664 0000000 0000000 00000001505 14477163243 0016677 0 ustar 00root root 0000000 0000000 name: Test suite
on: [push, pull_request]
jobs:
unit_tests:
runs-on: ${{matrix.os}}
strategy:
max-parallel: 8
matrix:
os: [ubuntu-20.04, ubuntu-22.04, macos-12]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{matrix.python-version}}
- name: Install jq
run: |
if [[ $(uname) == Linux ]]; then sudo apt-get install --yes jq; fi
if [[ $(uname) == Darwin ]]; then brew install jq; fi
- run: make install
- run: make lint
- run: make test
- uses: codecov/codecov-action@v3
black:
runs-on: ubuntu-22.04
steps:
- uses: psf/black@stable
isort:
runs-on: ubuntu-22.04
steps:
- uses: isort/isort-action@v1.1.0
yq-3.2.3/.gitignore 0000664 0000000 0000000 00000000735 14477163243 0014160 0 ustar 00root root 0000000 0000000 # Reminder:
# - A leading slash means the pattern is anchored at the root.
# - No leading slash means the pattern matches at any depth.
# Python files
*.pyc
__pycache__/
.tox/
*.egg-info/
/build/
/dist/
/.eggs/
/yq/version.py
# IDE project files
/.pydevproject
# vim python-mode plugin
/.ropeproject
# IntelliJ IDEA / PyCharm project files
/.idea
/*.iml
# JS/node/npm/web dev files
node_modules
npm-debug.log
# OS X metadata files
.DS_Store
# Python coverage
.coverage
yq-3.2.3/Changes.rst 0000664 0000000 0000000 00000017154 14477163243 0014275 0 ustar 00root root 0000000 0000000 Changes for v3.2.3 (2023-09-09)
===============================
- test.py: use valid values for jsonargs. Fixes #172
- Allow editing toml in place (#171)
- Documentation improvements
Changes for v3.2.2 (2023-04-22)
===============================
- Allow XML documents to be streamed with –xml-item-depth
Changes for v3.2.1 (2023-04-04)
===============================
- Relax tomlkit dependency version range to preserve Python 3.6
compatibility (#165)
Changes for v3.2.0 (2023-04-03)
===============================
- Use tomlkit instead of toml
- Add security policy
- Documentation and release infrastructure improvements
Changes for v3.1.1 (2023-02-21)
===============================
- Handle TOML datetimes. Fixes #160
- Test and documentation improvements
Changes for v3.1.0 (2022-07-24)
===============================
- Use configurable output grammar, compatible with YAML 1.1
Changes for v3.0.2 (2022-07-05)
===============================
- Expand merge keys (https://yaml.org/type/merge.html). This is a YAML
1.1 specific behavior, but will be accommodated in yq due to its
widespread use and low likelihood of accidental invocation.
Changes for v3.0.1 (2022-07-04)
===============================
- yq now uses the YAML 1.2 grammar when parsing and rendering YAML
documents. This means bare literals like “on”, “no”, and “12:34:56”
are interpreted as strings. (Fix interrupted release)
Changes for v3.0.0 (2022-07-04)
===============================
- yq now uses the YAML 1.2 grammar when parsing and rendering YAML
documents. This means bare literals like “on”, “no”, and “12:34:56”
are interpreted as strings.
Changes for v2.14.0 (2022-02-20)
================================
- Support binary and set tags. Fixes #140
Changes for v2.13.0 (2021-12-02)
================================
- Armor against entity expansion attacks
- Improve YAML loading performance by using CSafeLoader where available
- Require PyYAML 5.3.1 or newer
- Test and release infrastructure improvements
Changes for v2.12.2 (2021-06-13)
================================
- Handle -n correctly
Changes for v2.12.1 (2021-06-13)
================================
- Do not close fds on child process
Changes for v2.12.0 (2021-02-05)
================================
- Add TOML support and the tomlq CLI utility to access it
- Drop Python 2.7 support
Changes for v2.11.1 (2020-09-26)
================================
Parse correctly when empty string is passed as jq_filter
Changes for v2.11.0 (2020-09-03)
================================
- Better handling of jq_filter and files arguments (#102)
- Create **main**.py (#82)
Changes for v2.10.1 (2020-05-11)
================================
- Add support for xmltodict force_list definition for xq CLI (#95)
- Support explicit doc markers (#93)
- Ensure proper ordering of help messages (#90)
Changes for v2.10.0 (2019-12-23)
================================
- Add support for in-place editing (yq -yi)
- Add argcomplete integration
- Docs: Migrate from RTD to gh-pages
Changes for v2.9.2 (2019-11-04)
===============================
- Fix interrupted release
Changes for v2.9.1 (2019-11-04)
===============================
- Fix documentation build
Changes for v2.9.0 (2019-11-04)
===============================
- Add -Y/–yaml-roundtrip for preserving YAML styles and tags
Changes for v2.8.1 (2019-10-28)
===============================
- Filter out -C and separate commingled yq and jq short options
Changes for v2.8.0 (2019-10-25)
===============================
- Set default block sequence indentation to 2 spaces, –indentless for 0
- Make main body of yq callable as a library function
- Test and release infrastructure updates
Changes for v2.7.2 (2019-01-09)
===============================
- Support options introduced in jq 1.6. Fixes #46
- xq: Re-raise if exception is unrecognized
Changes for v2.7.1 (2018-11-05)
===============================
- xq: Introduce –xml-dtd and –xml-root. Fixes #37.
- TOML support is optional and experimental
Changes for v2.7.0 (2018-08-04)
===============================
- TOML support with the tq executable entry point.
- Disallow argparse abbreviated options. Fixes #38 on Python 3.5+.
- Now available in Homebrew as python-yq.
Changes for v2.6.0 (2018-04-28)
===============================
- Packaging: Replace scripts with entry-points
- Packaging: Package the license file
Changes for v2.5.0 (2018-04-02)
===============================
- Parse unrecognized tags instead of dropping them. Fixes #23
Changes for v2.4.1 (2018-02-13)
===============================
- Ignore unrecognized YAML tags instead of crashing
- Explicitly disable XML entity expansion and mention in docs
- xq -x: Raise understandable error on non-dict conversion failure
Changes for v2.4.0 (2018-02-08)
===============================
- Support XML parsing with xmltodict
Changes for v2.3.7 (2018-02-07)
===============================
- Fix for the –from-file/-f argument: Re-route jq_filter to files when
using –from-file. Fixes #19.
Changes for v2.3.6 (2018-01-29)
===============================
- Parse and pass multiple positional-consuming jq args
Changes for v2.3.5 (2018-01-29)
===============================
- Support jq arguments that consume subsequent positionals (such as
–arg k v) (#16).
Changes for v2.3.4 (2017-12-26)
===============================
- Support bare YAML dates and times. Fixes #10
Changes for v2.3.3 (2017-09-30)
===============================
- Avoid buffering all input docs in memory with no -y
- End all json.dump output with newlines. Close all input streams.
Fixes #8. Thanks to @bubbleattic for reporting.
Changes for v2.3.2 (2017-09-25)
===============================
- Fix test suite on Python 3
Changes for v2.3.1 (2017-09-25)
===============================
- Add support for multiple yaml files in arguments. Thanks to
@bubbleattic (PR #7)
Changes for v2.3.0 (2017-08-27)
===============================
- Handle multi-document streams. Fixes #6
- Report version via yq --version
Changes for v2.2.0 (2017-07-07)
===============================
- Stringify datetimes loaded from YAML. Fixes #5
Changes for v2.1.2 (2017-06-27)
===============================
- Fix ResourceWarning: unclosed file
- Internal: Make usage of loader argument consistent
- Documentation improvements
Changes for v2.1.1 (2017-05-02)
===============================
- Fix release script. Release is identical to v2.1.0.
Changes for v2.1.0 (2017-05-02)
===============================
- yq now supports emitting YAML (round-trip YAML support) using "yq
-y". Fixes #2.
- Key order is now preserved in mappings/objects/dictionaries.
- Passing input files by filename as an argument is now supported (in
addition to providing data on standard input).
Changes for v2.0.2 (2017-01-16)
===============================
- Test and documentation improvements
Changes for v2.0.1 (2017-01-14)
===============================
- Fix description in setup.py
Changes for v2.0.0 (2017-01-14)
===============================
- Begin 2.0.0 release series. This package's release series available
on PyPI begins with version 2.0.0. Versions of ``yq`` prior to 2.0.0
are distributed by https://github.com/abesto/yq and are not related
to this package. No guarantees of compatibility are made between
abesto/yq and kislyuk/yq. This package follows the
``Semantic Versioning 2.0.0 ``\ \_ standard. To
ensure proper operation, declare dependency version ranges according
to SemVer. See the Readme for more information.
yq-3.2.3/LICENSE 0000664 0000000 0000000 00000024041 14477163243 0013171 0 ustar 00root root 0000000 0000000 Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and
distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright
owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities
that control, are controlled by, or are under common control with that entity.
For the purposes of this definition, "control" means (i) the power, direct or
indirect, to cause the direction or management of such entity, whether by
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising
permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including
but not limited to software source code, documentation source, and configuration
files.
"Object" form shall mean any form resulting from mechanical transformation or
translation of a Source form, including but not limited to compiled object code,
generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made
available under the License, as indicated by a copyright notice that is included
in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that
is based on (or derived from) the Work and for which the editorial revisions,
annotations, elaborations, or other modifications represent, as a whole, an
original work of authorship. For the purposes of this License, Derivative Works
shall not include works that remain separable from, or merely link (or bind by
name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version
of the Work and any modifications or additions to that Work or Derivative Works
thereof, that is intentionally submitted to Licensor for inclusion in the Work
by the copyright owner or by an individual or Legal Entity authorized to submit
on behalf of the copyright owner. For the purposes of this definition,
"submitted" means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems, and
issue tracking systems that are managed by, or on behalf of, the Licensor for
the purpose of discussing and improving the Work, but excluding communication
that is conspicuously marked or otherwise designated in writing by the copyright
owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
of whom a Contribution has been received by Licensor and subsequently
incorporated within the Work.
2. Grant of Copyright License.
Subject to the terms and conditions of this License, each Contributor hereby
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
irrevocable copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the Work and such
Derivative Works in Source or Object form.
3. Grant of Patent License.
Subject to the terms and conditions of this License, each Contributor hereby
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to make, have
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
such license applies only to those patent claims licensable by such Contributor
that are necessarily infringed by their Contribution(s) alone or by combination
of their Contribution(s) with the Work to which such Contribution(s) was
submitted. If You institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
Contribution incorporated within the Work constitutes direct or contributory
patent infringement, then any patent licenses granted to You under this License
for that Work shall terminate as of the date such litigation is filed.
4. Redistribution.
You may reproduce and distribute copies of the Work or Derivative Works thereof
in any medium, with or without modifications, and in Source or Object form,
provided that You meet the following conditions:
You must give any other recipients of the Work or Derivative Works a copy of
this License; and
You must cause any modified files to carry prominent notices stating that You
changed the files; and
You must retain, in the Source form of any Derivative Works that You distribute,
all copyright, patent, trademark, and attribution notices from the Source form
of the Work, excluding those notices that do not pertain to any part of the
Derivative Works; and
If the Work includes a "NOTICE" text file as part of its distribution, then any
Derivative Works that You distribute must include a readable copy of the
attribution notices contained within such NOTICE file, excluding those notices
that do not pertain to any part of the Derivative Works, in at least one of the
following places: within a NOTICE text file distributed as part of the
Derivative Works; within the Source form or documentation, if provided along
with the Derivative Works; or, within a display generated by the Derivative
Works, if and wherever such third-party notices normally appear. The contents of
the NOTICE file are for informational purposes only and do not modify the
License. You may add Your own attribution notices within Derivative Works that
You distribute, alongside or as an addendum to the NOTICE text from the Work,
provided that such additional attribution notices cannot be construed as
modifying the License.
You may add Your own copyright statement to Your modifications and may provide
additional or different license terms and conditions for use, reproduction, or
distribution of Your modifications, or for any such Derivative Works as a whole,
provided Your use, reproduction, and distribution of the Work otherwise complies
with the conditions stated in this License.
5. Submission of Contributions.
Unless You explicitly state otherwise, any Contribution intentionally submitted
for inclusion in the Work by You to the Licensor shall be under the terms and
conditions of this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify the terms of
any separate license agreement you may have executed with Licensor regarding
such Contributions.
6. Trademarks.
This License does not grant permission to use the trade names, trademarks,
service marks, or product names of the Licensor, except as required for
reasonable and customary use in describing the origin of the Work and
reproducing the content of the NOTICE file.
7. Disclaimer of Warranty.
Unless required by applicable law or agreed to in writing, Licensor provides the
Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
including, without limitation, any warranties or conditions of TITLE,
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
solely responsible for determining the appropriateness of using or
redistributing the Work and assume any risks associated with Your exercise of
permissions under this License.
8. Limitation of Liability.
In no event and under no legal theory, whether in tort (including negligence),
contract, or otherwise, unless required by applicable law (such as deliberate
and grossly negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special, incidental,
or consequential damages of any character arising as a result of this License or
out of the use or inability to use the Work (including but not limited to
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
any and all other commercial damages or losses), even if such Contributor has
been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability.
While redistributing the Work or Derivative Works thereof, You may choose to
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
other liability obligations and/or rights consistent with this License. However,
in accepting such obligations, You may act only on Your own behalf and on Your
sole responsibility, not on behalf of any other Contributor, and only if You
agree to indemnify, defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason of your
accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work
To apply the Apache License to your work, attach the following boilerplate
notice, with the fields enclosed by brackets "[]" replaced with your own
identifying information. (Don't include the brackets!) The text should be
enclosed in the appropriate comment syntax for the file format. We also
recommend that a file or class name and description of purpose be included on
the same "printed page" as the copyright notice for easier identification within
third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
yq-3.2.3/MANIFEST.in 0000664 0000000 0000000 00000000051 14477163243 0013715 0 ustar 00root root 0000000 0000000 include LICENSE
recursive-include test *
yq-3.2.3/Makefile 0000664 0000000 0000000 00000000736 14477163243 0013631 0 ustar 00root root 0000000 0000000 SHELL=/bin/bash
lint:
ruff $$(dirname */__init__.py)
mypy --install-types --non-interactive --check-untyped-defs $$(dirname */__init__.py)
test:
python ./test/test.py -v
init_docs:
cd docs; sphinx-quickstart
docs:
python -m pip install furo sphinx-copybutton
sphinx-build docs docs/html
install:
-rm -rf dist
python -m pip install build
python -m build
python -m pip install --upgrade $$(echo dist/*.whl)[tests]
.PHONY: test lint release docs
include common.mk
yq-3.2.3/README.rst 0000664 0000000 0000000 00000016452 14477163243 0013662 0 ustar 00root root 0000000 0000000 yq: Command-line YAML/XML/TOML processor - jq wrapper for YAML, XML, TOML documents
===================================================================================
Installation
------------
::
pip install yq
Before using ``yq``, you also have to install its dependency, ``jq``. See the `jq installation instructions
`_ for details and directions specific to your platform.
On macOS, ``yq`` is also available on `Homebrew `_: use ``brew install python-yq``.
Synopsis
--------
``yq`` takes YAML input, converts it to JSON, and pipes it to `jq `_::
cat input.yml | yq .foo.bar
Like in ``jq``, you can also specify input filename(s) as arguments::
yq .foo.bar input.yml
By default, no conversion of ``jq`` output is done. Use the ``--yaml-output``/``-y`` option to convert it back into YAML::
cat input.yml | yq -y .foo.bar
Mapping key order is preserved. By default, custom `YAML tags `_ and
`styles `_ in the input are ignored. Use the ``--yaml-roundtrip``/``-Y``
option to preserve YAML tags and styles by representing them as extra items in their enclosing mappings and sequences
while in JSON::
yq -Y .foo.bar input.yml
yq can be called as a module if needed. With ``-y/-Y``, files can be edited in place like with ``sed -i``::
python -m yq -Y --indentless --in-place '.["current-context"] = "staging-cluster"' ~/.kube/config
Use the ``--width``/``-w`` option to pass the line wrap width for string literals. Use
``--explicit-start``/``--explicit-end`` to emit YAML start/end markers even when processing a single document. All other
command line arguments are forwarded to ``jq``. ``yq`` forwards the exit code ``jq`` produced, unless there was an error
in YAML parsing, in which case the exit code is 1. See the `jq manual `_ for more
details on ``jq`` features and options.
Because YAML treats JSON as a dialect of YAML, you can use yq to convert JSON to YAML: ``yq -y . < in.json > out.yml``.
Preserving tags and styles using the ``-Y`` (``--yaml-roundtrip``) option
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The ``-Y`` option helps preserve custom `string styles `_ and
`tags `_ in your document. For example, consider the following
document (an `AWS CloudFormation `_ template fragment)::
Resources:
ElasticLoadBalancer:
Type: 'AWS::ElasticLoadBalancing::LoadBalancer'
Properties:
AvailabilityZones: !GetAZs ''
Instances:
- !Ref Ec2Instance1
- !Ref Ec2Instance2
Description: >-
Load balancer for Big Important Service.
Good thing it's managed by this template.
Passing this document through ``yq -y .Resources.ElasticLoadBalancer`` will drop custom tags, such as ``!Ref``,
and styles, such as the `folded `_ style of the ``Description`` field::
Type: AWS::ElasticLoadBalancing::LoadBalancer
Properties:
AvailabilityZones: ''
Instances:
- Ec2Instance1
- Ec2Instance2
Description: 'Load balancer for Big Important Service.
Good thing it''s managed by this template.'
By contrast, passing it through ``yq -Y .Resources.ElasticLoadBalancer`` will preserve tags and styles::
Type: 'AWS::ElasticLoadBalancing::LoadBalancer'
Properties:
AvailabilityZones: !GetAZs ''
Instances:
- !Ref 'Ec2Instance1'
- !Ref 'Ec2Instance2'
Description: >-
Load balancer for Big Important Service.
Good thing it's managed by this template.
To accomplish this in ``-Y`` mode, yq carries extra metadata (mapping pairs and sequence values) in the JSON
representation of your document for any custom tags or styles that it finds. When converting the JSON back into YAML, it
parses this metadata, re-applies the tags and styles, and discards the extra pairs and values.
.. warning ::
The ``-Y`` option is incompatible with jq filters that do not expect the extra information injected into the document
to preserve the YAML formatting. For example, a jq filter that counts entries in the Instances array will come up with
4 entries instead of 2. A filter that expects all array entries to be mappings may break due to the presence of string
metadata keys. Check your jq filter for compatibility/semantic validity when using the ``-Y`` option.
XML support
-----------
``yq`` also supports XML. The ``yq`` package installs an executable, ``xq``, which
`transcodes XML to JSON `_ using
`xmltodict `_ and pipes it to ``jq``. Roundtrip transcoding is available with
the ``xq --xml-output``/``xq -x`` option. Multiple XML documents can be passed in separate files/streams as
``xq a.xml b.xml``. Use ``--xml-item-depth`` to descend into large documents, streaming their contents without loading
the full doc into memory (for example, stream a `Wikipedia database dump `_ with
``cat enwiki-*.xml.bz2 | bunzip2 | xq . --xml-item-depth=2``). Entity expansion and DTD resolution is disabled to avoid
XML parsing vulnerabilities.
TOML support
------------
``yq`` supports `TOML `_ as well. The ``yq`` package installs an executable, ``tomlq``, which uses the
`tomlkit library `_ to transcode TOML to JSON, then pipes it to ``jq``. Roundtrip
transcoding is available with the ``tomlq --toml-output``/``tomlq -t`` option.
.. admonition:: Compatibility note
This package's release series available on PyPI begins with version 2.0.0. Versions of ``yq`` prior to 2.0.0 are
distributed by https://github.com/abesto/yq and are not related to this package. No guarantees of compatibility are
made between abesto/yq and kislyuk/yq. This package follows the `Semantic Versioning 2.0.0 `_
standard. To ensure proper operation, declare dependency version ranges according to SemVer.
Authors
-------
* Andrey Kislyuk
Links
-----
* `Project home page (GitHub) `_
* `Documentation `_
* `Package distribution (PyPI) `_
* `Change log `_
* `jq `_ - the command-line JSON processor utility powering ``yq``
Bugs
~~~~
Please report bugs, issues, feature requests, etc. on `GitHub `_.
License
-------
Licensed under the terms of the `Apache License, Version 2.0 `_.
.. image:: https://github.com/kislyuk/yq/workflows/Python%20package/badge.svg
:target: https://github.com/kislyuk/yq/actions
.. image:: https://codecov.io/github/kislyuk/yq/coverage.svg?branch=master
:target: https://codecov.io/github/kislyuk/yq?branch=master
.. image:: https://img.shields.io/pypi/v/yq.svg
:target: https://pypi.python.org/pypi/yq
.. image:: https://img.shields.io/pypi/l/yq.svg
:target: https://pypi.python.org/pypi/yq
yq-3.2.3/SECURITY.md 0000664 0000000 0000000 00000001270 14477163243 0013754 0 ustar 00root root 0000000 0000000 # Security Policy
## Reporting a Vulnerability
If you believe you have found a security vulnerability in this project, please report it to us by submitting a security advisory at https://github.com/kislyuk/yq/security/advisories. You can expect an initial response within 14 days.
## Supported Versions
In general, the maintainers of this project provide security updates only for the most recent published release. If you need support for prior versions, please open an issue and describe your situation. Requests for updates to prior releases will be considered on a case-by-case basis, and will generally be accommodated only for the latest releases in prior major version release series.
yq-3.2.3/common.mk 0000664 0000000 0000000 00000004774 14477163243 0014020 0 ustar 00root root 0000000 0000000 SHELL=/bin/bash -eo pipefail
release-major:
$(eval export TAG=$(shell git describe --tags --match 'v*.*.*' | perl -ne '/^v(\d+)\.(\d+)\.(\d+)/; print "v@{[$$1+1]}.0.0"'))
$(MAKE) release
release-minor:
$(eval export TAG=$(shell git describe --tags --match 'v*.*.*' | perl -ne '/^v(\d+)\.(\d+)\.(\d+)/; print "v$$1.@{[$$2+1]}.0"'))
$(MAKE) release
release-patch:
$(eval export TAG=$(shell git describe --tags --match 'v*.*.*' | perl -ne '/^v(\d+)\.(\d+)\.(\d+)/; print "v$$1.$$2.@{[$$3+1]}"'))
$(MAKE) release
release:
@if ! git diff --cached --exit-code; then echo "Commit staged files before proceeding"; exit 1; fi
@if [[ -z $$TAG ]]; then echo "Use release-{major,minor,patch}"; exit 1; fi
@if ! type -P pandoc; then echo "Please install pandoc"; exit 1; fi
@if ! type -P sponge; then echo "Please install moreutils"; exit 1; fi
@if ! type -P gh; then echo "Please install gh"; exit 1; fi
@if ! type -P twine; then echo "Please install twine"; exit 1; fi
git pull
git clean -x --force $$(python setup.py --name)
sed -i -e "s/version=\([\'\"]\)[0-9]*\.[0-9]*\.[0-9]*/version=\1$${TAG:1}/" setup.py
git add setup.py
TAG_MSG=$$(mktemp); \
echo "# Changes for ${TAG} ($$(date +%Y-%m-%d))" > $$TAG_MSG; \
git log --pretty=format:%s $$(git describe --abbrev=0)..HEAD >> $$TAG_MSG; \
$${EDITOR:-emacs} $$TAG_MSG; \
if [[ -f Changes.md ]]; then cat $$TAG_MSG <(echo) Changes.md | sponge Changes.md; git add Changes.md; fi; \
if [[ -f Changes.rst ]]; then cat <(pandoc --from markdown --to rst $$TAG_MSG) <(echo) Changes.rst | sponge Changes.rst; git add Changes.rst; fi; \
yq --help > docs/cli-doc.txt; git add docs/cli-doc.txt; \
xq --help > docs/cli-doc-xq.txt; git add docs/cli-doc-xq.txt; \
tomlq --help > docs/cli-doc-tomlq.txt; git add docs/cli-doc-tomlq.txt; \
git commit -m ${TAG}; \
git tag --sign --annotate --file $$TAG_MSG ${TAG}
git push --follow-tags
$(MAKE) install
gh release create ${TAG} dist/*.whl --notes="$$(git tag --list ${TAG} -n99 | perl -pe 's/^\S+\s*// if $$. == 1' | sed 's/^\s\s\s\s//')"
$(MAKE) release-pypi
$(MAKE) release-docs
release-pypi:
python -m build
twine upload dist/*.tar.gz dist/*.whl --sign --verbose
release-docs:
$(MAKE) docs
-git branch -D gh-pages
git checkout -B gh-pages-stage
touch docs/html/.nojekyll
git add --force docs/html
git commit -m "Docs for ${TAG}"
git push --force origin $$(git subtree split --prefix docs/html --branch gh-pages):refs/heads/gh-pages
git checkout -
.PHONY: release
yq-3.2.3/docs/ 0000775 0000000 0000000 00000000000 14477163243 0013113 5 ustar 00root root 0000000 0000000 yq-3.2.3/docs/changelog.rst 0000664 0000000 0000000 00000000070 14477163243 0015571 0 ustar 00root root 0000000 0000000 Release Notes
=============
.. include:: ../Changes.rst
yq-3.2.3/docs/cli-doc-tomlq.txt 0000664 0000000 0000000 00000004577 14477163243 0016335 0 ustar 00root root 0000000 0000000 usage: tomlq [options] [input file...]
tomlq: Command-line TOML processor - jq wrapper for TOML documents
tomlq transcodes TOML documents to JSON and passes them to jq.
See https://github.com/kislyuk/tomlq for more information.
positional arguments:
jq_filter
files
options:
-h, --help show this help message and exit
--toml-output, -t Transcode jq JSON output back into TOML and emit it
--in-place, -i Edit files in place (no backup - use caution)
--version show program's version number and exit
jq - commandline JSON processor [version 1.6]
Usage: jq [options] [file...]
jq [options] --args [strings...]
jq [options] --jsonargs [JSON_TEXTS...]
jq is a tool for processing JSON inputs, applying the given filter to
its JSON text inputs and producing the filter's results as JSON on
standard output.
The simplest filter is ., which copies jq's input to its output
unmodified (except for formatting, but note that IEEE754 is used
for number representation internally, with all that that implies).
For more advanced filters see the jq(1) manpage ("man jq")
and/or https://stedolan.github.io/jq
Example:
$ echo '{"foo": 0}' | jq .
{
"foo": 0
}
Some of the options include:
-c compact instead of pretty-printed output;
-n use `null` as the single input value;
-e set the exit status code based on the output;
-s read (slurp) all inputs into an array; apply filter to it;
-r output raw strings, not JSON texts;
-R read raw strings, not JSON texts;
-C colorize JSON;
-M monochrome (don't colorize JSON);
-S sort keys of objects on output;
--tab use tabs for indentation;
--arg a v set variable $a to value ;
--argjson a v set variable $a to JSON value ;
--slurpfile a f set variable $a to an array of JSON texts read from ;
--rawfile a f set variable $a to a string consisting of the contents of ;
--args remaining arguments are string arguments, not files;
--jsonargs remaining arguments are JSON arguments, not files;
-- terminates argument processing;
Named arguments are also available as $ARGS.named[], while
positional arguments are available as $ARGS.positional[].
See the manpage for more options.
yq-3.2.3/docs/cli-doc-xq.txt 0000664 0000000 0000000 00000005537 14477163243 0015626 0 ustar 00root root 0000000 0000000 usage: xq [options] [input file...]
[--version]
[jq_filter] [files ...]
xq: Command-line XML processor - jq wrapper for XML documents
xq transcodes XML documents to JSON and passes them to jq.
See https://github.com/kislyuk/xq for more information.
positional arguments:
jq_filter
files
options:
-h, --help show this help message and exit
--xml-output, -x Transcode jq JSON output back into XML and emit it
--xml-item-depth 123 Specify depth of items to emit (default 0; use a positive integer to stream large docs)
--xml-dtd Preserve XML Document Type Definition (disables streaming of multiple docs)
--xml-root XML_ROOT When transcoding back to XML, envelope the output in an element with this name
--xml-force-list ELT Emit a list for elements with this name even if they occur only once (option can repeat)
--in-place, -i Edit files in place (no backup - use caution)
--version show program's version number and exit
jq - commandline JSON processor [version 1.6]
Usage: jq [options] [file...]
jq [options] --args [strings...]
jq [options] --jsonargs [JSON_TEXTS...]
jq is a tool for processing JSON inputs, applying the given filter to
its JSON text inputs and producing the filter's results as JSON on
standard output.
The simplest filter is ., which copies jq's input to its output
unmodified (except for formatting, but note that IEEE754 is used
for number representation internally, with all that that implies).
For more advanced filters see the jq(1) manpage ("man jq")
and/or https://stedolan.github.io/jq
Example:
$ echo '{"foo": 0}' | jq .
{
"foo": 0
}
Some of the options include:
-c compact instead of pretty-printed output;
-n use `null` as the single input value;
-e set the exit status code based on the output;
-s read (slurp) all inputs into an array; apply filter to it;
-r output raw strings, not JSON texts;
-R read raw strings, not JSON texts;
-C colorize JSON;
-M monochrome (don't colorize JSON);
-S sort keys of objects on output;
--tab use tabs for indentation;
--arg a v set variable $a to value ;
--argjson a v set variable $a to JSON value ;
--slurpfile a f set variable $a to an array of JSON texts read from ;
--rawfile a f set variable $a to a string consisting of the contents of ;
--args remaining arguments are string arguments, not files;
--jsonargs remaining arguments are JSON arguments, not files;
-- terminates argument processing;
Named arguments are also available as $ARGS.named[], while
positional arguments are available as $ARGS.positional[].
See the manpage for more options.
yq-3.2.3/docs/cli-doc.txt 0000664 0000000 0000000 00000007103 14477163243 0015167 0 ustar 00root root 0000000 0000000 usage: yq [options] [input file...]
[--indentless-lists] [--explicit-start] [--explicit-end]
[--in-place] [--version]
[jq_filter] [files ...]
yq: Command-line YAML processor - jq wrapper for YAML documents
yq transcodes YAML documents to JSON and passes them to jq.
See https://github.com/kislyuk/yq for more information.
positional arguments:
jq_filter
files
options:
-h, --help show this help message and exit
--yaml-output, --yml-output, -y
Transcode jq JSON output back into YAML and emit it
--yaml-roundtrip, --yml-roundtrip, -Y
Transcode jq JSON output back into YAML and emit it. Preserve YAML tags and styles by representing them as extra items in their enclosing mappings and sequences while in JSON. This option is incompatible with jq filters that do not expect these extra items.
--yaml-output-grammar-version {1.1,1.2}, --yml-out-ver {1.1,1.2}
When using --yaml-output, specify output grammar (the default is 1.1 and will be changed to 1.2 in a future version). Setting this to 1.2 will cause strings like 'on' and 'no' to be emitted unquoted.
--width WIDTH, -w WIDTH
When using --yaml-output, specify string wrap width
--indentless-lists, --indentless
When using --yaml-output, indent block style lists (sequences) with 0 spaces instead of 2
--explicit-start When using --yaml-output, always emit explicit document start ("---")
--explicit-end When using --yaml-output, always emit explicit document end ("...")
--in-place, -i Edit files in place (no backup - use caution)
--version show program's version number and exit
jq - commandline JSON processor [version 1.6]
Usage: jq [options] [file...]
jq [options] --args [strings...]
jq [options] --jsonargs [JSON_TEXTS...]
jq is a tool for processing JSON inputs, applying the given filter to
its JSON text inputs and producing the filter's results as JSON on
standard output.
The simplest filter is ., which copies jq's input to its output
unmodified (except for formatting, but note that IEEE754 is used
for number representation internally, with all that that implies).
For more advanced filters see the jq(1) manpage ("man jq")
and/or https://stedolan.github.io/jq
Example:
$ echo '{"foo": 0}' | jq .
{
"foo": 0
}
Some of the options include:
-c compact instead of pretty-printed output;
-n use `null` as the single input value;
-e set the exit status code based on the output;
-s read (slurp) all inputs into an array; apply filter to it;
-r output raw strings, not JSON texts;
-R read raw strings, not JSON texts;
-C colorize JSON;
-M monochrome (don't colorize JSON);
-S sort keys of objects on output;
--tab use tabs for indentation;
--arg a v set variable $a to value ;
--argjson a v set variable $a to JSON value ;
--slurpfile a f set variable $a to an array of JSON texts read from ;
--rawfile a f set variable $a to a string consisting of the contents of ;
--args remaining arguments are string arguments, not files;
--jsonargs remaining arguments are JSON arguments, not files;
-- terminates argument processing;
Named arguments are also available as $ARGS.named[], while
positional arguments are available as $ARGS.positional[].
See the manpage for more options.
yq-3.2.3/docs/conf.py 0000664 0000000 0000000 00000001446 14477163243 0014417 0 ustar 00root root 0000000 0000000 import os
project = "yq"
copyright = "Andrey Kislyuk"
author = "Andrey Kislyuk"
version = ""
release = ""
language = "en"
master_doc = "index"
extensions = ["sphinx.ext.autodoc", "sphinx.ext.viewcode", "sphinx_copybutton"]
source_suffix = [".rst", ".md"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
pygments_style = "sphinx"
templates_path = [""]
if "readthedocs.org" in os.getcwd().split("/"):
with open("index.rst", "w") as fh:
fh.write("Documentation for this project has moved to https://kislyuk.github.io/" + project)
else:
html_theme = "furo"
html_sidebars = {
"**": [
"sidebar/brand.html",
"sidebar/search.html",
"sidebar/scroll-start.html",
"toc.html",
"sidebar/scroll-end.html",
]
}
yq-3.2.3/docs/index.rst 0000664 0000000 0000000 00000000370 14477163243 0014754 0 ustar 00root root 0000000 0000000 .. include:: ../README.rst
CLI usage
=========
yq
--
.. literalinclude:: cli-doc.txt
xq
--
.. literalinclude:: cli-doc-xq.txt
tomlq
-----
.. literalinclude:: cli-doc-tomlq.txt
Change log
==========
.. toctree::
:maxdepth: 5
changelog
yq-3.2.3/docs/toc.html 0000664 0000000 0000000 00000000010 14477163243 0014555 0 ustar 00root root 0000000 0000000 {{toc}}
yq-3.2.3/pyproject.toml 0000664 0000000 0000000 00000000407 14477163243 0015100 0 ustar 00root root 0000000 0000000 [tool.black]
line-length = 120
[tool.isort]
profile = "black"
line_length = 120
skip_gitignore = true
[tool.ruff]
line-length = 120
per-file-ignores = {"yq/__init__.py" = ["F401"]}
[[tool.mypy.overrides]]
module = "argcomplete.*"
ignore_missing_imports = true
yq-3.2.3/setup.py 0000775 0000000 0000000 00000003214 14477163243 0013700 0 ustar 00root root 0000000 0000000 #!/usr/bin/env python
from setuptools import find_packages, setup
setup(
name="yq",
version="3.2.3",
url="https://github.com/kislyuk/yq",
license="Apache Software License",
author="Andrey Kislyuk",
author_email="kislyuk@gmail.com",
description="Command-line YAML/XML processor - jq wrapper for YAML/XML documents",
long_description=open("README.rst").read(),
python_requires=">=3.6",
use_scm_version={
"write_to": "yq/version.py",
},
setup_requires=["setuptools_scm >= 3.4.3"],
install_requires=[
"PyYAML >= 5.3.1",
"xmltodict >= 0.11.0",
"tomlkit >= 0.11.6",
"argcomplete >= 1.8.1",
],
extras_require={
"tests": [
"coverage",
"wheel",
"build",
"ruff",
"mypy",
]
},
packages=find_packages(exclude=["test"]),
include_package_data=True,
entry_points={
"console_scripts": ["yq=yq:cli", "xq=yq:xq_cli", "tomlq=yq:tq_cli"],
},
test_suite="test",
classifiers=[
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: MacOS :: MacOS X",
"Operating System :: POSIX",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Software Development :: Libraries :: Python Modules",
],
)
yq-3.2.3/test/ 0000775 0000000 0000000 00000000000 14477163243 0013142 5 ustar 00root root 0000000 0000000 yq-3.2.3/test/cfn.yml 0000664 0000000 0000000 00000006614 14477163243 0014442 0 ustar 00root root 0000000 0000000 AWSTemplateFormatVersion: '2010-09-09'
Metadata:
License: Apache-2.0
Description: 'AWS CloudFormation Sample Template S3_Website_With_CloudFront_Distribution:
Sample template showing how to create a website with a custom DNS name, hosted on
Amazon S3 and served via Amazone CloudFront. It assumes you already have a Hosted
Zone registered with Amazon Route 53. **WARNING** This template creates an Amazon
Route 53 DNS record, an S3 bucket and a CloudFront distribution. You will be billed
for the AWS resources used if you create a stack from this template.'
Parameters:
HostedZone:
Type: String
Description: The DNS name of an existing Amazon Route 53 hosted zone
AllowedPattern: (?!-)[a-zA-Z0-9-.]{1,63}(?