headson 0.2.3__cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
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.
Potentially problematic release.
This version of headson might be problematic. Click here for more details.
headson/__init__.py
ADDED
|
Binary file
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: headson
|
|
3
|
+
Version: 0.2.3
|
|
4
|
+
Classifier: Programming Language :: Python
|
|
5
|
+
Classifier: Programming Language :: Python :: 3
|
|
6
|
+
Classifier: Programming Language :: Rust
|
|
7
|
+
Classifier: Operating System :: OS Independent
|
|
8
|
+
Requires-Dist: pytest>=8 ; extra == 'test'
|
|
9
|
+
Provides-Extra: test
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Summary: Budget‑constrained JSON preview renderer (Python bindings)
|
|
12
|
+
Keywords: json,preview,summarize,cli,bindings
|
|
13
|
+
Requires-Python: >=3.8
|
|
14
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
15
|
+
|
|
16
|
+
# headson
|
|
17
|
+
|
|
18
|
+
Budget‑constrained JSON preview for the terminal.
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
Using Cargo:
|
|
23
|
+
|
|
24
|
+
cargo install headson
|
|
25
|
+
|
|
26
|
+
From source:
|
|
27
|
+
|
|
28
|
+
cargo build --release
|
|
29
|
+
target/release/headson --help
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
headson [FLAGS] [INPUT...]
|
|
34
|
+
|
|
35
|
+
- INPUT (optional, repeatable): file path(s). If omitted, reads JSON from stdin. Multiple input files are supported.
|
|
36
|
+
- Prints the preview to stdout. On parse errors, exits non‑zero and prints an error to stderr.
|
|
37
|
+
|
|
38
|
+
Common flags:
|
|
39
|
+
|
|
40
|
+
- `-n, --budget <BYTES>`: per‑file output budget. When multiple input files are provided, the total budget equals `<BYTES> * number_of_inputs`.
|
|
41
|
+
- `-N, --global-budget <BYTES>`: total output budget across all inputs. Useful when you want a fixed-size preview across many files (may omit entire files). Mutually exclusive with `--budget`.
|
|
42
|
+
- `-f, --template <json|pseudo|js>`: output style (default: `pseudo`)
|
|
43
|
+
- `-m, --compact`: no indentation, no spaces, no newlines
|
|
44
|
+
- `--no-newline`: single line output
|
|
45
|
+
- `--no-space`: no space after `:` in objects
|
|
46
|
+
- `--indent <STR>`: indentation unit (default: two spaces)
|
|
47
|
+
- `--string-cap <N>`: max graphemes to consider per string (default: 500)
|
|
48
|
+
|
|
49
|
+
Notes:
|
|
50
|
+
|
|
51
|
+
- With multiple input files:
|
|
52
|
+
- JSON template outputs a single JSON object keyed by the input file paths.
|
|
53
|
+
- Pseudo and JS templates render file sections with human-readable headers.
|
|
54
|
+
- Using `--global-budget` may truncate or omit entire files to respect the total budget.
|
|
55
|
+
|
|
56
|
+
Examples:
|
|
57
|
+
|
|
58
|
+
- Read from stdin with defaults:
|
|
59
|
+
|
|
60
|
+
cat data.json | headson
|
|
61
|
+
|
|
62
|
+
- Read from file, JS style, 200‑byte budget:
|
|
63
|
+
|
|
64
|
+
headson -n 200 -f js data.json
|
|
65
|
+
|
|
66
|
+
- JSON style, compact:
|
|
67
|
+
|
|
68
|
+
headson -f json -m data.json
|
|
69
|
+
|
|
70
|
+
- Multiple files (JSON template produces an object keyed by paths):
|
|
71
|
+
|
|
72
|
+
headson -f json a.json b.json
|
|
73
|
+
|
|
74
|
+
- Global limit across files (fixed total size across all files):
|
|
75
|
+
|
|
76
|
+
headson -N 400 -f json a.json b.json
|
|
77
|
+
|
|
78
|
+
Show help:
|
|
79
|
+
|
|
80
|
+
headson --help
|
|
81
|
+
|
|
82
|
+
## Python package
|
|
83
|
+
|
|
84
|
+
Headson is also available as a Python extension module built with PyO3/maturin.
|
|
85
|
+
|
|
86
|
+
Install from PyPI:
|
|
87
|
+
|
|
88
|
+
pip install headson
|
|
89
|
+
|
|
90
|
+
Example:
|
|
91
|
+
|
|
92
|
+
import json
|
|
93
|
+
import headson
|
|
94
|
+
|
|
95
|
+
data = {"foo": [1, 2, 3], "bar": {"x": "y"}}
|
|
96
|
+
preview = headson.summarize(json.dumps(data), template="json", character_budget=200)
|
|
97
|
+
print(preview)
|
|
98
|
+
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
headson-0.2.3.dist-info/METADATA,sha256=_C-vskWIbrSYy6BEZpX0_qH5FQPUHZ0fgQnTw3nNPXI,2776
|
|
2
|
+
headson-0.2.3.dist-info/WHEEL,sha256=fzKw7D4hQlly-QR1ny78JqSVziI8F0zhh7uHrIL1JAo,129
|
|
3
|
+
headson-0.2.3.dist-info/licenses/LICENSE,sha256=GZ9row3L2LsnOSbEuGMQZ0zKOIEd5tHr76cZHpg4KK8,1072
|
|
4
|
+
headson/__init__.py,sha256=PnXEkHuT6aEqKi8lL11uZU2IZ5cGgFqfO43xShmpros,137
|
|
5
|
+
headson/headson.cpython-310-x86_64-linux-gnu.so,sha256=eUM1lmtMaLSMi-R2rbpG5_XDhPJ7c3u0oHCb2a_pVNE,670136
|
|
6
|
+
headson-0.2.3.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Dániel Kántor
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|