[-]
[+]
|
Deleted |
_service:tar_git:python3-yq.spec
|
@@ -1,75 +0,0 @@
-#
-# Do NOT Edit the Auto-generated Part!
-# Generated by: spectacle version 0.32
-#
-
-Name: python3-yq
-
-# >> macros
-# << macros
-%define int_name yq
-
-Summary: Command-line YAML/XML processor - jq wrapper for YAML/XML documents
-Version: 3.1.1
-Release: 0
-Group: Applications
-License: Apache-2.0
-BuildArch: noarch
-URL: https://pypi.org/project/yq/
-Source0: https://files.pythonhosted.org/packages/y/%{int_name}/%{int_name}-%{version}.tar.gz
-Source100: python3-yq.yaml
-Requires: jq
-BuildRequires: pkgconfig(python)
-BuildRequires: python3-setuptools_scm >= 3.4.3
-BuildRequires: python3-yaml >= 3.5.1
-BuildRequires: python3-rpm-macros
-
-%description
-
-yq takes YAML input, converts it to JSON, and pipes it to jq
-
-%if "%{?vendor}" == "chum"
-PackageName: yq
-Type: console-application
-Categories:
- - Utility
-Custom:
- PackagingRepo: https://github.com/sailfishos-chum/python3-yq
-Url:
- Homepage: https://pypi.org/project/yq/
- Help: https://pypi.org/project/yq/#description
-%endif
-
-
-%prep
-%setup -q -n %{int_name}-%{version}
-
-# >> setup
-# << setup
-
-%build
-# >> build pre
-# << build pre
-
-%{py3_build}
-
-# >> build post
-# << build post
-
-%install
-rm -rf %{buildroot}
-# >> install pre
-# << install pre
-%{py3_install}
-
-# >> install post
-# << install post
-
-%files
-%defattr(-,root,root,-)
-# >> files
-%license LICENSE
-%doc README.rst
-%{_bindir}/*
-%{python3_sitelib}/*
-# << files
|
[-]
[+]
|
Added |
_service:tar_git:yq.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -2,8 +2,10 @@
<service name="tar_git">
<param name="url">https://github.com/sailfishos-chum/python3-yq.git</param>
<param name="branch"></param>
- <param name="revision">3.1.1+git3</param>
+ <param name="revision">3.2.3+git1</param>
<!--
+ <param name="branch"></param>
+ <param name="revision">3.1.1+git3</param>
<param name="revision">2.14.0+git2</param>
-->
<param name="token"/>
|
[-]
[+]
|
Deleted |
_service:tar_git:python3-yq.yaml
^
|
@@ -1,42 +0,0 @@
-Name: python3-yq
-Summary: Command-line YAML/XML processor - jq wrapper for YAML/XML documents
-# 2.13 needs pyyaml = 5.3.1, SFOS has 5.3 at the moment
-#Version: 2.13.0
-#Version: 2.12.2
-Version: 3.1.1
-Release: 0
-Group: Applications
-License: Apache-2.0
-URL: https://pypi.org/project/yq/
-Macros:
- - 'int_name;yq'
-Sources:
- - 'https://files.pythonhosted.org/packages/y/%{int_name}/%{int_name}-%{version}.tar.gz'
-Description: |
-
- yq takes YAML input, converts it to JSON, and pipes it to jq
-
- %if "%{?vendor}" == "chum"
- PackageName: yq
- Type: console-application
- Categories:
- - Utility
- Custom:
- PackagingRepo: https://github.com/sailfishos-chum/python3-yq
- Url:
- Homepage: https://pypi.org/project/yq/
- Help: https://pypi.org/project/yq/#description
- %endif
-
-SetupOptions: '-q -n %{int_name}-%{version}'
-BuildArch: noarch
-Configure: none
-Builder: python3
-Requires:
- - jq
-PkgBR:
- - python3-setuptools_scm >= 3.4.3
- - python3-yaml >= 3.5.1
- - python3-rpm-macros
-PkgConfigBR:
- - python
|
[-]
[+]
|
Changed |
_service:tar_git:yq-3.2.3.tar.gz/.github/workflows/ci.yml
^
|
@@ -8,7 +8,7 @@
strategy:
max-parallel: 8
matrix:
- os: [ubuntu-18.04, ubuntu-22.04, macos-12]
+ 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
|
[-]
[+]
|
Changed |
_service:tar_git:yq-3.2.3.tar.gz/Changes.rst
^
|
@@ -1,3 +1,32 @@
+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)
===============================
|
[-]
[+]
|
Changed |
_service:tar_git:yq-3.2.3.tar.gz/Makefile
^
|
@@ -1,7 +1,7 @@
SHELL=/bin/bash
lint:
- flake8
+ ruff $$(dirname */__init__.py)
mypy --install-types --non-interactive --check-untyped-defs $$(dirname */__init__.py)
test:
@@ -11,6 +11,7 @@
cd docs; sphinx-quickstart
docs:
+ python -m pip install furo sphinx-copybutton
sphinx-build docs docs/html
install:
|
[-]
[+]
|
Changed |
_service:tar_git:yq-3.2.3.tar.gz/PKG-INFO
^
|
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: yq
-Version: 3.1.1
+Version: 3.2.3
Summary: Command-line YAML/XML processor - jq wrapper for YAML/XML documents
Home-page: https://github.com/kislyuk/yq
Author: Andrey Kislyuk
@@ -12,15 +12,24 @@
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
+Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.6
-Provides-Extra: tests
License-File: LICENSE
+Requires-Dist: PyYAML>=5.3.1
+Requires-Dist: xmltodict>=0.11.0
+Requires-Dist: tomlkit>=0.11.6
+Requires-Dist: argcomplete>=1.8.1
+Provides-Extra: tests
+Requires-Dist: coverage; extra == "tests"
+Requires-Dist: wheel; extra == "tests"
+Requires-Dist: build; extra == "tests"
+Requires-Dist: ruff; extra == "tests"
+Requires-Dist: mypy; extra == "tests"
yq: Command-line YAML/XML/TOML processor - jq wrapper for YAML, XML, TOML documents
===================================================================================
@@ -58,10 +67,15 @@
yq -Y .foo.bar input.yml
-Use the ``--width``/``-w`` option to pass the line wrap width for string literals. With ``-y/-Y``, files can be edited
-in place like with ``sed -i``: ``yq -yi .foo=1 *.yml``. 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 <https://stedolan.github.io/jq/manual/>`_ for more details on ``jq`` features and options.
+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 <https://stedolan.github.io/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``.
@@ -128,13 +142,16 @@
`transcodes XML to JSON <https://www.xml.com/pub/a/2006/05/31/converting-between-xml-and-json.html>`_ using
`xmltodict <https://github.com/martinblech/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``. Entity expansion and DTD resolution is disabled to avoid XML parsing vulnerabilities.
+``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 <https://dumps.wikimedia.org>`_ 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 <https://toml.io/>`_ as well. The ``yq`` package installs an executable, ``tomlq``, which uses the
-`toml library <https://github.com/uiri/toml>`_ to transcode TOML to JSON, then pipes it to ``jq``. Roundtrip transcoding
-is available with the ``tomlq --toml-output``/``tomlq -t`` option.
+`tomlkit library <https://github.com/sdispater/tomlkit>`_ 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
|
[-]
[+]
|
Changed |
_service:tar_git:yq-3.2.3.tar.gz/README.rst
^
|
@@ -34,10 +34,15 @@
yq -Y .foo.bar input.yml
-Use the ``--width``/``-w`` option to pass the line wrap width for string literals. With ``-y/-Y``, files can be edited
-in place like with ``sed -i``: ``yq -yi .foo=1 *.yml``. 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 <https://stedolan.github.io/jq/manual/>`_ for more details on ``jq`` features and options.
+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 <https://stedolan.github.io/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``.
@@ -104,13 +109,16 @@
`transcodes XML to JSON <https://www.xml.com/pub/a/2006/05/31/converting-between-xml-and-json.html>`_ using
`xmltodict <https://github.com/martinblech/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``. Entity expansion and DTD resolution is disabled to avoid XML parsing vulnerabilities.
+``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 <https://dumps.wikimedia.org>`_ 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 <https://toml.io/>`_ as well. The ``yq`` package installs an executable, ``tomlq``, which uses the
-`toml library <https://github.com/uiri/toml>`_ to transcode TOML to JSON, then pipes it to ``jq``. Roundtrip transcoding
-is available with the ``tomlq --toml-output``/``tomlq -t`` option.
+`tomlkit library <https://github.com/sdispater/tomlkit>`_ 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
|
[-]
[+]
|
Added |
_service:tar_git:yq-3.2.3.tar.gz/SECURITY.md
^
|
@@ -0,0 +1,9 @@
+# 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.
|
[-]
[+]
|
Changed |
_service:tar_git:yq-3.2.3.tar.gz/common.mk
^
|
@@ -17,13 +17,8 @@
@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 http; then echo "Please install httpie"; 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
- $(eval REMOTE=$(shell git remote get-url origin | perl -ne '/([^\/\:]+\/[^\/\:]+?)(\.git)?$$/; print $$1'))
- $(eval GIT_USER=$(shell git config --get user.email))
- $(eval GH_AUTH=$(shell if grep -q '@github.com' ~/.git-credentials; then echo $$(grep '@github.com' ~/.git-credentials | python3 -c 'import sys, urllib.parse as p; print(p.urlparse(sys.stdin.read()).netloc.split("@")[0])'); else echo $(GIT_USER); fi))
- $(eval RELEASES_API=https://api.github.com/repos/${REMOTE}/releases)
- $(eval UPLOADS_API=https://uploads.github.com/repos/${REMOTE}/releases)
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
@@ -34,15 +29,14 @@
$${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; \
- git commit -m ${TAG}; \
+ 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
- http --check-status --auth ${GH_AUTH} ${RELEASES_API} tag_name=${TAG} name=${TAG} \
- body="$$(git tag --list ${TAG} -n99 | perl -pe 's/^\S+\s*// if $$. == 1' | sed 's/^\s\s\s\s//')"
$(MAKE) install
- http --check-status --auth ${GH_AUTH} POST ${UPLOADS_API}/$$(http --auth ${GH_AUTH} ${RELEASES_API}/latest | jq .id)/assets \
- name==$$(basename dist/*.whl) label=="Python Wheel" < dist/*.whl
+ 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
|
[-]
[+]
|
Added |
_service:tar_git:yq-3.2.3.tar.gz/docs/cli-doc-tomlq.txt
^
|
@@ -0,0 +1,64 @@
+usage: tomlq [options] <jq filter> [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] <jq filter> [file...]
+ jq [options] --args <jq filter> [strings...]
+ jq [options] --jsonargs <jq filter> [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 <v>;
+ --argjson a v set variable $a to JSON value <v>;
+ --slurpfile a f set variable $a to an array of JSON texts read from <f>;
+ --rawfile a f set variable $a to a string consisting of the contents of <f>;
+ --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.
|
[-]
[+]
|
Added |
_service:tar_git:yq-3.2.3.tar.gz/docs/cli-doc-xq.txt
^
|
@@ -0,0 +1,70 @@
+usage: xq [options] <jq filter> [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] <jq filter> [file...]
+ jq [options] --args <jq filter> [strings...]
+ jq [options] --jsonargs <jq filter> [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 <v>;
+ --argjson a v set variable $a to JSON value <v>;
+ --slurpfile a f set variable $a to an array of JSON texts read from <f>;
+ --rawfile a f set variable $a to a string consisting of the contents of <f>;
+ --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.
|
[-]
[+]
|
Changed |
_service:tar_git:yq-3.2.3.tar.gz/docs/cli-doc.txt
^
|
@@ -1,5 +1,6 @@
usage: yq [options] <jq filter> [input file...]
- [--indentless-lists] [--in-place] [--version]
+ [--indentless-lists] [--explicit-start] [--explicit-end]
+ [--in-place] [--version]
[jq_filter] [files ...]
yq: Command-line YAML processor - jq wrapper for YAML documents
@@ -11,7 +12,7 @@
jq_filter
files
-optional arguments:
+options:
-h, --help show this help message and exit
--yaml-output, --yml-output, -y
Transcode jq JSON output back into YAML and emit it
@@ -23,6 +24,8 @@
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
|
[-]
[+]
|
Changed |
_service:tar_git:yq-3.2.3.tar.gz/docs/conf.py
^
|
@@ -5,29 +5,25 @@
author = "Andrey Kislyuk"
version = ""
release = ""
-language = None
+language = "en"
master_doc = "index"
-extensions = ["sphinx.ext.autodoc", "sphinx.ext.viewcode"]
+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:
- import guzzle_sphinx_theme
- html_theme_path = guzzle_sphinx_theme.html_theme_path()
- html_theme = "guzzle_sphinx_theme"
- html_theme_options = {
- "project_nav_name": project,
- "projectlink": "https://github.com/kislyuk/" + project,
- }
+ html_theme = "furo"
html_sidebars = {
"**": [
- "logo-text.html",
- # "globaltoc.html",
- "localtoc.html",
- "searchbox.html"
+ "sidebar/brand.html",
+ "sidebar/search.html",
+ "sidebar/scroll-start.html",
+ "toc.html",
+ "sidebar/scroll-end.html",
]
}
|
[-]
[+]
|
Changed |
_service:tar_git:yq-3.2.3.tar.gz/docs/index.rst
^
|
@@ -3,8 +3,19 @@
CLI usage
=========
+yq
+--
.. literalinclude:: cli-doc.txt
+xq
+--
+.. literalinclude:: cli-doc-xq.txt
+
+tomlq
+-----
+.. literalinclude:: cli-doc-tomlq.txt
+
+
Change log
==========
|
[-]
[+]
|
Added |
_service:tar_git:yq-3.2.3.tar.gz/docs/toc.html
^
|
@@ -0,0 +1 @@
+{{toc}}
|
[-]
[+]
|
Changed |
_service:tar_git:yq-3.2.3.tar.gz/pyproject.toml
^
|
@@ -1,9 +1,15 @@
[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
\ No newline at end of file
+ignore_missing_imports = true
|
[-]
[+]
|
Changed |
_service:tar_git:yq-3.2.3.tar.gz/setup.cfg
^
|
@@ -1,12 +1,3 @@
-[metadata]
-license_file = LICENSE
-
-[flake8]
-max-line-length = 120
-extend-ignore = E203
-per-file-ignores =
- yq/__init__.py:F401
-
[egg_info]
tag_build =
tag_date = 0
|
[-]
[+]
|
Changed |
_service:tar_git:yq-3.2.3.tar.gz/setup.py
^
|
@@ -4,7 +4,7 @@
setup(
name="yq",
- version="3.1.1",
+ version="3.2.3",
url="https://github.com/kislyuk/yq",
license="Apache Software License",
author="Andrey Kislyuk",
@@ -19,15 +19,15 @@
install_requires=[
"PyYAML >= 5.3.1",
"xmltodict >= 0.11.0",
- "toml >= 0.10.0",
+ "tomlkit >= 0.11.6",
"argcomplete >= 1.8.1",
],
extras_require={
"tests": [
"coverage",
- "flake8",
"wheel",
"build",
+ "ruff",
"mypy",
]
},
@@ -44,11 +44,11 @@
"Operating System :: POSIX",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
- "Programming Language :: Python :: 3.6",
"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",
],
)
|
[-]
[+]
|
Changed |
_service:tar_git:yq-3.2.3.tar.gz/test/test.py
^
|
@@ -136,7 +136,7 @@
self.run_yq("{}", ["--indentless", "-y", ".a=$ARGS.positional", "--args", "a", "b"]), "a:\n- a\n- b\n"
)
self.assertEqual(self.run_yq("{}", ["-y", ".a=$ARGS.positional", "--args", "a", "b"]), "a:\n - a\n - b\n")
- self.assertEqual(self.run_yq("{}", [".", "--jsonargs", "a", "b"]), "")
+ self.assertEqual(self.run_yq("{}", [".", "--jsonargs", "{}", "{}"]), "")
def test_short_option_separation(self):
# self.assertEqual(self.run_yq('{"a": 1}', ["-yCcC", "."]), "a: 1\n") - Fails on 2.7 and 3.8
@@ -185,7 +185,7 @@
with io.open(cfn_filename) as fh:
self.assertEqual(self.run_yq("", ["-Y", ".", cfn_filename]), fh.read())
- def test_in_place(self):
+ def test_in_place_yaml(self):
with tempfile.NamedTemporaryFile() as tf, tempfile.NamedTemporaryFile() as tf2:
tf.write(b"- foo\n- bar\n")
tf.seek(0)
@@ -202,6 +202,13 @@
self.assertEqual(tf.read(), b"foo\n...\n")
self.assertEqual(tf2.read(), b"foo\n...\n")
+ def test_in_place_toml(self):
+ with tempfile.NamedTemporaryFile() as tf:
+ tf.write(b'[GLOBAL]\nversion="1.0.0"\n')
+ tf.seek(0)
+ self.run_yq("", ["-i", "-t", '.GLOBAL.version="1.0.1"', tf.name], input_format="toml")
+ self.assertEqual(tf.read(), b'[GLOBAL]\nversion = "1.0.1"\n')
+
def test_explicit_doc_markers(self):
test_doc = os.path.join(os.path.dirname(__file__), "doc.yml")
self.assertTrue(self.run_yq("", ["-y", ".", test_doc]).startswith("yaml_struct"))
@@ -210,7 +217,12 @@
def test_xq(self):
self.assertEqual(self.run_yq("<foo/>", ["."], input_format="xml"), "")
+ self.assertEqual(self.run_yq("<foo/>", ["--xml-item-depth=2", "."], input_format="xml"), "")
+ self.assertEqual(self.run_yq("<foo/>", ["--xml-dtd", "."], input_format="xml"), "")
self.assertEqual(self.run_yq("<foo/>", ["-x", ".foo.x=1"], input_format="xml"), "<foo>\n <x>1</x>\n</foo>\n")
+ self.assertTrue(self.run_yq("<foo/>", ["-x", "--xml-dtd", "."], input_format="xml").startswith("<?xml"))
+ self.assertTrue(self.run_yq("<foo/>", ["-x", "--xml-root=R", "."], input_format="xml").startswith("<R>"))
+ self.assertEqual(self.run_yq("<foo/>", ["--xml-force-list=foo", "."], input_format="xml"), "")
self.assertEqual(self.run_yq("<a><b/></a>", ["-y", "."], input_format="xml"), "a:\n b: null\n")
self.assertEqual(
|
[-]
[+]
|
Changed |
_service:tar_git:yq-3.2.3.tar.gz/yq.egg-info/PKG-INFO
^
|
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: yq
-Version: 3.1.1
+Version: 3.2.3
Summary: Command-line YAML/XML processor - jq wrapper for YAML/XML documents
Home-page: https://github.com/kislyuk/yq
Author: Andrey Kislyuk
@@ -12,15 +12,24 @@
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
+Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.6
-Provides-Extra: tests
License-File: LICENSE
+Requires-Dist: PyYAML>=5.3.1
+Requires-Dist: xmltodict>=0.11.0
+Requires-Dist: tomlkit>=0.11.6
+Requires-Dist: argcomplete>=1.8.1
+Provides-Extra: tests
+Requires-Dist: coverage; extra == "tests"
+Requires-Dist: wheel; extra == "tests"
+Requires-Dist: build; extra == "tests"
+Requires-Dist: ruff; extra == "tests"
+Requires-Dist: mypy; extra == "tests"
yq: Command-line YAML/XML/TOML processor - jq wrapper for YAML, XML, TOML documents
===================================================================================
@@ -58,10 +67,15 @@
yq -Y .foo.bar input.yml
-Use the ``--width``/``-w`` option to pass the line wrap width for string literals. With ``-y/-Y``, files can be edited
-in place like with ``sed -i``: ``yq -yi .foo=1 *.yml``. 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 <https://stedolan.github.io/jq/manual/>`_ for more details on ``jq`` features and options.
+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 <https://stedolan.github.io/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``.
@@ -128,13 +142,16 @@
`transcodes XML to JSON <https://www.xml.com/pub/a/2006/05/31/converting-between-xml-and-json.html>`_ using
`xmltodict <https://github.com/martinblech/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``. Entity expansion and DTD resolution is disabled to avoid XML parsing vulnerabilities.
+``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 <https://dumps.wikimedia.org>`_ 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 <https://toml.io/>`_ as well. The ``yq`` package installs an executable, ``tomlq``, which uses the
-`toml library <https://github.com/uiri/toml>`_ to transcode TOML to JSON, then pipes it to ``jq``. Roundtrip transcoding
-is available with the ``tomlq --toml-output``/``tomlq -t`` option.
+`tomlkit library <https://github.com/sdispater/tomlkit>`_ 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
|
[-]
[+]
|
Changed |
_service:tar_git:yq-3.2.3.tar.gz/yq.egg-info/SOURCES.txt
^
|
@@ -4,16 +4,19 @@
MANIFEST.in
Makefile
README.rst
+SECURITY.md
common.mk
pyproject.toml
-setup.cfg
setup.py
.github/FUNDING.yml
.github/workflows/ci.yml
docs/changelog.rst
+docs/cli-doc-tomlq.txt
+docs/cli-doc-xq.txt
docs/cli-doc.txt
docs/conf.py
docs/index.rst
+docs/toc.html
test/cfn.yml
test/doc.yml
test/filter.jq
|
[-]
[+]
|
Changed |
_service:tar_git:yq-3.2.3.tar.gz/yq.egg-info/requires.txt
^
|
@@ -1,11 +1,11 @@
PyYAML>=5.3.1
xmltodict>=0.11.0
-toml>=0.10.0
+tomlkit>=0.11.6
argcomplete>=1.8.1
[tests]
coverage
-flake8
wheel
build
+ruff
mypy
|
[-]
[+]
|
Changed |
_service:tar_git:yq-3.2.3.tar.gz/yq/__init__.py
^
|
@@ -131,8 +131,8 @@
yq_args = dict(input_format=input_format, program_name=program_name, jq_args=jq_args, **vars(args))
if in_place:
- if args.output_format not in {"yaml", "annotated_yaml"}:
- sys.exit("{}: -i/--in-place can only be used with -y/-Y".format(program_name))
+ if args.output_format not in {"yaml", "annotated_yaml", "toml"}:
+ sys.exit("{}: -i/--in-place can only be used with -y/-Y/-t".format(program_name))
input_streams = yq_args.pop("input_streams")
if len(input_streams) == 1 and input_streams[0].name == "<stdin>":
msg = "{}: -i/--in-place can only be used with filename arguments, not on standard input"
@@ -183,6 +183,7 @@
width=None,
indentless_lists=False,
xml_root=None,
+ xml_item_depth=0,
xml_dtd=False,
xml_force_list=frozenset(),
explicit_start=False,
@@ -242,13 +243,20 @@
elif input_format == "xml":
import xmltodict
- doc = xmltodict.parse(input_stream.read(), disable_entities=True, force_list=xml_force_list)
+ if xml_item_depth != 0:
+ raise Exception("xml_item_depth is not supported with xq -x")
+
+ doc = xmltodict.parse(
+ input_stream.buffer if isinstance(input_stream, io.TextIOWrapper) else input_stream.read(),
+ disable_entities=True,
+ force_list=xml_force_list,
+ )
json.dump(doc, json_buffer, cls=JSONDateTimeEncoder)
json_buffer.write("\n")
elif input_format == "toml":
- import toml
+ import tomlkit
- doc = toml.load(input_stream) # type: ignore
+ doc = tomlkit.load(input_stream) # type: ignore
json.dump(doc, json_buffer, cls=JSONDateTimeEncoder)
json_buffer.write("\n")
else:
@@ -295,13 +303,13 @@
raise
output_stream.write(b"\n" if sys.version_info < (3, 0) else "\n")
elif output_format == "toml":
- import toml
+ import tomlkit
for doc in decode_docs(jq_out, json_decoder):
if not isinstance(doc, dict):
msg = "{}: Error converting JSON to TOML: cannot represent non-object types at top level."
exit_func(msg.format(program_name))
- toml.dump(doc, output_stream)
+ tomlkit.dump(doc, output_stream)
else:
if input_format == "yaml":
loader_class = get_loader(
@@ -320,17 +328,26 @@
elif input_format == "xml":
import xmltodict
+ def emit_entry(path, entry):
+ json.dump(entry, jq.stdin) # type: ignore
+ jq.stdin.write("\n") # type: ignore
+ return True
+
for input_stream in input_streams:
- json.dump(
- xmltodict.parse(input_stream.read(), disable_entities=True, force_list=xml_force_list),
- jq.stdin, # type: ignore
+ doc = xmltodict.parse(
+ input_stream.buffer if isinstance(input_stream, io.TextIOWrapper) else input_stream.read(),
+ disable_entities=True,
+ force_list=xml_force_list,
+ item_depth=xml_item_depth,
+ item_callback=emit_entry,
)
- jq.stdin.write("\n") # type: ignore
+ if doc:
+ emit_entry(None, doc)
elif input_format == "toml":
- import toml
+ import tomlkit
for input_stream in input_streams:
- json.dump(toml.load(input_stream), jq.stdin, cls=JSONDateTimeEncoder) # type: ignore
+ json.dump(tomlkit.load(input_stream), jq.stdin, cls=JSONDateTimeEncoder) # type: ignore
jq.stdin.write("\n") # type: ignore
else:
raise Exception("Unknown input format")
|
[-]
[+]
|
Changed |
_service:tar_git:yq-3.2.3.tar.gz/yq/parser.py
^
|
@@ -38,7 +38,8 @@
def get_parser(program_name, description):
# By default suppress these help strings and only enable them in the specific programs.
yaml_output_help, yaml_roundtrip_help, width_help, indentless_help, grammar_help = [argparse.SUPPRESS] * 5
- xml_output_help, xml_dtd_help, xml_root_help, xml_force_list_help = [argparse.SUPPRESS] * 4
+ explicit_start_help, explicit_end_help = [argparse.SUPPRESS] * 2
+ xml_output_help, xml_item_depth_help, xml_dtd_help, xml_root_help, xml_force_list_help = [argparse.SUPPRESS] * 5
toml_output_help = argparse.SUPPRESS
if program_name == "yq":
@@ -51,20 +52,21 @@
"is incompatible with jq filters that do not expect these extra items."
)
width_help = "When using --yaml-output, specify string wrap width"
- indentless_help = "When using --yaml-output, indent block style lists (sequences) " "with 0 spaces instead of 2"
+ indentless_help = "When using --yaml-output, indent block style lists (sequences) with 0 spaces instead of 2"
grammar_help = (
"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."
)
+ explicit_start_help = 'When using --yaml-output, always emit explicit document start ("---")'
+ explicit_end_help = 'When using --yaml-output, always emit explicit document end ("...")'
elif program_name == "xq":
current_language = "XML"
xml_output_help = "Transcode jq JSON output back into XML and emit it"
+ xml_item_depth_help = "Specify depth of items to emit (default 0; use a positive integer to stream large docs)"
xml_dtd_help = "Preserve XML Document Type Definition (disables streaming of multiple docs)"
xml_root_help = "When transcoding back to XML, envelope the output in an element with this name"
- xml_force_list_help = (
- "Tag name to pass to force_list parameter of xmltodict.parse(). " "Can be used multiple times."
- )
+ xml_force_list_help = "Emit a list for elements with this name even if they occur only once (option can repeat)"
elif program_name == "tomlq":
current_language = "TOML"
toml_output_help = "Transcode jq JSON output back into TOML and emit it"
@@ -100,16 +102,17 @@
)
parser.add_argument("--width", "-w", type=int, help=width_help)
parser.add_argument("--indentless-lists", "--indentless", action="store_true", help=indentless_help)
- parser.add_argument("--explicit-start", action="store_true", help=argparse.SUPPRESS)
- parser.add_argument("--explicit-end", action="store_true", help=argparse.SUPPRESS)
+ parser.add_argument("--explicit-start", action="store_true", help=explicit_start_help)
+ parser.add_argument("--explicit-end", action="store_true", help=explicit_end_help)
parser.add_argument("--no-expand-aliases", action="store_false", dest="expand_aliases", help=argparse.SUPPRESS)
parser.add_argument("--max-expansion-factor", type=int, default=1024, help=argparse.SUPPRESS)
parser.add_argument(
"--xml-output", "-x", dest="output_format", action="store_const", const="xml", help=xml_output_help
)
+ parser.add_argument("--xml-item-depth", type=int, default=0, help=xml_item_depth_help, metavar="123")
parser.add_argument("--xml-dtd", action="store_true", help=xml_dtd_help)
parser.add_argument("--xml-root", help=xml_root_help)
- parser.add_argument("--xml-force-list", action="append", help=xml_force_list_help)
+ parser.add_argument("--xml-force-list", action="append", help=xml_force_list_help, metavar="ELT")
parser.add_argument(
"--toml-output", "-t", dest="output_format", action="store_const", const="toml", help=toml_output_help
)
|
[-]
[+]
|
Changed |
_service:tar_git:yq-3.2.3.tar.gz/yq/version.py
^
|
@@ -1,4 +1,4 @@
# file generated by setuptools_scm
# don't change, don't track in version control
-__version__ = version = '3.1.1'
-__version_tuple__ = version_tuple = (3, 1, 1)
+__version__ = version = '3.2.3'
+__version_tuple__ = version_tuple = (3, 2, 3)
|
[-]
[+]
|
Added |
_service:tar_git:yq.yaml
^
|
@@ -0,0 +1,51 @@
+Name: yq
+Summary: Command-line YAML/XML processor - jq wrapper for YAML/XML documents
+# 2.13 needs pyyaml = 5.3.1, SFOS 4.5 has 5.3 at the moment
+#Version: 2.13.0
+Version: 3.2.3
+Release: 0
+Group: Applications
+License: Apache-2.0
+URL: https://pypi.org/project/yq/
+Sources:
+ - https://files.pythonhosted.org/packages/source/y/%{name}/%{name}-%{version}.tar.gz
+Description: |
+
+ yq takes YAML input, converts it to JSON, and pipes it to jq
+
+ %if "%{?vendor}" == "chum"
+ Title: yq
+ Type: console-application
+ Categories:
+ - Utility
+ Custom:
+ PackagingRepo: https://github.com/sailfishos-chum/python3-yq
+ Links:
+ Homepage: https://pypi.org/project/yq/
+ Help: https://pypi.org/project/yq/#description
+ %endif
+
+SetupOptions: '-q -n %{name}-%{version}'
+BuildArch: noarch
+Configure: none
+Builder: python3
+PkgBR:
+ - python3-setuptools_scm >= 3.4.3
+ - python3-yaml >= 3.5.1
+ - python3-rpm-macros
+PkgConfigBR:
+ - python3
+NoFiles: true
+SubPackages:
+ - Name: python3-%{name}
+ AsWholeName: true
+ Summary: Command-line YAML/XML processor - jq wrapper for YAML/XML documents
+ Group: Development/Libraries
+ Requires:
+ - jq
+ Files:
+ - '%{_bindir}/tomlq'
+ - '%{_bindir}/xq'
+ - '%{_bindir}/yq'
+ - '%{python3_sitelib}/%{name}-*.egg-info/'
+ - '%{python3_sitelib}/%{name}/'
|