headson 0.2.4__cp310-cp310-macosx_11_0_arm64.whl → 0.3.0__cp310-cp310-macosx_11_0_arm64.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.
- headson/headson.cpython-310-darwin.so +0 -0
- headson-0.3.0.dist-info/METADATA +168 -0
- headson-0.3.0.dist-info/RECORD +6 -0
- headson-0.2.4.dist-info/METADATA +0 -99
- headson-0.2.4.dist-info/RECORD +0 -6
- {headson-0.2.4.dist-info → headson-0.3.0.dist-info}/WHEEL +0 -0
- {headson-0.2.4.dist-info → headson-0.3.0.dist-info}/licenses/LICENSE +0 -0
|
Binary file
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: headson
|
|
3
|
+
Version: 0.3.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.8
|
|
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.
|
|
76
|
+
- Using `--global-budget` may truncate or omit entire files to respect the total budget.
|
|
77
|
+
- The tool finds the largest preview that fits the budget; if even the tiniest preview exceeds it, you still get a minimal, valid preview.
|
|
78
|
+
- 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.
|
|
79
|
+
|
|
80
|
+
Quick one‑liners:
|
|
81
|
+
|
|
82
|
+
- Peek a big JSON stream (keeps structure):
|
|
83
|
+
|
|
84
|
+
zstdcat huge.json.zst | headson -n 800 -f pseudo
|
|
85
|
+
|
|
86
|
+
- Many files with a fixed overall size:
|
|
87
|
+
|
|
88
|
+
headson -N 1200 -f json logs/*.json
|
|
89
|
+
|
|
90
|
+
- Glance at a file, JavaScript‑style comments for omissions:
|
|
91
|
+
|
|
92
|
+
headson -n 400 -f js data.json
|
|
93
|
+
|
|
94
|
+
Show help:
|
|
95
|
+
|
|
96
|
+
headson --help
|
|
97
|
+
|
|
98
|
+
## Examples: head vs headson
|
|
99
|
+
|
|
100
|
+
Input:
|
|
101
|
+
|
|
102
|
+
```json
|
|
103
|
+
{"users":[{"id":1,"name":"Ana","roles":["admin","dev"]},{"id":2,"name":"Bo"}],"meta":{"count":2,"source":"db"}}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Naive cut (can break mid‑token):
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
jq -c . users.json | head -c 80
|
|
110
|
+
# {"users":[{"id":1,"name":"Ana","roles":["admin","dev"]},{"id":2,"name":"Bo"}],"me
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Structured preview with headson (pseudo):
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
headson -n 120 -f pseudo users.json
|
|
117
|
+
# {
|
|
118
|
+
# users: [
|
|
119
|
+
# { id: 1, name: "Ana", roles: [ "admin", … ] },
|
|
120
|
+
# …
|
|
121
|
+
# ]
|
|
122
|
+
# meta: { count: 2, … }
|
|
123
|
+
# }
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Machine‑readable preview (json):
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
headson -n 120 -f json users.json
|
|
130
|
+
# {"users":[{"id":1,"name":"Ana","roles":["admin"]}],"meta":{"count":2}}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Python Bindings
|
|
134
|
+
|
|
135
|
+
A thin Python extension module is available on PyPI as `headson`.
|
|
136
|
+
|
|
137
|
+
- Install: `pip install headson` (prebuilt wheels for CPython 3.10–3.12 on Linux/macOS/Windows). Older/newer Python versions may build from source if Rust is installed.
|
|
138
|
+
- API:
|
|
139
|
+
- `headson.summarize(text: str, *, template: str = "pseudo", character_budget: int | None = None, tail: bool = False) -> str`
|
|
140
|
+
- `template`: one of `"json" | "pseudo" | "js"`
|
|
141
|
+
- `character_budget`: maximum output size in characters (default: 500)
|
|
142
|
+
- `tail`: prefer the end of arrays when truncating; strings unaffected. Affects only display templates (`pseudo`/`js`); `json` remains strict.
|
|
143
|
+
|
|
144
|
+
Example:
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
import json
|
|
148
|
+
import headson
|
|
149
|
+
|
|
150
|
+
data = {"foo": [1, 2, 3], "bar": {"x": "y"}}
|
|
151
|
+
preview = headson.summarize(json.dumps(data), template="json", character_budget=200)
|
|
152
|
+
print(preview)
|
|
153
|
+
|
|
154
|
+
# Prefer the tail of arrays (annotations show in pseudo/js only)
|
|
155
|
+
print(
|
|
156
|
+
headson.summarize(
|
|
157
|
+
json.dumps(list(range(100))),
|
|
158
|
+
template="pseudo",
|
|
159
|
+
character_budget=80,
|
|
160
|
+
tail=True,
|
|
161
|
+
)
|
|
162
|
+
)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## License
|
|
166
|
+
|
|
167
|
+
MIT
|
|
168
|
+
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
headson-0.3.0.dist-info/METADATA,sha256=0bqflJDLsUMe8qscFcISR6huZE7B9B8_3x2iraTSlIs,5751
|
|
2
|
+
headson-0.3.0.dist-info/WHEEL,sha256=PmVieto1wuHPE0V9Yj-HDpDcXvcgT7RQ6xfDnzOpcS8,104
|
|
3
|
+
headson-0.3.0.dist-info/licenses/LICENSE,sha256=GZ9row3L2LsnOSbEuGMQZ0zKOIEd5tHr76cZHpg4KK8,1072
|
|
4
|
+
headson/__init__.py,sha256=PnXEkHuT6aEqKi8lL11uZU2IZ5cGgFqfO43xShmpros,137
|
|
5
|
+
headson/headson.cpython-310-darwin.so,sha256=xQsAIfcWUUsOtn1tkHtCOS55tiVGrHcTUnPEAz_lfx4,604528
|
|
6
|
+
headson-0.3.0.dist-info/RECORD,,
|
headson-0.2.4.dist-info/METADATA
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: headson
|
|
3
|
-
Version: 0.2.4
|
|
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
|
-
- 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.
|
|
56
|
-
|
|
57
|
-
Examples:
|
|
58
|
-
|
|
59
|
-
- Read from stdin with defaults:
|
|
60
|
-
|
|
61
|
-
cat data.json | headson
|
|
62
|
-
|
|
63
|
-
- Read from file, JS style, 200‑byte budget:
|
|
64
|
-
|
|
65
|
-
headson -n 200 -f js data.json
|
|
66
|
-
|
|
67
|
-
- JSON style, compact:
|
|
68
|
-
|
|
69
|
-
headson -f json -m data.json
|
|
70
|
-
|
|
71
|
-
- Multiple files (JSON template produces an object keyed by paths):
|
|
72
|
-
|
|
73
|
-
headson -f json a.json b.json
|
|
74
|
-
|
|
75
|
-
- Global limit across files (fixed total size across all files):
|
|
76
|
-
|
|
77
|
-
headson -N 400 -f json a.json b.json
|
|
78
|
-
|
|
79
|
-
Show help:
|
|
80
|
-
|
|
81
|
-
headson --help
|
|
82
|
-
|
|
83
|
-
## Python package
|
|
84
|
-
|
|
85
|
-
Headson is also available as a Python extension module built with PyO3/maturin.
|
|
86
|
-
|
|
87
|
-
Install from PyPI:
|
|
88
|
-
|
|
89
|
-
pip install headson
|
|
90
|
-
|
|
91
|
-
Example:
|
|
92
|
-
|
|
93
|
-
import json
|
|
94
|
-
import headson
|
|
95
|
-
|
|
96
|
-
data = {"foo": [1, 2, 3], "bar": {"x": "y"}}
|
|
97
|
-
preview = headson.summarize(json.dumps(data), template="json", character_budget=200)
|
|
98
|
-
print(preview)
|
|
99
|
-
|
headson-0.2.4.dist-info/RECORD
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
headson-0.2.4.dist-info/METADATA,sha256=mxCvLWdv1YzVPeiptYxc2BXjgTd2oFwgq8PYNDbu54w,2967
|
|
2
|
-
headson-0.2.4.dist-info/WHEEL,sha256=PmVieto1wuHPE0V9Yj-HDpDcXvcgT7RQ6xfDnzOpcS8,104
|
|
3
|
-
headson-0.2.4.dist-info/licenses/LICENSE,sha256=GZ9row3L2LsnOSbEuGMQZ0zKOIEd5tHr76cZHpg4KK8,1072
|
|
4
|
-
headson/__init__.py,sha256=PnXEkHuT6aEqKi8lL11uZU2IZ5cGgFqfO43xShmpros,137
|
|
5
|
-
headson/headson.cpython-310-darwin.so,sha256=DMfMjQTV5ocAmIyOID9BX6uVqtEL6ewUyOWeeueoXzk,570848
|
|
6
|
-
headson-0.2.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|