5bb-yaml 4.45.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,207 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+ #poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ #pdm.lock
116
+ #pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ #pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # SageMath parsed files
135
+ *.sage.py
136
+
137
+ # Environments
138
+ .env
139
+ .envrc
140
+ .venv
141
+ env/
142
+ venv/
143
+ ENV/
144
+ env.bak/
145
+ venv.bak/
146
+
147
+ # Spyder project settings
148
+ .spyderproject
149
+ .spyproject
150
+
151
+ # Rope project settings
152
+ .ropeproject
153
+
154
+ # mkdocs documentation
155
+ /site
156
+
157
+ # mypy
158
+ .mypy_cache/
159
+ .dmypy.json
160
+ dmypy.json
161
+
162
+ # Pyre type checker
163
+ .pyre/
164
+
165
+ # pytype static type analyzer
166
+ .pytype/
167
+
168
+ # Cython debug symbols
169
+ cython_debug/
170
+
171
+ # PyCharm
172
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
173
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
175
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
176
+ #.idea/
177
+
178
+ # Abstra
179
+ # Abstra is an AI-powered process automation framework.
180
+ # Ignore directories containing user credentials, local state, and settings.
181
+ # Learn more at https://abstra.io/docs
182
+ .abstra/
183
+
184
+ # Visual Studio Code
185
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
188
+ # you could uncomment the following to ignore the entire vscode folder
189
+ # .vscode/
190
+
191
+ # Ruff stuff:
192
+ .ruff_cache/
193
+
194
+ # PyPI configuration file
195
+ .pypirc
196
+
197
+ # Cursor
198
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
199
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
200
+ # refer to https://docs.cursor.com/context/ignore-files
201
+ .cursorignore
202
+ .cursorindexingignore
203
+
204
+ # Marimo
205
+ marimo/_static/
206
+ marimo/_lsp/
207
+ __marimo__/
@@ -0,0 +1,56 @@
1
+ Metadata-Version: 2.4
2
+ Name: 5bb-yaml
3
+ Version: 4.45.1
4
+ Summary: yamlquery – a portable command-line YAML, JSON, XML, CSV, TOML and properties processor, packaged for easy installation via pip/uv
5
+ Project-URL: Homepage, https://github.com/5-bare-bones/toolbox__monorepo
6
+ Project-URL: Source, https://github.com/mikefarah/yq
7
+ License: MIT
8
+ Keywords: cli,jq,json,yaml,yq
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Environment :: Console
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Text Processing :: Markup
16
+ Classifier: Topic :: Utilities
17
+ Requires-Python: >=3.11
18
+ Requires-Dist: rich>=13
19
+ Provides-Extra: dev
20
+ Requires-Dist: pytest; extra == 'dev'
21
+ Description-Content-Type: text/markdown
22
+
23
+ # 5bb-yaml
24
+
25
+ > **yq** – a portable command-line YAML, JSON, XML, CSV, TOML and properties processor (like jq, but for YAML), distributed via PyPI/uv.
26
+
27
+ This package downloads and installs the [`yq`](https://github.com/mikefarah/yq) binary for your platform on first use. No compilation required.
28
+
29
+ ## Installation
30
+
31
+ ```bash
32
+ uv tool install 5bb-yaml
33
+ # or
34
+ pip install 5bb-yaml
35
+ ```
36
+
37
+ ## Usage
38
+
39
+ ```bash
40
+ yq '.name' config.yml
41
+ yq -i '.version = "1.0.0"' pyproject.yml
42
+ ```
43
+
44
+ The binary is downloaded from the official GitHub releases on first run and cached in `~/.cache/5bb-yaml/`.
45
+
46
+ ## Configuration
47
+
48
+ Set `BB_CACHE_DIR` to override the cache location:
49
+
50
+ ```bash
51
+ BB_CACHE_DIR=/opt/tools yq '.name' config.yml
52
+ ```
53
+
54
+ ## License
55
+
56
+ MIT – see the [LICENSE](../../LICENSE) file for details.
@@ -0,0 +1,34 @@
1
+ # 5bb-yaml
2
+
3
+ > **yq** – a portable command-line YAML, JSON, XML, CSV, TOML and properties processor (like jq, but for YAML), distributed via PyPI/uv.
4
+
5
+ This package downloads and installs the [`yq`](https://github.com/mikefarah/yq) binary for your platform on first use. No compilation required.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ uv tool install 5bb-yaml
11
+ # or
12
+ pip install 5bb-yaml
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```bash
18
+ yq '.name' config.yml
19
+ yq -i '.version = "1.0.0"' pyproject.yml
20
+ ```
21
+
22
+ The binary is downloaded from the official GitHub releases on first run and cached in `~/.cache/5bb-yaml/`.
23
+
24
+ ## Configuration
25
+
26
+ Set `BB_CACHE_DIR` to override the cache location:
27
+
28
+ ```bash
29
+ BB_CACHE_DIR=/opt/tools yq '.name' config.yml
30
+ ```
31
+
32
+ ## License
33
+
34
+ MIT – see the [LICENSE](../../LICENSE) file for details.
@@ -0,0 +1,46 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "5bb-yaml"
7
+ version = "4.45.1"
8
+ description = "yamlquery – a portable command-line YAML, JSON, XML, CSV, TOML and properties processor, packaged for easy installation via pip/uv"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = { text = "MIT" }
12
+ dependencies = ["rich>=13"]
13
+ keywords = ["yq", "yaml", "json", "cli", "jq"]
14
+ classifiers = [
15
+ "Development Status :: 4 - Beta",
16
+ "Environment :: Console",
17
+ "Intended Audience :: Developers",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Operating System :: OS Independent",
20
+ "Programming Language :: Python :: 3",
21
+ "Topic :: Text Processing :: Markup",
22
+ "Topic :: Utilities",
23
+ ]
24
+
25
+ [project.urls]
26
+ Homepage = "https://github.com/5-bare-bones/toolbox__monorepo"
27
+ Source = "https://github.com/mikefarah/yq"
28
+
29
+ [project.scripts]
30
+ yamlquery = "bb_yaml:run"
31
+ yaml = "bb_yaml:run"
32
+
33
+ [tool.hatch.build.targets.wheel]
34
+ packages = ["src/bb_yaml"]
35
+
36
+ [tool.hatch.build.targets.sdist]
37
+ include = ["src/", "README.md"]
38
+
39
+ [dependency-groups]
40
+ dev = [
41
+ "mkdocs-material>=9.7.6",
42
+ "pytest>=9.0.3",
43
+ ]
44
+
45
+ [project.optional-dependencies]
46
+ dev = ["pytest"]
@@ -0,0 +1,175 @@
1
+ """
2
+ bb_yaml – thin Python wrapper around the portable command-line
3
+ YAML/JSON/XML/CSV/TOML processor (like jq, but for YAML).
4
+
5
+ On first use the appropriate pre-built binary is downloaded from the
6
+ official GitHub release page and cached in ``~/.cache/5bb-yaml/``.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import os
12
+ import platform
13
+ import stat
14
+ import subprocess
15
+ import sys
16
+ import urllib.request
17
+ from pathlib import Path
18
+
19
+ __version__ = "4.45.1"
20
+ _YQ_VERSION = __version__
21
+
22
+ # ---------------------------------------------------------------------------
23
+ # Platform detection helpers
24
+ # ---------------------------------------------------------------------------
25
+
26
+ def _arch() -> str:
27
+ machine = platform.machine().lower()
28
+ if machine in ("x86_64", "amd64"):
29
+ return "amd64"
30
+ if machine in ("i386", "i686"):
31
+ return "386"
32
+ if machine in ("aarch64", "arm64"):
33
+ return "arm64"
34
+ if machine.startswith("arm"):
35
+ return "arm"
36
+ return machine
37
+
38
+
39
+ def _os_name() -> str:
40
+ system = platform.system().lower()
41
+ if system == "darwin":
42
+ return "darwin"
43
+ if system == "windows":
44
+ return "windows"
45
+ return "linux"
46
+
47
+
48
+ def _binary_name() -> str:
49
+ return "yq.exe" if platform.system().lower() == "windows" else "yq"
50
+
51
+
52
+ def _asset_name() -> str:
53
+ suffix = ".exe" if platform.system().lower() == "windows" else ""
54
+ return f"yq_{_os_name()}_{_arch()}{suffix}"
55
+
56
+
57
+ def _download_url() -> str:
58
+ return (
59
+ f"https://github.com/mikefarah/yq/releases/download"
60
+ f"/v{_YQ_VERSION}/{_asset_name()}"
61
+ )
62
+
63
+
64
+ # ---------------------------------------------------------------------------
65
+ # Binary management
66
+ # ---------------------------------------------------------------------------
67
+
68
+ def _cache_dir() -> Path:
69
+ return Path(os.environ.get("BB_CACHE_DIR", Path.home() / ".cache")) / "5bb-yaml"
70
+
71
+
72
+ def _binary_path() -> Path:
73
+ return _cache_dir() / _binary_name()
74
+
75
+
76
+ def ensure_binary() -> Path:
77
+ """Return the path to the yq binary, downloading it if necessary."""
78
+ binary = _binary_path()
79
+ if binary.exists():
80
+ return binary
81
+
82
+ binary.parent.mkdir(parents=True, exist_ok=True)
83
+ url = _download_url()
84
+
85
+ print(f"[5bb-yaml] Downloading yamlquery v{_YQ_VERSION} …", file=sys.stderr)
86
+ try:
87
+ urllib.request.urlretrieve(url, binary) # noqa: S310
88
+ except Exception as exc: # pragma: no cover
89
+ raise SystemExit(
90
+ f"[5bb-yaml] Failed to download {url}: {exc}"
91
+ ) from exc
92
+
93
+ # Ensure the binary is executable.
94
+ binary.chmod(binary.stat().st_mode | stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH)
95
+ return binary
96
+
97
+
98
+ # ---------------------------------------------------------------------------
99
+ # Help
100
+ # ---------------------------------------------------------------------------
101
+
102
+ def _show_help() -> None:
103
+ from rich.console import Console
104
+ from rich.panel import Panel
105
+ from rich.table import Table
106
+ from rich.text import Text
107
+
108
+ console = Console()
109
+
110
+ console.print(Panel.fit(
111
+ f"[bold cyan]yamlquery[/] [dim]v{__version__}[/]\n"
112
+ "[dim]A portable YAML / JSON / XML / CSV / TOML processor[/]",
113
+ border_style="cyan",
114
+ ))
115
+
116
+ console.print("\n[bold]Usage[/]")
117
+ console.print(" [cyan]yamlquery[/] [yellow]<expression>[/] [green][flags][/] [blue][file...][/]\n")
118
+
119
+ console.print("[bold]Examples[/]")
120
+ examples = [
121
+ ("Read a field", "yamlquery '.name' file.yaml"),
122
+ ("Read nested field", "yamlquery '.metadata.name' file.yaml"),
123
+ ("Update in place", "yamlquery -i '.version = \"2.0\"' file.yaml"),
124
+ ("Output as JSON", "yamlquery -o json '.' file.yaml"),
125
+ ("Merge two files", "yamlquery '. * load(\"b.yaml\")' a.yaml"),
126
+ ("Read from stdin", "cat file.yaml | yamlquery '.name'"),
127
+ ("Multiple documents", "yamlquery '.[].name' multi.yaml"),
128
+ ("Pretty-print", "yamlquery -P '.' file.yaml"),
129
+ ]
130
+ tbl = Table(show_header=False, box=None, padding=(0, 2))
131
+ tbl.add_column(style="dim")
132
+ tbl.add_column(style="green")
133
+ for desc, cmd in examples:
134
+ tbl.add_row(desc, cmd)
135
+ console.print(tbl)
136
+
137
+ console.print("\n[bold]Common flags[/]")
138
+ flags = [
139
+ ("-i, --inplace", "Edit file in place"),
140
+ ("-o, --output-format", "Output format: yaml | json | props | csv | tsv | xml"),
141
+ ("-P, --prettyPrint", "Pretty-print output"),
142
+ ("-e, --exit-status", "Exit 1 if expression returns no results"),
143
+ ("-n, --null-input", "Don't read input; use 'null' as input"),
144
+ ("-r, --raw-output", "Print raw strings (no quotes)"),
145
+ (" --xml-attribute-prefix", "Prefix for XML attributes (default: +@)"),
146
+ (" --version", "Print version and exit"),
147
+ ("-h, --help", "Show this help"),
148
+ ]
149
+ ftbl = Table(show_header=False, box=None, padding=(0, 2))
150
+ ftbl.add_column(style="yellow", no_wrap=True)
151
+ ftbl.add_column(style="dim")
152
+ for flag, desc in flags:
153
+ ftbl.add_row(flag, desc)
154
+ console.print(ftbl)
155
+
156
+ console.print(
157
+ "\n[dim]Full documentation: https://mikefarah.gitbook.io/yq[/]\n"
158
+ )
159
+
160
+
161
+ # ---------------------------------------------------------------------------
162
+ # Entry point
163
+ # ---------------------------------------------------------------------------
164
+
165
+ def run() -> None:
166
+ """CLI entry point – delegates all arguments to the yamlquery binary."""
167
+ args = sys.argv[1:]
168
+ if not args or args[0] in ("-h", "--help"):
169
+ _show_help()
170
+ sys.exit(0)
171
+ binary = ensure_binary()
172
+ full_args = [str(binary)] + args
173
+ if platform.system().lower() == "windows":
174
+ sys.exit(subprocess.call(full_args))
175
+ os.execv(str(binary), full_args)