headson 0.4.0__cp310-abi3-win_amd64.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 +4 -0
- headson/headson.pyd +0 -0
- headson-0.4.0.dist-info/METADATA +169 -0
- headson-0.4.0.dist-info/RECORD +6 -0
- headson-0.4.0.dist-info/WHEEL +4 -0
- headson-0.4.0.dist-info/licenses/LICENSE +21 -0
headson/__init__.py
ADDED
headson/headson.pyd
ADDED
|
Binary file
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: headson
|
|
3
|
+
Version: 0.4.0
|
|
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.10
|
|
14
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
15
|
+
|
|
16
|
+
# headson
|
|
17
|
+
|
|
18
|
+
Head/tail for JSON — but structure‑aware. Get a compact preview that shows both the shape and representative values of your data, all within a strict character budget.
|
|
19
|
+
|
|
20
|
+
Available as:
|
|
21
|
+
- CLI (see [Usage](#usage))
|
|
22
|
+
- Python library (see [Python Bindings](#python-bindings))
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
Using Cargo:
|
|
27
|
+
|
|
28
|
+
cargo install headson
|
|
29
|
+
|
|
30
|
+
From source:
|
|
31
|
+
|
|
32
|
+
cargo build --release
|
|
33
|
+
target/release/headson --help
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## Features
|
|
37
|
+
|
|
38
|
+
- *Budgeted output*: specify exactly how much JSON you want to see
|
|
39
|
+
- *Multiple output formats* : `json` (machine‑readable), `pseudo` (human‑friendly), `js` (valid JavaScript, most detailed metadata).
|
|
40
|
+
- *Multiple inputs*: preview many files at once with a shared or per‑file budget.
|
|
41
|
+
- *Fast*: can process gigabyte-scale files in seconds (mostly disk-constrained)
|
|
42
|
+
- *Available as a CLI app and as a Python library*
|
|
43
|
+
|
|
44
|
+
## Fits into command line workflows
|
|
45
|
+
|
|
46
|
+
If you’re comfortable with tools like `head` and `tail`, use `headson` when you want a quick, structured peek into a JSON file without dumping the entire thing.
|
|
47
|
+
|
|
48
|
+
- `head`/`tail` operate on bytes/lines - their output is not optimized for tree structures
|
|
49
|
+
- `jq` you need to craft filters to preview large JSON files
|
|
50
|
+
- `headson` is like head/tail for trees: zero config but it keeps structure and represents content as much as possible
|
|
51
|
+
|
|
52
|
+
## Usage
|
|
53
|
+
|
|
54
|
+
headson [FLAGS] [INPUT...]
|
|
55
|
+
|
|
56
|
+
- INPUT (optional, repeatable): file path(s). If omitted, reads JSON from stdin. Multiple input files are supported.
|
|
57
|
+
- Prints the preview to stdout. On parse errors, exits non‑zero and prints an error to stderr.
|
|
58
|
+
|
|
59
|
+
Common flags:
|
|
60
|
+
|
|
61
|
+
- `-n, --budget <BYTES>`: per‑file output budget. When multiple input files are provided, the total budget equals `<BYTES> * number_of_inputs`.
|
|
62
|
+
- `-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`.
|
|
63
|
+
- `-f, --template <json|pseudo|js>`: output style (default: `pseudo`)
|
|
64
|
+
- `-m, --compact`: no indentation, no spaces, no newlines
|
|
65
|
+
- `--no-newline`: single line output
|
|
66
|
+
- `--no-space`: no space after `:` in objects
|
|
67
|
+
- `--indent <STR>`: indentation unit (default: two spaces)
|
|
68
|
+
- `--string-cap <N>`: max graphemes to consider per string (default: 500)
|
|
69
|
+
- `--tail`: prefer the end of arrays when truncating. Strings are unaffected. In `pseudo`/`js` templates the omission marker appears at the start; `json` remains strict JSON with no annotations.
|
|
70
|
+
|
|
71
|
+
Notes:
|
|
72
|
+
|
|
73
|
+
- With multiple input files:
|
|
74
|
+
- JSON template outputs a single JSON object keyed by the input file paths.
|
|
75
|
+
- Pseudo and JS templates render file sections with human-readable headers when newlines are enabled.
|
|
76
|
+
- If you use `--compact` or `--no-newline` (both disable newlines), fileset output falls back to standard inline rendering (no per-file headers) to remain compact.
|
|
77
|
+
- Using `--global-budget` may truncate or omit entire files to respect the total budget.
|
|
78
|
+
- The tool finds the largest preview that fits the budget; if even the tiniest preview exceeds it, you still get a minimal, valid preview.
|
|
79
|
+
- When passing file paths, directories and binary files are ignored; a notice is printed to stderr for each (e.g., `Ignored binary file: ./path/to/file`). Stdin mode reads the stream as-is.
|
|
80
|
+
|
|
81
|
+
Quick one‑liners:
|
|
82
|
+
|
|
83
|
+
- Peek a big JSON stream (keeps structure):
|
|
84
|
+
|
|
85
|
+
zstdcat huge.json.zst | headson -n 800 -f pseudo
|
|
86
|
+
|
|
87
|
+
- Many files with a fixed overall size:
|
|
88
|
+
|
|
89
|
+
headson -N 1200 -f json logs/*.json
|
|
90
|
+
|
|
91
|
+
- Glance at a file, JavaScript‑style comments for omissions:
|
|
92
|
+
|
|
93
|
+
headson -n 400 -f js data.json
|
|
94
|
+
|
|
95
|
+
Show help:
|
|
96
|
+
|
|
97
|
+
headson --help
|
|
98
|
+
|
|
99
|
+
## Examples: head vs headson
|
|
100
|
+
|
|
101
|
+
Input:
|
|
102
|
+
|
|
103
|
+
```json
|
|
104
|
+
{"users":[{"id":1,"name":"Ana","roles":["admin","dev"]},{"id":2,"name":"Bo"}],"meta":{"count":2,"source":"db"}}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Naive cut (can break mid‑token):
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
jq -c . users.json | head -c 80
|
|
111
|
+
# {"users":[{"id":1,"name":"Ana","roles":["admin","dev"]},{"id":2,"name":"Bo"}],"me
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Structured preview with headson (pseudo):
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
headson -n 120 -f pseudo users.json
|
|
118
|
+
# {
|
|
119
|
+
# users: [
|
|
120
|
+
# { id: 1, name: "Ana", roles: [ "admin", … ] },
|
|
121
|
+
# …
|
|
122
|
+
# ]
|
|
123
|
+
# meta: { count: 2, … }
|
|
124
|
+
# }
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Machine‑readable preview (json):
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
headson -n 120 -f json users.json
|
|
131
|
+
# {"users":[{"id":1,"name":"Ana","roles":["admin"]}],"meta":{"count":2}}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Python Bindings
|
|
135
|
+
|
|
136
|
+
A thin Python extension module is available on PyPI as `headson`.
|
|
137
|
+
|
|
138
|
+
- Install: `pip install headson` (ABI3 wheels for Python 3.10+ on Linux/macOS/Windows).
|
|
139
|
+
- API:
|
|
140
|
+
- `headson.summarize(text: str, *, template: str = "pseudo", character_budget: int | None = None, tail: bool = False) -> str`
|
|
141
|
+
- `template`: one of `"json" | "pseudo" | "js"`
|
|
142
|
+
- `character_budget`: maximum output size in characters (default: 500)
|
|
143
|
+
- `tail`: prefer the end of arrays when truncating; strings unaffected. Affects only display templates (`pseudo`/`js`); `json` remains strict.
|
|
144
|
+
|
|
145
|
+
Example:
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
import json
|
|
149
|
+
import headson
|
|
150
|
+
|
|
151
|
+
data = {"foo": [1, 2, 3], "bar": {"x": "y"}}
|
|
152
|
+
preview = headson.summarize(json.dumps(data), template="json", character_budget=200)
|
|
153
|
+
print(preview)
|
|
154
|
+
|
|
155
|
+
# Prefer the tail of arrays (annotations show in pseudo/js only)
|
|
156
|
+
print(
|
|
157
|
+
headson.summarize(
|
|
158
|
+
json.dumps(list(range(100))),
|
|
159
|
+
template="pseudo",
|
|
160
|
+
character_budget=80,
|
|
161
|
+
tail=True,
|
|
162
|
+
)
|
|
163
|
+
)
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## License
|
|
167
|
+
|
|
168
|
+
MIT
|
|
169
|
+
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
headson-0.4.0.dist-info/METADATA,sha256=R2xwoSZ2KhkXVMmqa8Bqlh8i_DjR3KzSLH8f0rfkS58,6015
|
|
2
|
+
headson-0.4.0.dist-info/WHEEL,sha256=4EDp_7DiFfWl1yYv5M4wSosAn5L_xgD1dyrQxQxfCx8,95
|
|
3
|
+
headson-0.4.0.dist-info/licenses/LICENSE,sha256=85XxIce4vPe2JysuORWOYpzGI-ypir_79W6aOF8y534,1093
|
|
4
|
+
headson/__init__.py,sha256=PnXEkHuT6aEqKi8lL11uZU2IZ5cGgFqfO43xShmpros,137
|
|
5
|
+
headson/headson.pyd,sha256=yywJ7fyfJ95heJpIjcJN53K_RLDAIQzzlvjlWB3RiY0,453632
|
|
6
|
+
headson-0.4.0.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.
|