diff options
author | Patrick McLean <chutzpah@gentoo.org> | 2023-02-22 12:05:16 -0800 |
---|---|---|
committer | Patrick McLean <chutzpah@gentoo.org> | 2023-02-22 12:05:16 -0800 |
commit | 7485e96950fa050f08756d93eae63ac5718f9ede (patch) | |
tree | 7c437bbf3a3aa25e659773f98b284e74a3ea8f42 /app-misc/yq | |
parent | x11-wm/wmii: fix MissingRemoteId for maintainer-needed packages (diff) | |
download | gentoo-7485e96950fa050f08756d93eae63ac5718f9ede.tar.gz gentoo-7485e96950fa050f08756d93eae63ac5718f9ede.tar.bz2 gentoo-7485e96950fa050f08756d93eae63ac5718f9ede.zip |
app-misc/yq: add 3.1.1
Signed-off-by: Patrick McLean <chutzpah@gentoo.org>
Diffstat (limited to 'app-misc/yq')
-rw-r--r-- | app-misc/yq/Manifest | 1 | ||||
-rw-r--r-- | app-misc/yq/files/yq-3.1.1-tomli.patch | 80 | ||||
-rw-r--r-- | app-misc/yq/yq-3.1.1.ebuild | 59 |
3 files changed, 140 insertions, 0 deletions
diff --git a/app-misc/yq/Manifest b/app-misc/yq/Manifest index 7e92831a05b4..d6ba60e56cec 100644 --- a/app-misc/yq/Manifest +++ b/app-misc/yq/Manifest @@ -1 +1,2 @@ DIST yq-3.1.0.tar.gz 29627 BLAKE2B 9ebeec400462788613b256a29c9706f4d6a06ced8a86b72ce6128cea6bdf258a62ff18b643cea00d5170f68af798d28af324b3908fc3fdea83329bc5feaa5539 SHA512 bb55a9fde5c072d2341faacd76c54d7374fcc70789ddae4d06e36fd48d7ebd6462c8bff13042c39c3fedf191d70752fa2f94af3c69f52f754bca83c3f1f89004 +DIST yq-3.1.1.tar.gz 30095 BLAKE2B 0f8ed3d23e1c1b65fae0164f34b19ab774308ee8ec9b5c21547c5eddf930c49750cdbee858b6b48bcd92d4146715f7e4c45dd976141dc5837c788e4ae68a51bc SHA512 f6d372fd406179121849330391ab5657e9bac3b6fb4d33673872d4649337fd60344fe01c534d1382cc35416919cd19b62287350d1f0f825f198fb9cc9bc58c1f diff --git a/app-misc/yq/files/yq-3.1.1-tomli.patch b/app-misc/yq/files/yq-3.1.1-tomli.patch new file mode 100644 index 000000000000..b4ef5ef3dfb9 --- /dev/null +++ b/app-misc/yq/files/yq-3.1.1-tomli.patch @@ -0,0 +1,80 @@ +diff --git a/README.rst b/README.rst +index 69d77e1..237b89e 100644 +--- a/README.rst ++++ b/README.rst +@@ -109,7 +109,9 @@ the ``xq --xml-output``/``xq -x`` option. Multiple XML documents can be passed i + 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 ++`tomllib module <https://docs.python.org/3.11/library/tomllib.html>` or `tomli library ++<https://github.com/hukkin/tomli>`_ to transcode TOML to JSON, then pipes it to ``jq``. Transcoding to TOML uses the ++`tomli-w <https://github.com/hukkin/toml-w`_ package. Roundtrip transcoding + is available with the ``tomlq --toml-output``/``tomlq -t`` option. + + .. admonition:: Compatibility note +diff --git a/setup.py b/setup.py +index 9de217e..7d34f8c 100755 +--- a/setup.py ++++ b/setup.py +@@ -19,7 +19,8 @@ setup( + install_requires=[ + "PyYAML >= 5.3.1", + "xmltodict >= 0.11.0", +- "toml >= 0.10.0", ++ "tomli >= 1.2.3; python_version < '3.11'", ++ "tomli-w", + "argcomplete >= 1.8.1", + ], + extras_require={ +diff --git a/yq/__init__.py b/yq/__init__.py +index 0ccb8e8..88da1d7 100644 +--- a/yq/__init__.py ++++ b/yq/__init__.py +@@ -246,9 +246,12 @@ def yq( + json.dump(doc, json_buffer, cls=JSONDateTimeEncoder) + json_buffer.write("\n") + elif input_format == "toml": +- import toml ++ if sys.version_info >= (3, 11): ++ import tomllib ++ else: ++ import tomli as tomllib + +- doc = toml.load(input_stream) # type: ignore ++ doc = tomllib.loads(input_stream.read()) # type: ignore + json.dump(doc, json_buffer, cls=JSONDateTimeEncoder) + json_buffer.write("\n") + else: +@@ -295,13 +298,13 @@ def yq( + raise + output_stream.write(b"\n" if sys.version_info < (3, 0) else "\n") + elif output_format == "toml": +- import toml ++ import tomli_w + + 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) ++ output_stream.write(tomli_w.dumps(doc)) + else: + if input_format == "yaml": + loader_class = get_loader( +@@ -327,10 +330,13 @@ def yq( + ) + jq.stdin.write("\n") # type: ignore + elif input_format == "toml": +- import toml ++ if sys.version_info >= (3, 11): ++ import tomllib ++ else: ++ import tomli as tomllib + + for input_stream in input_streams: +- json.dump(toml.load(input_stream), jq.stdin, cls=JSONDateTimeEncoder) # type: ignore ++ json.dump(tomllib.loads(input_stream.read()), jq.stdin, cls=JSONDateTimeEncoder) # type: ignore + jq.stdin.write("\n") # type: ignore + else: + raise Exception("Unknown input format") diff --git a/app-misc/yq/yq-3.1.1.ebuild b/app-misc/yq/yq-3.1.1.ebuild new file mode 100644 index 000000000000..93a72bf0f774 --- /dev/null +++ b/app-misc/yq/yq-3.1.1.ebuild @@ -0,0 +1,59 @@ +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +PYTHON_COMPAT=( python3_{9..11} pypy3 ) +DISTUTILS_USE_PEP517=setuptools + +inherit pypi distutils-r1 + +DESCRIPTION="Command-line YAML processor - jq wrapper for YAML documents" +HOMEPAGE=" + https://yq.readthedocs.io/ + https://github.com/kislyuk/yq/ + https://pypi.org/project/yq/ +" + +LICENSE="Apache-2.0" +SLOT="0" +KEYWORDS="~amd64 ~x86" +IUSE="test" +RESTRICT="!test? ( test )" + +RDEPEND=" + app-misc/jq + dev-python/argcomplete[${PYTHON_USEDEP}] + >=dev-python/pyyaml-5.3.1[${PYTHON_USEDEP}] + dev-python/xmltodict[${PYTHON_USEDEP}] + $(python_gen_cond_dep ' + dev-python/tomli[${PYTHON_USEDEP}] + ' 3.{8..10}) +" +DEPEND=" + ${RDEPEND} + test? ( + dev-python/wheel[${PYTHON_USEDEP}] + ) +" + +PATCHES=( + "${FILESDIR}/yq-2.13.0-tests.patch" + "${FILESDIR}/yq-3.1.1-tomli.patch" +) + +python_prepare_all() { + sed -e 's:unittest.main():unittest.main(verbosity=2):' \ + -i test/test.py || die + + sed -r -e 's:[[:space:]]*"coverage",:: ; s:[[:space:]]*"flake8",::' \ + -i setup.py || die + + sed -e '/license_file/ d' -i setup.cfg || die + + distutils-r1_python_prepare_all +} + +python_test() { + "${EPYTHON}" test/test.py </dev/null || die "tests failed under ${EPYTHON}" +} |