Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-yq for openSUSE:Factory checked in at 2023-03-02 23:03:40 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-yq (Old) and /work/SRC/openSUSE:Factory/.python-yq.new.31432 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-yq" Thu Mar 2 23:03:40 2023 rev:11 rq:1068548 version:3.1.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-yq/python-yq.changes 2022-07-26 19:45:45.607420997 +0200 +++ /work/SRC/openSUSE:Factory/.python-yq.new.31432/python-yq.changes 2023-03-02 23:04:13.384069610 +0100 @@ -1,0 +2,7 @@ +Wed Mar 1 20:21:02 UTC 2023 - Dirk Müller <dmuel...@suse.com> + +- update to 3.1.1: + * Handle TOML datetimes. Fixes #160 + * Test and documentation improvements + +------------------------------------------------------------------- Old: ---- yq-3.1.0.tar.gz New: ---- yq-3.1.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-yq.spec ++++++ --- /var/tmp/diff_new_pack.8rEL70/_old 2023-03-02 23:04:14.040072887 +0100 +++ /var/tmp/diff_new_pack.8rEL70/_new 2023-03-02 23:04:14.044072907 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-yq # -# Copyright (c) 2022 SUSE LLC +# Copyright (c) 2023 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,7 +19,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python2 1 Name: python-yq -Version: 3.1.0 +Version: 3.1.1 Release: 0 Summary: Command-line YAML processor - jq wrapper for YAML documents License: Apache-2.0 ++++++ yq-3.1.0.tar.gz -> yq-3.1.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-3.1.0/.github/workflows/ci.yml new/yq-3.1.1/.github/workflows/ci.yml --- old/yq-3.1.0/.github/workflows/ci.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/yq-3.1.1/.github/workflows/ci.yml 2023-02-22 06:14:38.000000000 +0100 @@ -0,0 +1,33 @@ +name: Test suite + +on: [push, pull_request] + +jobs: + unit_tests: + runs-on: ${{matrix.os}} + strategy: + max-parallel: 8 + matrix: + os: [ubuntu-18.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 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-3.1.0/.github/workflows/pythonpackage.yml new/yq-3.1.1/.github/workflows/pythonpackage.yml --- old/yq-3.1.0/.github/workflows/pythonpackage.yml 2022-07-05 20:34:10.000000000 +0200 +++ new/yq-3.1.1/.github/workflows/pythonpackage.yml 1970-01-01 01:00:00.000000000 +0100 @@ -1,28 +0,0 @@ -name: Python package - -on: [push, pull_request] - -jobs: - build: - runs-on: ${{matrix.os}} - strategy: - max-parallel: 8 - matrix: - os: [ubuntu-18.04, ubuntu-20.04, macos-10.15] - python-version: ["3.7", "3.8", "3.9", "3.10"] - - steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install - run: | - [[ $(uname) == Linux ]] && sudo apt-get install --yes jq - [[ $(uname) == Darwin ]] && brew install jq - pip install coverage wheel - make install - - name: Test - run: | - make test diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-3.1.0/Changes.rst new/yq-3.1.1/Changes.rst --- old/yq-3.1.0/Changes.rst 2022-07-24 19:50:54.000000000 +0200 +++ new/yq-3.1.1/Changes.rst 2023-02-22 06:26:45.000000000 +0100 @@ -1,3 +1,10 @@ +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) =============================== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-3.1.0/Makefile new/yq-3.1.1/Makefile --- old/yq-3.1.0/Makefile 2021-12-25 21:38:42.000000000 +0100 +++ new/yq-3.1.1/Makefile 2023-02-22 06:14:38.000000000 +0100 @@ -1,24 +1,24 @@ -test_deps: - pip install .[tests] +SHELL=/bin/bash -lint: test_deps - flake8 $$(python setup.py --name) +lint: + flake8 + mypy --install-types --non-interactive --check-untyped-defs $$(dirname */__init__.py) -test: test_deps lint - coverage run --source=$$(python setup.py --name) ./test/test.py -v +test: + python ./test/test.py -v + +init_docs: + cd docs; sphinx-quickstart docs: sphinx-build docs docs/html -install: clean - pip install build +install: + -rm -rf dist + python -m pip install build python -m build - pip install --upgrade dist/*.whl - -clean: - -rm -rf build dist - -rm -rf *.egg-info + python -m pip install --upgrade $$(echo dist/*.whl)[tests] -.PHONY: lint test test_deps docs install clean +.PHONY: test lint release docs include common.mk diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-3.1.0/PKG-INFO new/yq-3.1.1/PKG-INFO --- old/yq-3.1.0/PKG-INFO 2022-07-24 19:51:29.951044300 +0200 +++ new/yq-3.1.1/PKG-INFO 2023-02-22 06:27:05.400125300 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: yq -Version: 3.1.0 +Version: 3.1.1 Summary: Command-line YAML/XML processor - jq wrapper for YAML/XML documents Home-page: https://github.com/kislyuk/yq Author: Andrey Kislyuk @@ -29,7 +29,7 @@ ------------ :: - pip3 install yq + pip install yq Before using ``yq``, you also have to install its dependency, ``jq``. See the `jq installation instructions <https://stedolan.github.io/jq/download/>`_ for details and directions specific to your platform. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-3.1.0/README.rst new/yq-3.1.1/README.rst --- old/yq-3.1.0/README.rst 2021-06-21 16:10:07.000000000 +0200 +++ new/yq-3.1.1/README.rst 2023-02-22 06:14:38.000000000 +0100 @@ -5,7 +5,7 @@ ------------ :: - pip3 install yq + pip install yq Before using ``yq``, you also have to install its dependency, ``jq``. See the `jq installation instructions <https://stedolan.github.io/jq/download/>`_ for details and directions specific to your platform. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-3.1.0/docs/cli-doc.txt new/yq-3.1.1/docs/cli-doc.txt --- old/yq-3.1.0/docs/cli-doc.txt 2022-07-24 19:50:54.000000000 +0200 +++ new/yq-3.1.1/docs/cli-doc.txt 2023-02-22 06:26:45.000000000 +0100 @@ -1,6 +1,6 @@ usage: yq [options] <jq filter> [input file...] [--indentless-lists] [--in-place] [--version] - [jq_filter] [files [files ...]] + [jq_filter] [files ...] yq: Command-line YAML processor - jq wrapper for YAML documents @@ -28,9 +28,9 @@ jq - commandline JSON processor [version 1.6] -Usage: /Users/andrey.kislyuk/.asdf/installs/jq/1.6/bin/jq [options] <jq filter> [file...] - /Users/andrey.kislyuk/.asdf/installs/jq/1.6/bin/jq [options] --args <jq filter> [strings...] - /Users/andrey.kislyuk/.asdf/installs/jq/1.6/bin/jq [options] --jsonargs <jq filter> [JSON_TEXTS...] +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 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-3.1.0/pyproject.toml new/yq-3.1.1/pyproject.toml --- old/yq-3.1.0/pyproject.toml 1970-01-01 01:00:00.000000000 +0100 +++ new/yq-3.1.1/pyproject.toml 2023-02-22 06:14:38.000000000 +0100 @@ -0,0 +1,9 @@ +[tool.black] +line-length = 120 +[tool.isort] +profile = "black" +line_length = 120 +skip_gitignore = true +[[tool.mypy.overrides]] +module = "argcomplete.*" +ignore_missing_imports = true \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-3.1.0/setup.cfg new/yq-3.1.1/setup.cfg --- old/yq-3.1.0/setup.cfg 2022-07-24 19:51:29.952011300 +0200 +++ new/yq-3.1.1/setup.cfg 2023-02-22 06:27:05.400349600 +0100 @@ -3,7 +3,9 @@ [flake8] max-line-length = 120 -ignore = E302, E305, E401 +extend-ignore = E203 +per-file-ignores = + yq/__init__.py:F401 [egg_info] tag_build = diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-3.1.0/setup.py new/yq-3.1.1/setup.py --- old/yq-3.1.0/setup.py 2022-07-24 19:50:48.000000000 +0200 +++ new/yq-3.1.1/setup.py 2023-02-22 06:26:16.000000000 +0100 @@ -1,10 +1,10 @@ #!/usr/bin/env python -from setuptools import setup, find_packages +from setuptools import find_packages, setup setup( name="yq", - version="3.1.0", + version="3.1.1", url="https://github.com/kislyuk/yq", license="Apache Software License", author="Andrey Kislyuk", @@ -15,28 +15,26 @@ use_scm_version={ "write_to": "yq/version.py", }, - setup_requires=['setuptools_scm >= 3.4.3'], + setup_requires=["setuptools_scm >= 3.4.3"], install_requires=[ "PyYAML >= 5.3.1", "xmltodict >= 0.11.0", "toml >= 0.10.0", - "argcomplete >= 1.8.1" + "argcomplete >= 1.8.1", ], extras_require={ "tests": [ "coverage", "flake8", - "wheel" + "wheel", + "build", + "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' - ], + "console_scripts": ["yq=yq:cli", "xq=yq:xq_cli", "tomlq=yq:tq_cli"], }, test_suite="test", classifiers=[ @@ -51,6 +49,6 @@ "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", - "Topic :: Software Development :: Libraries :: Python Modules" - ] + "Topic :: Software Development :: Libraries :: Python Modules", + ], ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-3.1.0/test/test.py new/yq-3.1.1/test/test.py --- old/yq-3.1.0/test/test.py 2022-07-24 19:40:08.000000000 +0200 +++ new/yq-3.1.1/test/test.py 2023-02-22 06:16:29.000000000 +0100 @@ -1,9 +1,15 @@ #!/usr/bin/env python -import os, sys, unittest, tempfile, io, platform, subprocess, yaml +import io +import os +import platform +import subprocess +import sys +import tempfile +import unittest -sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) -from yq import yq, cli # noqa +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) +from yq import cli, yq # noqa USING_PYPY = True if platform.python_implementation() == "PyPy" else False @@ -41,6 +47,7 @@ lol10: &lol10 [*lol9,*lol9,*lol9,*lol9,*lol9,*lol9,*lol9,*lol9,*lol9] """ + class TestYq(unittest.TestCase): def run_yq(self, input_data, args, expect_exit_codes={os.EX_OK}, input_format="yaml"): stdin, stdout = sys.stdin, sys.stdout @@ -75,10 +82,14 @@ self.assertEqual(self.run_yq("- понеделÑник\n- вÑоÑник\n", ["-y", "."]), "- понеделÑник\n- вÑоÑник\n") def test_yq_err(self): - err = ('yq: Error running jq: ScannerError: while scanning for the next token\nfound character \'%\' that ' - 'cannot start any token\n in "<file>", line 1, column 3.') - err2 = ('yq: Error running jq: ScannerError: while scanning for the next token\nfound character that ' - 'cannot start any token\n in "<file>", line 1, column 3.') + err = ( + "yq: Error running jq: ScannerError: while scanning for the next token\nfound character '%' that " + 'cannot start any token\n in "<file>", line 1, column 3.' + ) + err2 = ( + "yq: Error running jq: ScannerError: while scanning for the next token\nfound character that " + 'cannot start any token\n in "<file>", line 1, column 3.' + ) self.run_yq("- %", ["."], expect_exit_codes={err, err2, 2}) def test_yq_arg_handling(self): @@ -104,24 +115,26 @@ def test_yq_arg_passthrough(self): self.assertEqual(self.run_yq("{}", ["--arg", "foo", "bar", "--arg", "x", "y", "--indent", "4", "."]), "") - self.assertEqual(self.run_yq("{}", ["--arg", "foo", "bar", "--arg", "x", "y", "-y", "--indent", "4", ".x=$x"]), - "x: y\n") + self.assertEqual( + self.run_yq("{}", ["--arg", "foo", "bar", "--arg", "x", "y", "-y", "--indent", "4", ".x=$x"]), "x: y\n" + ) err = "yq: Error running jq: BrokenPipeError: [Errno 32] Broken pipe" + (": '<fdopen>'." if USING_PYPY else ".") self.run_yq("{}", ["--indent", "9", "."], expect_exit_codes={err, 2}) - self.assertEqual(self.run_yq('', ["true", "-y", "-rn"]), "true\n...\n") + self.assertEqual(self.run_yq("", ["true", "-y", "-rn"]), "true\n...\n") with tempfile.NamedTemporaryFile() as tf, tempfile.TemporaryFile() as tf2: - tf.write(b'.a') + tf.write(b".a") tf.seek(0) tf2.write(b'{"a": 1}') for arg in "--from-file", "-f": tf2.seek(0) - self.assertEqual(self.run_yq("", ["-y", arg, tf.name, self.fd_path(tf2)]), '1\n...\n') + self.assertEqual(self.run_yq("", ["-y", arg, tf.name, self.fd_path(tf2)]), "1\n...\n") @unittest.skipIf(subprocess.check_output(["jq", "--version"]) < b"jq-1.6", "Test options introduced in jq 1.6") def test_jq16_arg_passthrough(self): - self.assertEqual(self.run_yq("{}", ["--indentless", "-y", ".a=$ARGS.positional", "--args", "a", "b"]), - "a:\n- a\n- b\n") + self.assertEqual( + 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"]), "") @@ -145,13 +158,14 @@ tf.seek(0) tf2.write(b'{"a": 1}') tf2.seek(0) - self.assertEqual(self.run_yq("", ["-y", ".a", self.fd_path(tf), self.fd_path(tf2)]), 'b\n--- 1\n...\n') + self.assertEqual(self.run_yq("", ["-y", ".a", self.fd_path(tf), self.fd_path(tf2)]), "b\n--- 1\n...\n") def test_datetimes(self): self.assertEqual(self.run_yq("- 2016-12-20T22:07:36Z\n", ["."]), "") self.assertEqual(self.run_yq("- 2016-12-20T22:07:36Z\n", ["-y", "."]), "- '2016-12-20T22:07:36Z'\n") - self.assertEqual(self.run_yq("- 2016-12-20T22:07:36Z\n", ["-y", "--yml-out-ver=1.2", "."]), - "- 2016-12-20T22:07:36Z\n") + self.assertEqual( + self.run_yq("- 2016-12-20T22:07:36Z\n", ["-y", "--yml-out-ver=1.2", "."]), "- 2016-12-20T22:07:36Z\n" + ) self.assertEqual(self.run_yq("2016-12-20", ["."]), "") self.assertEqual(self.run_yq("2016-12-20", ["-y", "."]), "'2016-12-20'\n") self.assertEqual(self.run_yq("2016-12-20", ["-y", "--yml-out-ver=1.2", "."]), "2016-12-20\n...\n") @@ -164,7 +178,7 @@ with tempfile.TemporaryFile() as tf: tf.write(yaml_with_tags.encode()) tf.seek(0) - self.assertEqual(self.run_yq("", ["-y", ".xyz.foo", self.fd_path(tf)]), 'bar\n...\n') + self.assertEqual(self.run_yq("", ["-y", ".xyz.foo", self.fd_path(tf)]), "bar\n...\n") def test_roundtrip_yaml(self): cfn_filename = os.path.join(os.path.dirname(__file__), "cfn.yml") @@ -178,15 +192,15 @@ tf2.write(b"- foo\n- bar\n") tf2.seek(0) self.run_yq("", ["-i", "-y", ".[0]", tf.name, tf2.name]) - self.assertEqual(tf.read(), b'foo\n...\n') - self.assertEqual(tf2.read(), b'foo\n...\n') + self.assertEqual(tf.read(), b"foo\n...\n") + self.assertEqual(tf2.read(), b"foo\n...\n") # Files do not get overwritten on error (DeferredOutputStream logic) self.run_yq("", ["-i", "-y", tf.name, tf2.name], expect_exit_codes=[3]) tf.seek(0) tf2.seek(0) - self.assertEqual(tf.read(), b'foo\n...\n') - self.assertEqual(tf2.read(), b'foo\n...\n') + self.assertEqual(tf.read(), b"foo\n...\n") + self.assertEqual(tf2.read(), b"foo\n...\n") def test_explicit_doc_markers(self): test_doc = os.path.join(os.path.dirname(__file__), "doc.yml") @@ -196,49 +210,57 @@ def test_xq(self): self.assertEqual(self.run_yq("<foo/>", ["."], 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.assertEqual(self.run_yq("<foo/>", ["-x", ".foo.x=1"], input_format="xml"), "<foo>\n <x>1</x>\n</foo>\n") - self.assertEqual(self.run_yq("<a><b/></a>", ["-y", "."], input_format="xml"), - "a:\n b: null\n") - self.assertEqual(self.run_yq("<a><b/></a>", ["-y", "--xml-force-list", "b", "."], input_format="xml"), - "a:\n b:\n - null\n") + self.assertEqual(self.run_yq("<a><b/></a>", ["-y", "."], input_format="xml"), "a:\n b: null\n") + self.assertEqual( + self.run_yq("<a><b/></a>", ["-y", "--xml-force-list", "b", "."], input_format="xml"), + "a:\n b:\n - null\n", + ) with tempfile.TemporaryFile() as tf, tempfile.TemporaryFile() as tf2: - tf.write(b'<a><b/></a>') + tf.write(b"<a><b/></a>") tf.seek(0) - tf2.write(b'<a><c/></a>') + tf2.write(b"<a><c/></a>") tf2.seek(0) - self.assertEqual(self.run_yq("", ["-x", ".a", self.fd_path(tf), self.fd_path(tf2)], input_format="xml"), - '<b></b>\n<c></c>\n') - err = ("yq: Error converting JSON to XML: cannot represent non-object types at top level. " - "Use --xml-root=name to envelope your output with a root element.") + self.assertEqual( + self.run_yq("", ["-x", ".a", self.fd_path(tf), self.fd_path(tf2)], input_format="xml"), + "<b></b>\n<c></c>\n", + ) + err = ( + "yq: Error converting JSON to XML: cannot represent non-object types at top level. " + "Use --xml-root=name to envelope your output with a root element." + ) self.run_yq("[1]", ["-x", "."], expect_exit_codes=[err]) def test_xq_dtd(self): with tempfile.TemporaryFile() as tf: tf.write(b'<a><b c="d">e</b><b>f</b></a>') tf.seek(0) - self.assertEqual(self.run_yq("", ["-x", ".a", self.fd_path(tf)], input_format="xml"), - '<b c="d">e</b><b>f</b>\n') + self.assertEqual( + self.run_yq("", ["-x", ".a", self.fd_path(tf)], input_format="xml"), '<b c="d">e</b><b>f</b>\n' + ) tf.seek(0) - self.assertEqual(self.run_yq("", ["-x", "--xml-dtd", ".", self.fd_path(tf)], input_format="xml"), - '<?xml version="1.0" encoding="utf-8"?>\n<a>\n <b c="d">e</b>\n <b>f</b>\n</a>\n') + self.assertEqual( + self.run_yq("", ["-x", "--xml-dtd", ".", self.fd_path(tf)], input_format="xml"), + '<?xml version="1.0" encoding="utf-8"?>\n<a>\n <b c="d">e</b>\n <b>f</b>\n</a>\n', + ) tf.seek(0) self.assertEqual( self.run_yq("", ["-x", "--xml-dtd", "--xml-root=g", ".a", self.fd_path(tf)], input_format="xml"), - '<?xml version="1.0" encoding="utf-8"?>\n<g>\n <b c="d">e</b>\n <b>f</b>\n</g>\n' + '<?xml version="1.0" encoding="utf-8"?>\n<g>\n <b c="d">e</b>\n <b>f</b>\n</g>\n', ) def test_tomlq(self): self.assertEqual(self.run_yq("[foo]\nbar = 1", ["."], input_format="toml"), "") self.assertEqual(self.run_yq("[foo]\nbar = 1", ["-t", ".foo"], input_format="toml"), "bar = 1\n") + self.assertEqual(self.run_yq("[foo]\nbar = 2020-02-20", ["."], input_format="toml"), "") def test_abbrev_opt_collisions(self): with tempfile.TemporaryFile() as tf, tempfile.TemporaryFile() as tf2: self.assertEqual( self.run_yq("", ["-y", "-e", "--slurp", ".[0] == .[1]", "-", self.fd_path(tf), self.fd_path(tf2)]), - "true\n...\n" + "true\n...\n", ) def test_entity_expansion_defense(self): @@ -252,12 +274,13 @@ self.assertEqual(self.run_yq(set_yaml, ["."]), "") self.assertEqual( self.run_yq(set_yaml, ["-y", "."]), - "example:\n Boston Red Sox: null\n Detroit Tigers: null\n New York Yankees: null\n" + "example:\n Boston Red Sox: null\n Detroit Tigers: null\n New York Yankees: null\n", ) def test_yaml_merge(self): - self.assertEqual(self.run_yq("a: &b\n c: d\ne:\n <<: *b\n g: h", ["-y", "."]), - "a:\n c: d\ne:\n c: d\n g: h\n") + self.assertEqual( + self.run_yq("a: &b\n c: d\ne:\n <<: *b\n g: h", ["-y", "."]), "a:\n c: d\ne:\n c: d\n g: h\n" + ) def test_yaml_1_2(self): self.assertEqual(self.run_yq("11:12:13", ["."]), "") @@ -288,5 +311,6 @@ """YAML 1.2 octals not yet implemented""" self.assertEqual(self.run_yq("on: -012345", ["-y", "--yml-out-ver=1.2", "."]), "on: -12345\n") -if __name__ == '__main__': + +if __name__ == "__main__": unittest.main() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-3.1.0/yq/__init__.py new/yq-3.1.1/yq/__init__.py --- old/yq-3.1.0/yq/__init__.py 2022-07-23 01:39:38.000000000 +0200 +++ new/yq-3.1.1/yq/__init__.py 2023-02-22 06:19:50.000000000 +0100 @@ -7,38 +7,49 @@ # PYTHON_ARGCOMPLETE_OK -import os, sys, argparse, subprocess, json, io -from datetime import datetime, date, time +import argparse +import io +import json +import os +import subprocess +import sys +from datetime import date, datetime, time -import yaml, argcomplete +import argcomplete +import yaml -from .parser import get_parser, jq_arg_spec -from .loader import get_loader from .dumper import get_dumper +from .loader import get_loader +from .parser import get_parser, jq_arg_spec try: from .version import version as __version__ except ImportError: __version__ = "0.0.0" + class JSONDateTimeEncoder(json.JSONEncoder): def default(self, o): if isinstance(o, (datetime, date, time)): return o.isoformat() return json.JSONEncoder.default(self, o) + def decode_docs(jq_output, json_decoder): while jq_output: doc, pos = json_decoder.raw_decode(jq_output) - jq_output = jq_output[pos + 1:] + jq_output = jq_output[pos + 1 :] yield doc + def xq_cli(): cli(input_format="xml", program_name="xq") + def tq_cli(): cli(input_format="toml", program_name="tomlq") + class DeferredOutputStream: def __init__(self, name, mode="w"): self.name = name @@ -62,6 +73,7 @@ def __getattr__(self, a): return getattr(self.fh, a) + def cli(args=None, input_format="yaml", program_name="yq"): parser = get_parser(program_name, __doc__) argcomplete.autocomplete(parser) @@ -101,9 +113,9 @@ else: jq_filter_arg_loc = len(jq_args) if "--args" in jq_args: - jq_filter_arg_loc = jq_args.index('--args') + 1 + jq_filter_arg_loc = jq_args.index("--args") + 1 elif "--jsonargs" in jq_args: - jq_filter_arg_loc = jq_args.index('--jsonargs') + 1 + jq_filter_arg_loc = jq_args.index("--jsonargs") + 1 jq_args.insert(jq_filter_arg_loc, args.jq_filter) if null_input: args.input_streams.insert(0, open(os.devnull)) @@ -126,15 +138,18 @@ msg = "{}: -i/--in-place can only be used with filename arguments, not on standard input" sys.exit(msg.format(program_name)) for i, input_stream in enumerate(input_streams): + def exit_handler(arg=None): if arg: sys.exit(arg) + if i < len(input_streams): yq_args["exit_func"] = exit_handler yq(input_streams=[input_stream], output_stream=DeferredOutputStream(input_stream.name), **yq_args) else: yq(**yq_args) + def load_yaml_docs(in_stream, out_stream, jq, loader_class, max_expansion_factor, exit_func, prog): loader = loader_class(in_stream) @@ -158,10 +173,27 @@ finally: loader.dispose() -def yq(input_streams=None, output_stream=None, input_format="yaml", output_format="json", - program_name="yq", width=None, indentless_lists=False, xml_root=None, xml_dtd=False, xml_force_list=frozenset(), - explicit_start=False, explicit_end=False, expand_merge_keys=True, expand_aliases=True, - max_expansion_factor=1024, yaml_output_grammar_version="1.1", jq_args=frozenset(), exit_func=None): + +def yq( + input_streams=None, + output_stream=None, + input_format="yaml", + output_format="json", + program_name="yq", + width=None, + indentless_lists=False, + xml_root=None, + xml_dtd=False, + xml_force_list=frozenset(), + explicit_start=False, + explicit_end=False, + expand_merge_keys=True, + expand_aliases=True, + max_expansion_factor=1024, + yaml_output_grammar_version="1.1", + jq_args=frozenset(), + exit_func=None, +): if not input_streams: input_streams = [sys.stdin] if not output_stream: @@ -173,11 +205,13 @@ try: # Notes: universal_newlines is just a way to induce subprocess to make stdin a text buffer and encode it for us; # close_fds must be false for command substitution to work (yq . t.yml --slurpfile t <(yq . t.yml)) - jq = subprocess.Popen(["jq"] + list(jq_args), - stdin=subprocess.PIPE, - stdout=subprocess.PIPE if converting_output else None, - close_fds=False, - universal_newlines=True) + jq = subprocess.Popen( + ["jq"] + list(jq_args), + stdin=subprocess.PIPE, + stdout=subprocess.PIPE if converting_output else None, + close_fds=False, + universal_newlines=True, + ) except OSError as e: msg = "{}: Error starting jq: {}: {}. Is jq installed and available on PATH?" exit_func(msg.format(program_name, type(e).__name__, e)) @@ -191,18 +225,30 @@ json_buffer = io.StringIO() for input_stream in input_streams: if input_format == "yaml": - loader_class = get_loader(use_annotations=use_annotations, expand_aliases=expand_aliases, - expand_merge_keys=expand_merge_keys) - load_yaml_docs(in_stream=input_stream, out_stream=json_buffer, jq=None, loader_class=loader_class, - max_expansion_factor=max_expansion_factor, exit_func=exit_func, prog=program_name) + loader_class = get_loader( + use_annotations=use_annotations, + expand_aliases=expand_aliases, + expand_merge_keys=expand_merge_keys, + ) + load_yaml_docs( + in_stream=input_stream, + out_stream=json_buffer, + jq=None, + loader_class=loader_class, + max_expansion_factor=max_expansion_factor, + exit_func=exit_func, + prog=program_name, + ) elif input_format == "xml": import xmltodict + doc = xmltodict.parse(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 - doc = toml.load(input_stream) + + doc = toml.load(input_stream) # type: ignore json.dump(doc, json_buffer, cls=JSONDateTimeEncoder) json_buffer.write("\n") else: @@ -210,24 +256,38 @@ jq_out, jq_err = jq.communicate(json_buffer.getvalue()) json_decoder = json.JSONDecoder() if output_format == "yaml" or output_format == "annotated_yaml": - dumper_class = get_dumper(use_annotations=use_annotations, indentless=indentless_lists, - grammar_version=yaml_output_grammar_version) - yaml.dump_all(decode_docs(jq_out, json_decoder), stream=output_stream, Dumper=dumper_class, - width=width, allow_unicode=True, default_flow_style=False, - explicit_start=explicit_start, explicit_end=explicit_end) + dumper_class = get_dumper( + use_annotations=use_annotations, + indentless=indentless_lists, + grammar_version=yaml_output_grammar_version, + ) + yaml.dump_all( + decode_docs(jq_out, json_decoder), + stream=output_stream, + Dumper=dumper_class, + width=width, + allow_unicode=True, + default_flow_style=False, + explicit_start=explicit_start, + explicit_end=explicit_end, + ) elif output_format == "xml": import xmltodict + for doc in decode_docs(jq_out, json_decoder): if xml_root: - doc = {xml_root: doc} + doc = {xml_root: doc} # type: ignore elif not isinstance(doc, dict): - msg = ("{}: Error converting JSON to XML: cannot represent non-object types at top level. " - "Use --xml-root=name to envelope your output with a root element.") + msg = ( + "{}: Error converting JSON to XML: cannot represent non-object types at top level. " + "Use --xml-root=name to envelope your output with a root element." + ) exit_func(msg.format(program_name)) full_document = True if xml_dtd else False try: - xmltodict.unparse(doc, output=output_stream, full_document=full_document, pretty=True, - indent=" ") + xmltodict.unparse( + doc, output=output_stream, full_document=full_document, pretty=True, indent=" " + ) except ValueError as e: if "Document must have exactly one root" in str(e): raise Exception(str(e) + " Use --xml-root=name to envelope your output with a root element") @@ -236,6 +296,7 @@ output_stream.write(b"\n" if sys.version_info < (3, 0) else "\n") elif output_format == "toml": import toml + 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." @@ -243,27 +304,39 @@ toml.dump(doc, output_stream) else: if input_format == "yaml": - loader_class = get_loader(use_annotations=False, expand_aliases=expand_aliases, - expand_merge_keys=expand_merge_keys) + loader_class = get_loader( + use_annotations=False, expand_aliases=expand_aliases, expand_merge_keys=expand_merge_keys + ) for input_stream in input_streams: - load_yaml_docs(in_stream=input_stream, out_stream=jq.stdin, jq=jq, loader_class=loader_class, - max_expansion_factor=max_expansion_factor, exit_func=exit_func, prog=program_name) + load_yaml_docs( + in_stream=input_stream, + out_stream=jq.stdin, + jq=jq, + loader_class=loader_class, + max_expansion_factor=max_expansion_factor, + exit_func=exit_func, + prog=program_name, + ) elif input_format == "xml": import xmltodict + for input_stream in input_streams: - json.dump(xmltodict.parse(input_stream.read(), disable_entities=True, - force_list=xml_force_list), jq.stdin) - jq.stdin.write("\n") + json.dump( + xmltodict.parse(input_stream.read(), disable_entities=True, force_list=xml_force_list), + jq.stdin, # type: ignore + ) + jq.stdin.write("\n") # type: ignore elif input_format == "toml": import toml + for input_stream in input_streams: - json.dump(toml.load(input_stream), jq.stdin) - jq.stdin.write("\n") + json.dump(toml.load(input_stream), jq.stdin, cls=JSONDateTimeEncoder) # type: ignore + jq.stdin.write("\n") # type: ignore else: raise Exception("Unknown input format") try: - jq.stdin.close() + jq.stdin.close() # type: ignore except Exception: pass jq.wait() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-3.1.0/yq/__main__.py new/yq-3.1.1/yq/__main__.py --- old/yq-3.1.0/yq/__main__.py 2021-06-21 16:10:07.000000000 +0200 +++ new/yq-3.1.1/yq/__main__.py 2023-02-22 06:14:38.000000000 +0100 @@ -1,4 +1,4 @@ -from yq.__init__ import cli +from . import cli if __name__ == "__main__": cli() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-3.1.0/yq/dumper.py new/yq-3.1.1/yq/dumper.py --- old/yq-3.1.0/yq/dumper.py 2022-07-23 01:39:22.000000000 +0200 +++ new/yq-3.1.1/yq/dumper.py 2023-02-22 06:14:38.000000000 +0100 @@ -1,16 +1,19 @@ import re import yaml + +from .loader import hash_key, set_yaml_grammar + # try: # from yaml import CSafeDumper as default_dumper # except ImportError: # from yaml import SafeDumper as default_dumper -from .loader import hash_key, set_yaml_grammar class OrderedIndentlessDumper(yaml.SafeDumper): pass + class OrderedDumper(yaml.SafeDumper): def increase_indent(self, flow=False, indentless=False): return super(OrderedDumper, self).increase_indent(flow, False) @@ -18,9 +21,11 @@ def ignore_aliases(self, data): return True + yaml_value_annotation_re = re.compile(r"^__yq_(?P<type>tag|style)_(?P<key>.+)__$") yaml_item_annotation_re = re.compile(r"^__yq_(?P<type>tag|style)_(?P<key>\d+)_(?P<value>.+)__$") + def get_dumper(use_annotations=False, indentless=False, grammar_version="1.1"): # if not (use_annotations or indentless): # return default_dumper diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-3.1.0/yq/loader.py new/yq-3.1.1/yq/loader.py --- old/yq-3.1.0/yq/loader.py 2022-07-24 18:06:03.000000000 +0200 +++ new/yq-3.1.1/yq/loader.py 2023-02-22 06:14:38.000000000 +0100 @@ -3,87 +3,111 @@ from hashlib import sha224 import yaml -from yaml.tokens import (AliasToken, AnchorToken, ScalarToken, FlowMappingStartToken, FlowMappingEndToken, KeyToken, - ValueToken) +from yaml.tokens import ( + AliasToken, + AnchorToken, + FlowMappingEndToken, + FlowMappingStartToken, + KeyToken, + ScalarToken, + ValueToken, +) + try: from yaml import CSafeLoader as default_loader except ImportError: - from yaml import SafeLoader as default_loader + from yaml import SafeLoader as default_loader # type: ignore core_resolvers = { "1.1": [ { "tag": "tag:yaml.org,2002:bool", - "regexp": re.compile(r'''^(?:yes|Yes|YES|no|No|NO + "regexp": re.compile( + r"""^(?:yes|Yes|YES|no|No|NO |true|True|TRUE|false|False|FALSE - |on|On|ON|off|Off|OFF)$''', re.X), - "start_chars": list('yYnNtTfFoO') - }, { + |on|On|ON|off|Off|OFF)$""", + re.X, + ), + "start_chars": list("yYnNtTfFoO"), + }, + { "tag": "tag:yaml.org,2002:float", - "regexp": re.compile(r'''^(?:[-+]?(?:[0-9][0-9_]*)\.[0-9_]*(?:[eE][-+][0-9]+)? + "regexp": re.compile( + r"""^(?:[-+]?(?:[0-9][0-9_]*)\.[0-9_]*(?:[eE][-+][0-9]+)? |\.[0-9_]+(?:[eE][-+][0-9]+)? |[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]* |[-+]?\.(?:inf|Inf|INF) - |\.(?:nan|NaN|NAN))$''', re.X), - "start_chars": list('-+0123456789.') - }, { + |\.(?:nan|NaN|NAN))$""", + re.X, + ), + "start_chars": list("-+0123456789."), + }, + { "tag": "tag:yaml.org,2002:int", - "regexp": re.compile(r'''^(?:[-+]?0b[0-1_]+ + "regexp": re.compile( + r"""^(?:[-+]?0b[0-1_]+ |[-+]?0[0-7_]+ |[-+]?(?:0|[1-9][0-9_]*) |[-+]?0x[0-9a-fA-F_]+ - |[-+]?[1-9][0-9_]*(?::[0-5]?[0-9])+)$''', re.X), - "start_chars": list('-+0123456789') - }, { + |[-+]?[1-9][0-9_]*(?::[0-5]?[0-9])+)$""", + re.X, + ), + "start_chars": list("-+0123456789"), + }, + { "tag": "tag:yaml.org,2002:null", - "regexp": re.compile(r'''^(?: ~ + "regexp": re.compile( + r"""^(?: ~ |null|Null|NULL - | )$''', re.X), - "start_chars": ['~', 'n', 'N', ''] - }, { + | )$""", + re.X, + ), + "start_chars": ["~", "n", "N", ""], + }, + { "tag": "tag:yaml.org,2002:timestamp", - "regexp": re.compile(r'''^(?:[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] + "regexp": re.compile( + r"""^(?:[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] |[0-9][0-9][0-9][0-9] -[0-9][0-9]? -[0-9][0-9]? (?:[Tt]|[ \t]+)[0-9][0-9]? :[0-9][0-9] :[0-9][0-9] (?:\.[0-9]*)? - (?:[ \t]*(?:Z|[-+][0-9][0-9]?(?::[0-9][0-9])?))?)$''', re.X), - "start_chars": list('0123456789') - }, { - "tag": "tag:yaml.org,2002:value", - "regexp": re.compile(r'^(?:=)$'), - "start_chars": ['='] - } + (?:[ \t]*(?:Z|[-+][0-9][0-9]?(?::[0-9][0-9])?))?)$""", + re.X, + ), + "start_chars": list("0123456789"), + }, + {"tag": "tag:yaml.org,2002:value", "regexp": re.compile(r"^(?:=)$"), "start_chars": ["="]}, ], "1.2": [ { "tag": "tag:yaml.org,2002:bool", - "regexp": re.compile(r'^(?:|true|True|TRUE|false|False|FALSE)$', re.X), - "start_chars": list('tTfF') - }, { + "regexp": re.compile(r"^(?:|true|True|TRUE|false|False|FALSE)$", re.X), + "start_chars": list("tTfF"), + }, + { "tag": "tag:yaml.org,2002:int", - "regexp": re.compile(r'^(?:|0o[0-7]+|[-+]?(?:[0-9]+)|0x[0-9a-fA-F]+)$', re.X), - "start_chars": list('-+0123456789') - }, { + "regexp": re.compile(r"^(?:|0o[0-7]+|[-+]?(?:[0-9]+)|0x[0-9a-fA-F]+)$", re.X), + "start_chars": list("-+0123456789"), + }, + { "tag": "tag:yaml.org,2002:float", "regexp": re.compile( - r'^(?:[-+]?(?:\.[0-9]+|[0-9]+(\.[0-9]*)?)(?:[eE][-+]?[0-9]+)?|[-+]?\.(?:inf|Inf|INF)|\.(?:nan|NaN|NAN))$', # noqa - re.X + r"^(?:[-+]?(?:\.[0-9]+|[0-9]+(\.[0-9]*)?)(?:[eE][-+]?[0-9]+)?|[-+]?\.(?:inf|Inf|INF)|\.(?:nan|NaN|NAN))$", # noqa + re.X, ), - "start_chars": list('-+0123456789.') - }, { + "start_chars": list("-+0123456789."), + }, + { "tag": "tag:yaml.org,2002:null", - "regexp": re.compile(r'^(?:~||null|Null|NULL)$', re.X), - "start_chars": ['~', 'n', 'N', ''] - } - ] + "regexp": re.compile(r"^(?:~||null|Null|NULL)$", re.X), + "start_chars": ["~", "n", "N", ""], + }, + ], } -merge_resolver = { - "tag": "tag:yaml.org,2002:merge", - "regexp": re.compile(r'^(?:<<)$'), - "start_chars": ['<'] -} +merge_resolver = {"tag": "tag:yaml.org,2002:merge", "regexp": re.compile(r"^(?:<<)$"), "start_chars": ["<"]} + def set_yaml_grammar(resolver, grammar_version="1.2", expand_merge_keys=True): if grammar_version not in core_resolvers: @@ -93,10 +117,11 @@ resolvers.append(merge_resolver) resolver.yaml_implicit_resolvers = {} for r in resolvers: - for start_char in r["start_chars"]: + for start_char in r["start_chars"]: # type: ignore resolver.yaml_implicit_resolvers.setdefault(start_char, []) resolver.yaml_implicit_resolvers[start_char].append((r["tag"], r["regexp"])) + def hash_key(key): return b64encode(sha224(key.encode() if isinstance(key, str) else key).digest()).decode() @@ -129,6 +154,7 @@ anchor_token = self.scan_anchor(AnchorToken) # noqa: F841 # self.emit_yq_kv("__yq_anchor__", anchor_token.value, original_token=anchor_token) + def get_loader(use_annotations=False, expand_aliases=True, expand_merge_keys=True): def construct_sequence(loader, node): annotations = [] @@ -171,7 +197,7 @@ loader_class = default_loader if expand_aliases else CustomLoader loader_class.add_constructor(yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG, construct_mapping) loader_class.add_constructor(yaml.resolver.BaseResolver.DEFAULT_SEQUENCE_TAG, construct_sequence) - loader_class.add_multi_constructor('', parse_unknown_tags) + loader_class.add_multi_constructor("", parse_unknown_tags) loader_class.yaml_constructors.pop("tag:yaml.org,2002:binary", None) loader_class.yaml_constructors.pop("tag:yaml.org,2002:set", None) set_yaml_grammar(loader_class, expand_merge_keys=expand_merge_keys) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-3.1.0/yq/parser.py new/yq-3.1.1/yq/parser.py --- old/yq-3.1.0/yq/parser.py 2022-07-23 01:40:02.000000000 +0200 +++ new/yq-3.1.1/yq/parser.py 2023-02-22 06:14:38.000000000 +0100 @@ -1,6 +1,7 @@ -from __future__ import absolute_import, division, print_function, unicode_literals - -import sys, argparse, subprocess +import argparse +import subprocess +import sys +from typing import Union try: from .version import version as __version__ @@ -8,8 +9,20 @@ __version__ = "0.0.0" # jq arguments that consume positionals must be listed here to avoid our parser mistaking them for our positionals -jq_arg_spec = {"--indent": 1, "-f": 1, "--from-file": 1, "-L": 1, "--arg": 2, "--argjson": 2, "--slurpfile": 2, - "--argfile": 2, "--rawfile": 2, "--args": argparse.REMAINDER, "--jsonargs": argparse.REMAINDER} +jq_arg_spec = { + "--indent": 1, + "-f": 1, + "--from-file": 1, + "-L": 1, + "--arg": 2, + "--argjson": 2, + "--slurpfile": 2, + "--argfile": 2, + "--rawfile": 2, + "--args": argparse.REMAINDER, + "--jsonargs": argparse.REMAINDER, +} + class Parser(argparse.ArgumentParser): def print_help(self): @@ -21,6 +34,7 @@ except Exception: pass + 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 @@ -30,23 +44,27 @@ if program_name == "yq": current_language = "YAML" yaml_output_help = "Transcode jq JSON output back into YAML and emit it" - yaml_roundtrip_help = ("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_roundtrip_help = ( + "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." + ) 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") - 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.") + 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." + ) elif program_name == "xq": current_language = "XML" xml_output_help = "Transcode jq JSON output back into XML and emit it" 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 = ( + "Tag name to pass to force_list parameter of xmltodict.parse(). " "Can be used multiple times." + ) elif program_name == "tomlq": current_language = "TOML" toml_output_help = "Transcode jq JSON output back into TOML and emit it" @@ -59,30 +77,48 @@ parser_args.update(allow_abbrev=False) # required to disambiguate options listed in jq_arg_spec parser = Parser(**parser_args) parser.add_argument("--output-format", default="json", help=argparse.SUPPRESS) - parser.add_argument("--yaml-output", "--yml-output", "-y", dest="output_format", action="store_const", const="yaml", - help=yaml_output_help) - parser.add_argument("--yaml-roundtrip", "--yml-roundtrip", "-Y", dest="output_format", action="store_const", - const="annotated_yaml", help=yaml_roundtrip_help) - parser.add_argument("--yaml-output-grammar-version", "--yml-out-ver", choices=["1.1", "1.2"], default="1.1", - help=grammar_help) + parser.add_argument( + "--yaml-output", + "--yml-output", + "-y", + dest="output_format", + action="store_const", + const="yaml", + help=yaml_output_help, + ) + parser.add_argument( + "--yaml-roundtrip", + "--yml-roundtrip", + "-Y", + dest="output_format", + action="store_const", + const="annotated_yaml", + help=yaml_roundtrip_help, + ) + parser.add_argument( + "--yaml-output-grammar-version", "--yml-out-ver", choices=["1.1", "1.2"], default="1.1", help=grammar_help + ) 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("--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-output", "-x", dest="output_format", action="store_const", const="xml", help=xml_output_help + ) 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("--toml-output", "-t", dest="output_format", action="store_const", const="toml", - help=toml_output_help) + parser.add_argument( + "--toml-output", "-t", dest="output_format", action="store_const", const="toml", help=toml_output_help + ) parser.add_argument("--in-place", "-i", action="store_true", help="Edit files in place (no backup - use caution)") parser.add_argument("--version", action="version", version="%(prog)s {version}".format(version=__version__)) for arg in jq_arg_spec: - parser.add_argument(arg, nargs=jq_arg_spec[arg], dest=arg, action="append", help=argparse.SUPPRESS) + nargs: Union[int, str] = jq_arg_spec[arg] # type: ignore + parser.add_argument(arg, nargs=nargs, dest=arg, action="append", help=argparse.SUPPRESS) parser.add_argument("jq_filter", nargs="?") parser.add_argument("input_streams", nargs="*", type=argparse.FileType(), metavar="files", default=[]) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-3.1.0/yq/version.py new/yq-3.1.1/yq/version.py --- old/yq-3.1.0/yq/version.py 2022-07-24 19:51:29.000000000 +0200 +++ new/yq-3.1.1/yq/version.py 2023-02-22 06:27:05.000000000 +0100 @@ -1,5 +1,4 @@ -# coding: utf-8 # file generated by setuptools_scm # don't change, don't track in version control -__version__ = version = '3.1.0' -__version_tuple__ = version_tuple = (3, 1, 0) +__version__ = version = '3.1.1' +__version_tuple__ = version_tuple = (3, 1, 1) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-3.1.0/yq.egg-info/PKG-INFO new/yq-3.1.1/yq.egg-info/PKG-INFO --- old/yq-3.1.0/yq.egg-info/PKG-INFO 2022-07-24 19:51:29.000000000 +0200 +++ new/yq-3.1.1/yq.egg-info/PKG-INFO 2023-02-22 06:27:05.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: yq -Version: 3.1.0 +Version: 3.1.1 Summary: Command-line YAML/XML processor - jq wrapper for YAML/XML documents Home-page: https://github.com/kislyuk/yq Author: Andrey Kislyuk @@ -29,7 +29,7 @@ ------------ :: - pip3 install yq + pip install yq Before using ``yq``, you also have to install its dependency, ``jq``. See the `jq installation instructions <https://stedolan.github.io/jq/download/>`_ for details and directions specific to your platform. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-3.1.0/yq.egg-info/SOURCES.txt new/yq-3.1.1/yq.egg-info/SOURCES.txt --- old/yq-3.1.0/yq.egg-info/SOURCES.txt 2022-07-24 19:51:29.000000000 +0200 +++ new/yq-3.1.1/yq.egg-info/SOURCES.txt 2023-02-22 06:27:05.000000000 +0100 @@ -5,10 +5,11 @@ Makefile README.rst common.mk +pyproject.toml setup.cfg setup.py .github/FUNDING.yml -.github/workflows/pythonpackage.yml +.github/workflows/ci.yml docs/changelog.rst docs/cli-doc.txt docs/conf.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-3.1.0/yq.egg-info/requires.txt new/yq-3.1.1/yq.egg-info/requires.txt --- old/yq-3.1.0/yq.egg-info/requires.txt 2022-07-24 19:51:29.000000000 +0200 +++ new/yq-3.1.1/yq.egg-info/requires.txt 2023-02-22 06:27:05.000000000 +0100 @@ -7,3 +7,5 @@ coverage flake8 wheel +build +mypy