headson 0.6.1__cp310-abi3-win_amd64.whl → 0.6.3__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 +6 -1
- headson/headson.pyd +0 -0
- {headson-0.6.1.dist-info → headson-0.6.3.dist-info}/METADATA +76 -38
- headson-0.6.3.dist-info/RECORD +5 -0
- headson-0.6.1.dist-info/RECORD +0 -6
- headson-0.6.1.dist-info/licenses/LICENSE +0 -21
- {headson-0.6.1.dist-info → headson-0.6.3.dist-info}/WHEEL +0 -0
headson/__init__.py
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
# Re-export the compiled extension API directly.
|
|
4
6
|
from .headson import summarize # type: ignore
|
|
5
7
|
|
|
6
8
|
__all__ = ["summarize"]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
__all__ = ["summarize"]
|
headson/headson.pyd
CHANGED
|
Binary file
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: headson
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.3
|
|
4
4
|
Classifier: Programming Language :: Python
|
|
5
5
|
Classifier: Programming Language :: Python :: 3
|
|
6
6
|
Classifier: Programming Language :: Rust
|
|
7
7
|
Classifier: Operating System :: OS Independent
|
|
8
8
|
Requires-Dist: pytest>=8 ; extra == 'test'
|
|
9
9
|
Provides-Extra: test
|
|
10
|
-
License-File: LICENSE
|
|
11
10
|
Summary: Budget‑constrained JSON preview renderer (Python bindings)
|
|
12
11
|
Keywords: json,preview,summarize,cli,bindings
|
|
13
12
|
Requires-Python: >=3.10
|
|
@@ -21,7 +20,7 @@ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
|
21
20
|
<br/>
|
|
22
21
|
</p>
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
`heal`/`tail` for JSON, YAML - but structure‑aware. Get a compact preview that shows both the shape and representative values of your data, all within a strict character budget. (Just like `head`/`tail`, `headson` can also work with unstructured text files.)
|
|
25
24
|
|
|
26
25
|
Available as:
|
|
27
26
|
- CLI (see [Usage](#usage))
|
|
@@ -41,11 +40,15 @@ From source:
|
|
|
41
40
|
|
|
42
41
|
## Features
|
|
43
42
|
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
43
|
+
- Budgeted output: specify exactly how much you want to see
|
|
44
|
+
- Output formats: `auto | json | yaml | text`
|
|
45
|
+
- Styles: `strict | default | detailed`
|
|
46
|
+
- JSON family: `strict` → strict JSON, `default` → human‑friendly Pseudo, `detailed` → JS with inline comments
|
|
47
|
+
- YAML: always YAML; `strict` has no comments, `default` uses “# …”, `detailed` uses “# N more …”
|
|
48
|
+
- Text: prints raw lines. In `default` style, omissions are shown as a single line `…`; in `detailed`, as `… N more lines …`. `strict` omits array‑level summaries.
|
|
49
|
+
- Multiple inputs: preview many files at once with a shared or per‑file budget
|
|
50
|
+
- Fast: processes gigabyte‑scale files in seconds (mostly disk‑bound)
|
|
51
|
+
- Available as a CLI app and as a Python library
|
|
49
52
|
|
|
50
53
|
## Fits into command line workflows
|
|
51
54
|
|
|
@@ -59,47 +62,74 @@ If you’re comfortable with tools like `head` and `tail`, use `headson` when yo
|
|
|
59
62
|
|
|
60
63
|
headson [FLAGS] [INPUT...]
|
|
61
64
|
|
|
62
|
-
- INPUT (optional, repeatable): file path(s). If omitted, reads
|
|
65
|
+
- INPUT (optional, repeatable): file path(s). If omitted, reads from stdin. Multiple input files are supported.
|
|
63
66
|
- Prints the preview to stdout. On parse errors, exits non‑zero and prints an error to stderr.
|
|
64
67
|
|
|
65
68
|
Common flags:
|
|
66
69
|
|
|
67
|
-
- `-n, --budget <BYTES>`: per‑file output budget.
|
|
68
|
-
- `-N, --global-budget <BYTES>`: total output budget across all inputs.
|
|
69
|
-
|
|
70
|
-
-
|
|
70
|
+
- `-n, --budget <BYTES>`: per‑file output budget. For multiple inputs, default total budget is `<BYTES> * number_of_inputs`.
|
|
71
|
+
- `-N, --global-budget <BYTES>`: total output budget across all inputs. With `--budget`, the effective total is the smaller of the two.
|
|
72
|
+
- `-f, --format <auto|json|yaml|text>`: output format (default: `auto`).
|
|
73
|
+
- Auto: stdin → JSON family; filesets → per‑file based on extension (`.json` → JSON family, `.yaml`/`.yml` → YAML, unknown → Text).
|
|
74
|
+
- `-t, --template <strict|default|detailed>`: output style (default: `default`).
|
|
75
|
+
- JSON family: `strict` → strict JSON; `default` → Pseudo; `detailed` → JS with inline comments.
|
|
76
|
+
- YAML: always YAML; style only affects comments (`strict` none, `default` “# …”, `detailed` “# N more …”).
|
|
77
|
+
- `-i, --input-format <json|yaml|text>`: ingestion format (default: `json`). For filesets in `auto` format, ingestion is chosen by extensions.
|
|
71
78
|
- `-m, --compact`: no indentation, no spaces, no newlines
|
|
72
79
|
- `--no-newline`: single line output
|
|
73
80
|
- `--no-space`: no space after `:` in objects
|
|
74
81
|
- `--indent <STR>`: indentation unit (default: two spaces)
|
|
75
82
|
- `--string-cap <N>`: max graphemes to consider per string (default: 500)
|
|
76
|
-
- `--head`: prefer the beginning of arrays when truncating (keep first N). Strings are unaffected.
|
|
77
|
-
- `--tail`: prefer the end of arrays when truncating (keep last N). Strings are unaffected.
|
|
83
|
+
- `--head`: prefer the beginning of arrays when truncating (keep first N). Strings are unaffected. Display styles place omission markers accordingly; strict JSON remains unannotated. Mutually exclusive with `--tail`.
|
|
84
|
+
- `--tail`: prefer the end of arrays when truncating (keep last N). Strings are unaffected. Display styles place omission markers accordingly; strict JSON remains unannotated. Mutually exclusive with `--head`.
|
|
78
85
|
|
|
79
86
|
Notes:
|
|
80
87
|
|
|
81
|
-
-
|
|
82
|
-
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
-
|
|
86
|
-
- The tool finds the largest preview that fits the budget;
|
|
87
|
-
-
|
|
88
|
-
- Head vs Tail sampling: these options bias which part of arrays are kept before rendering.
|
|
88
|
+
- Multiple inputs:
|
|
89
|
+
- With newlines enabled, file sections are rendered with human‑readable headers. In compact/single‑line modes, headers are omitted.
|
|
90
|
+
- In `--format auto`, each file uses its own best format: JSON family for `.json`, YAML for `.yaml`/`.yml`.
|
|
91
|
+
- Unknown extensions are treated as Text (raw lines) — safe for logs and `.txt` files.
|
|
92
|
+
- `--global-budget` may truncate or omit entire files to respect the total budget.
|
|
93
|
+
- The tool finds the largest preview that fits the budget; even if extremely tight, you still get a minimal, valid preview.
|
|
94
|
+
- Directories and binary files are ignored; a notice is printed to stderr for each. Stdin reads the stream as‑is.
|
|
95
|
+
- Head vs Tail sampling: these options bias which part of arrays are kept before rendering. Display styles may still insert internal gap markers to honor very small budgets; strict JSON stays unannotated.
|
|
89
96
|
|
|
90
97
|
Quick one‑liners:
|
|
91
98
|
|
|
92
99
|
- Peek a big JSON stream (keeps structure):
|
|
93
100
|
|
|
94
|
-
zstdcat huge.json.zst | headson -n 800 -f
|
|
101
|
+
zstdcat huge.json.zst | headson -n 800 -f json -t default
|
|
95
102
|
|
|
96
103
|
- Many files with a fixed overall size:
|
|
97
104
|
|
|
98
|
-
headson -N 1200 -f json logs/*.json
|
|
105
|
+
headson -N 1200 -f json -t strict logs/*.json
|
|
99
106
|
|
|
100
107
|
- Glance at a file, JavaScript‑style comments for omissions:
|
|
101
108
|
|
|
102
|
-
headson -n 400 -f
|
|
109
|
+
headson -n 400 -f json -t detailed data.json
|
|
110
|
+
|
|
111
|
+
- YAML with detailed comments:
|
|
112
|
+
|
|
113
|
+
headson -n 400 -f yaml -t detailed config.yaml
|
|
114
|
+
|
|
115
|
+
### Text mode
|
|
116
|
+
|
|
117
|
+
- Single file (auto):
|
|
118
|
+
|
|
119
|
+
headson -n 200 notes.txt
|
|
120
|
+
|
|
121
|
+
- Force Text ingest/output (useful when mixing with other extensions):
|
|
122
|
+
|
|
123
|
+
headson -n 200 -i text -f text notes.txt
|
|
124
|
+
|
|
125
|
+
- Many text files (fileset):
|
|
126
|
+
|
|
127
|
+
headson -n 800 -i text -f text logs/*.txt
|
|
128
|
+
|
|
129
|
+
- Styles on Text:
|
|
130
|
+
- default: omission as a standalone `…` line.
|
|
131
|
+
- detailed: omission as `… N more lines …`.
|
|
132
|
+
- strict: no array‑level omission line (individual long lines may still truncate with `…`).
|
|
103
133
|
|
|
104
134
|
Show help:
|
|
105
135
|
|
|
@@ -120,10 +150,10 @@ jq -c . users.json | head -c 80
|
|
|
120
150
|
# {"users":[{"id":1,"name":"Ana","roles":["admin","dev"]},{"id":2,"name":"Bo"}],"me
|
|
121
151
|
```
|
|
122
152
|
|
|
123
|
-
Structured preview with headson (
|
|
153
|
+
Structured preview with headson (JSON family, default style → Pseudo):
|
|
124
154
|
|
|
125
155
|
```bash
|
|
126
|
-
headson -n 120 -f
|
|
156
|
+
headson -n 120 -f json -t default users.json
|
|
127
157
|
# {
|
|
128
158
|
# users: [
|
|
129
159
|
# { id: 1, name: "Ana", roles: [ "admin", … ] },
|
|
@@ -133,10 +163,10 @@ headson -n 120 -f pseudo users.json
|
|
|
133
163
|
# }
|
|
134
164
|
```
|
|
135
165
|
|
|
136
|
-
Machine‑readable preview (
|
|
166
|
+
Machine‑readable preview (JSON family, strict style → strict JSON):
|
|
137
167
|
|
|
138
168
|
```bash
|
|
139
|
-
headson -n 120 -f json users.json
|
|
169
|
+
headson -n 120 -f json -t strict users.json
|
|
140
170
|
# {"users":[{"id":1,"name":"Ana","roles":["admin"]}],"meta":{"count":2}}
|
|
141
171
|
```
|
|
142
172
|
|
|
@@ -148,36 +178,44 @@ Regenerate locally:
|
|
|
148
178
|
- Run: cargo make tapes
|
|
149
179
|
- Outputs are written to docs/assets/tapes
|
|
150
180
|
|
|
181
|
+
|
|
151
182
|
## Python Bindings
|
|
152
183
|
|
|
153
184
|
A thin Python extension module is available on PyPI as `headson`.
|
|
154
185
|
|
|
155
|
-
|
|
186
|
+
- Install: `pip install headson` (ABI3 wheels for Python 3.10+ on Linux/macOS/Windows).
|
|
156
187
|
- API:
|
|
157
|
-
- `headson.summarize(text: str, *,
|
|
158
|
-
- `
|
|
188
|
+
- `headson.summarize(text: str, *, format: str = "auto", style: str = "default", input_format: str = "json", character_budget: int | None = None, skew: str = "balanced") -> str`
|
|
189
|
+
- `format`: `"auto" | "json" | "yaml"` (auto maps to JSON family for single inputs)
|
|
190
|
+
- `style`: `"strict" | "default" | "detailed"`
|
|
191
|
+
- `input_format`: `"json" | "yaml"` (ingestion)
|
|
159
192
|
- `character_budget`: maximum output size in characters (default: 500)
|
|
160
|
-
- `skew`:
|
|
193
|
+
- `skew`: `"balanced" | "head" | "tail"` (affects display styles; strict JSON remains unannotated)
|
|
161
194
|
|
|
162
|
-
|
|
195
|
+
Examples:
|
|
163
196
|
|
|
164
197
|
```python
|
|
165
198
|
import json
|
|
166
199
|
import headson
|
|
167
200
|
|
|
168
201
|
data = {"foo": [1, 2, 3], "bar": {"x": "y"}}
|
|
169
|
-
preview = headson.summarize(json.dumps(data),
|
|
202
|
+
preview = headson.summarize(json.dumps(data), format="json", style="strict", character_budget=200)
|
|
170
203
|
print(preview)
|
|
171
204
|
|
|
172
|
-
# Prefer the tail of arrays (annotations show
|
|
205
|
+
# Prefer the tail of arrays (annotations show with style="default"/"detailed")
|
|
173
206
|
print(
|
|
174
207
|
headson.summarize(
|
|
175
208
|
json.dumps(list(range(100))),
|
|
176
|
-
|
|
209
|
+
format="json",
|
|
210
|
+
style="detailed",
|
|
177
211
|
character_budget=80,
|
|
178
212
|
skew="tail",
|
|
179
213
|
)
|
|
180
214
|
)
|
|
215
|
+
|
|
216
|
+
# YAML support
|
|
217
|
+
doc = "root:\n items: [1,2,3,4,5,6,7,8,9,10]\n"
|
|
218
|
+
print(headson.summarize(doc, format="yaml", style="default", input_format="yaml", character_budget=60))
|
|
181
219
|
```
|
|
182
220
|
|
|
183
221
|
# Algorithm
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
headson-0.6.3.dist-info/METADATA,sha256=1KJILJz19mAFsItaIP8HJGiyDyUZyOGqQSQEQxcjRoE,10720
|
|
2
|
+
headson-0.6.3.dist-info/WHEEL,sha256=4EDp_7DiFfWl1yYv5M4wSosAn5L_xgD1dyrQxQxfCx8,95
|
|
3
|
+
headson/__init__.py,sha256=Z-vwzLN9ptomZrtRqVUuUKSAaidOSVcjFI6Ojbuj-dU,219
|
|
4
|
+
headson/headson.pyd,sha256=9tzAWWQGEgz4Al25c_oAHG2cQIEv3sqBTyXXavPRnMk,773632
|
|
5
|
+
headson-0.6.3.dist-info/RECORD,,
|
headson-0.6.1.dist-info/RECORD
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
headson-0.6.1.dist-info/METADATA,sha256=K9PGA8lKK8Z8DS36LgA-mNreoL7x_gQ1mnjgatV3Z4E,9188
|
|
2
|
-
headson-0.6.1.dist-info/WHEEL,sha256=4EDp_7DiFfWl1yYv5M4wSosAn5L_xgD1dyrQxQxfCx8,95
|
|
3
|
-
headson-0.6.1.dist-info/licenses/LICENSE,sha256=85XxIce4vPe2JysuORWOYpzGI-ypir_79W6aOF8y534,1093
|
|
4
|
-
headson/__init__.py,sha256=8DXFB8ahlywyQXJsscl3w_wgbcQi7sj7zEuV28wR60E,187
|
|
5
|
-
headson/headson.pyd,sha256=zFa5yaOO1Ehn44y61G7i6pJSCvvS3q08b9VGKTYoruk,459776
|
|
6
|
-
headson-0.6.1.dist-info/RECORD,,
|
|
@@ -1,21 +0,0 @@
|
|
|
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.
|
|
File without changes
|