headson 0.6.0__cp310-abi3-win_amd64.whl → 0.6.2__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 CHANGED
@@ -1,6 +1,11 @@
1
1
  from __future__ import annotations
2
2
 
3
- # Directly re-export the compiled extension function with the final signature.
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,27 +1,26 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: headson
3
- Version: 0.6.0
3
+ Version: 0.6.2
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
14
13
  Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
15
14
 
16
15
  <h1 align="center">
17
- <img src="https://raw.githubusercontent.com/kantord/headson/main/docs/assets/logo.svg" alt="headson" width="600" height="99" />
16
+ <img src="https://raw.githubusercontent.com/kantord/headson/main/docs/assets/logo.svg" alt="headson" width="221" />
18
17
  </h1>
19
18
  <p align="center">
20
19
  <img src="https://raw.githubusercontent.com/kantord/headson/main/docs/assets/tapes/demo.gif" alt="Terminal demo" width="1560" height="900" />
21
20
  <br/>
22
21
  </p>
23
22
 
24
- 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.
23
+ Head/tail for JSON and 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.
25
24
 
26
25
  Available as:
27
26
  - CLI (see [Usage](#usage))
@@ -41,11 +40,14 @@ From source:
41
40
 
42
41
  ## Features
43
42
 
44
- - *Budgeted output*: specify exactly how much JSON you want to see
45
- - *Multiple output formats* : `json` (machine‑readable), `pseudo` (human‑friendly), `js` (valid JavaScript, most detailed metadata).
46
- - *Multiple inputs*: preview many files at once with a shared or per‑file budget.
47
- - *Fast*: can process gigabyte-scale files in seconds (mostly disk-constrained)
48
- - *Available as a CLI app and as a Python library*
43
+ - Budgeted output: specify exactly how much you want to see
44
+ - Output formats: `auto | json | yaml`
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
+ - Multiple inputs: preview many files at once with a shared or per‑file budget
49
+ - Fast: processes gigabyte‑scale files in seconds (mostly disk‑bound)
50
+ - Available as a CLI app and as a Python library
49
51
 
50
52
  ## Fits into command line workflows
51
53
 
@@ -59,47 +61,54 @@ If you’re comfortable with tools like `head` and `tail`, use `headson` when yo
59
61
 
60
62
  headson [FLAGS] [INPUT...]
61
63
 
62
- - INPUT (optional, repeatable): file path(s). If omitted, reads JSON from stdin. Multiple input files are supported.
64
+ - INPUT (optional, repeatable): file path(s). If omitted, reads from stdin. Multiple input files are supported.
63
65
  - Prints the preview to stdout. On parse errors, exits non‑zero and prints an error to stderr.
64
66
 
65
67
  Common flags:
66
68
 
67
- - `-n, --budget <BYTES>`: per‑file output budget. When multiple input files are provided, the default total budget equals `<BYTES> * number_of_inputs`.
68
- - `-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).
69
- - When used together with `--budget`, the final total budget is `min(global, per_file * number_of_inputs)`. Files are only truncated if they don't fit into this final global limit, and no single file expands beyond the per‑file budget.
70
- - `-f, --template <json|pseudo|js>`: output style (default: `pseudo`)
69
+ - `-n, --budget <BYTES>`: per‑file output budget. For multiple inputs, default total budget is `<BYTES> * number_of_inputs`.
70
+ - `-N, --global-budget <BYTES>`: total output budget across all inputs. With `--budget`, the effective total is the smaller of the two.
71
+ - `-f, --format <auto|json|yaml>`: output format (default: `auto`).
72
+ - Auto: stdin JSON family; filesets → per‑file based on extension (`.json` → JSON family, `.yaml`/`.yml` → YAML).
73
+ - `-t, --template <strict|default|detailed>`: output style (default: `default`).
74
+ - JSON family: `strict` → strict JSON; `default` → Pseudo; `detailed` → JS with inline comments.
75
+ - YAML: always YAML; style only affects comments (`strict` none, `default` “# …”, `detailed` “# N more …”).
76
+ - `-i, --input-format <json|yaml>`: ingestion format (default: `json`). For filesets in `auto` format, ingestion is chosen by extensions.
71
77
  - `-m, --compact`: no indentation, no spaces, no newlines
72
78
  - `--no-newline`: single line output
73
79
  - `--no-space`: no space after `:` in objects
74
80
  - `--indent <STR>`: indentation unit (default: two spaces)
75
81
  - `--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. In `pseudo`/`js` templates the omission marker appears near the end; `json` remains strict. Mutually exclusive with `--tail`.
77
- - `--tail`: prefer the end of arrays when truncating (keep last N). Strings are unaffected. In `pseudo`/`js` templates the omission marker appears at the start; `json` remains strict. Mutually exclusive with `--head`.
82
+ - `--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`.
83
+ - `--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
84
 
79
85
  Notes:
80
86
 
81
- - With multiple input files:
82
- - JSON template outputs a single JSON object keyed by the input file paths.
83
- - Pseudo and JS templates render file sections with human-readable headers when newlines are enabled.
84
- - 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.
85
- - Using `--global-budget` may truncate or omit entire files to respect the total budget.
86
- - The tool finds the largest preview that fits the budget; if even the tiniest preview exceeds it, you still get a minimal, valid preview.
87
- - 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.
88
- - Head vs Tail sampling: these options bias which part of arrays are kept before rendering. They guarantee the kept segment is contiguous at the chosen side (prefix for `--head`, suffix for `--tail`). Display templates may still insert additional internal gap markers inside that kept segment to honor very small budgets; `json` remains strict and unannotated.
87
+ - Multiple inputs:
88
+ - With newlines enabled, file sections are rendered with human‑readable headers. In compact/single‑line modes, headers are omitted.
89
+ - In `--format auto`, each file uses its own best format: JSON family for `.json`, YAML for `.yaml`/`.yml`.
90
+ - `--global-budget` may truncate or omit entire files to respect the total budget.
91
+ - The tool finds the largest preview that fits the budget; even if extremely tight, you still get a minimal, valid preview.
92
+ - Directories and binary files are ignored; a notice is printed to stderr for each. Stdin reads the stream as‑is.
93
+ - 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
94
 
90
95
  Quick one‑liners:
91
96
 
92
97
  - Peek a big JSON stream (keeps structure):
93
98
 
94
- zstdcat huge.json.zst | headson -n 800 -f pseudo
99
+ zstdcat huge.json.zst | headson -n 800 -f json -t default
95
100
 
96
101
  - Many files with a fixed overall size:
97
102
 
98
- headson -N 1200 -f json logs/*.json
103
+ headson -N 1200 -f json -t strict logs/*.json
99
104
 
100
105
  - Glance at a file, JavaScript‑style comments for omissions:
101
106
 
102
- headson -n 400 -f js data.json
107
+ headson -n 400 -f json -t detailed data.json
108
+
109
+ - YAML with detailed comments:
110
+
111
+ headson -n 400 -f yaml -t detailed config.yaml
103
112
 
104
113
  Show help:
105
114
 
@@ -120,10 +129,10 @@ jq -c . users.json | head -c 80
120
129
  # {"users":[{"id":1,"name":"Ana","roles":["admin","dev"]},{"id":2,"name":"Bo"}],"me
121
130
  ```
122
131
 
123
- Structured preview with headson (pseudo):
132
+ Structured preview with headson (JSON family, default style → Pseudo):
124
133
 
125
134
  ```bash
126
- headson -n 120 -f pseudo users.json
135
+ headson -n 120 -f json -t default users.json
127
136
  # {
128
137
  # users: [
129
138
  # { id: 1, name: "Ana", roles: [ "admin", … ] },
@@ -133,10 +142,10 @@ headson -n 120 -f pseudo users.json
133
142
  # }
134
143
  ```
135
144
 
136
- Machine‑readable preview (json):
145
+ Machine‑readable preview (JSON family, strict style → strict JSON):
137
146
 
138
147
  ```bash
139
- headson -n 120 -f json users.json
148
+ headson -n 120 -f json -t strict users.json
140
149
  # {"users":[{"id":1,"name":"Ana","roles":["admin"]}],"meta":{"count":2}}
141
150
  ```
142
151
 
@@ -152,32 +161,39 @@ Regenerate locally:
152
161
 
153
162
  A thin Python extension module is available on PyPI as `headson`.
154
163
 
155
- - Install: `pip install headson` (ABI3 wheels for Python 3.10+ on Linux/macOS/Windows).
164
+ - Install: `pip install headson` (ABI3 wheels for Python 3.10+ on Linux/macOS/Windows).
156
165
  - API:
157
- - `headson.summarize(text: str, *, template: str = "pseudo", character_budget: int | None = None, skew: str = "balanced") -> str`
158
- - `template`: one of `"json" | "pseudo" | "js"`
166
+ - `headson.summarize(text: str, *, format: str = "auto", style: str = "default", input_format: str = "json", character_budget: int | None = None, skew: str = "balanced") -> str`
167
+ - `format`: `"auto" | "json" | "yaml"` (auto maps to JSON family for single inputs)
168
+ - `style`: `"strict" | "default" | "detailed"`
169
+ - `input_format`: `"json" | "yaml"` (ingestion)
159
170
  - `character_budget`: maximum output size in characters (default: 500)
160
- - `skew`: one of `"balanced" | "head" | "tail"` (focus arrays on start vs end; only affects display templates; `json` remains strict).
171
+ - `skew`: `"balanced" | "head" | "tail"` (affects display styles; strict JSON remains unannotated)
161
172
 
162
- Example:
173
+ Examples:
163
174
 
164
175
  ```python
165
176
  import json
166
177
  import headson
167
178
 
168
179
  data = {"foo": [1, 2, 3], "bar": {"x": "y"}}
169
- preview = headson.summarize(json.dumps(data), template="json", character_budget=200)
180
+ preview = headson.summarize(json.dumps(data), format="json", style="strict", character_budget=200)
170
181
  print(preview)
171
182
 
172
- # Prefer the tail of arrays (annotations show in pseudo/js only)
183
+ # Prefer the tail of arrays (annotations show with style="default"/"detailed")
173
184
  print(
174
185
  headson.summarize(
175
186
  json.dumps(list(range(100))),
176
- template="pseudo",
187
+ format="json",
188
+ style="detailed",
177
189
  character_budget=80,
178
190
  skew="tail",
179
191
  )
180
192
  )
193
+
194
+ # YAML support
195
+ doc = "root:\n items: [1,2,3,4,5,6,7,8,9,10]\n"
196
+ print(headson.summarize(doc, format="yaml", style="default", input_format="yaml", character_budget=60))
181
197
  ```
182
198
 
183
199
  # Algorithm
@@ -0,0 +1,5 @@
1
+ headson-0.6.2.dist-info/METADATA,sha256=JhObjCQ0LKxqCUg2YdJlE272hAKGob8KhXCcyh0Pa2s,9831
2
+ headson-0.6.2.dist-info/WHEEL,sha256=4EDp_7DiFfWl1yYv5M4wSosAn5L_xgD1dyrQxQxfCx8,95
3
+ headson/__init__.py,sha256=Z-vwzLN9ptomZrtRqVUuUKSAaidOSVcjFI6Ojbuj-dU,219
4
+ headson/headson.pyd,sha256=1u6Iy8XUOfv_zPDCcGp5Sht0CRrgYBQ5Sav2GNw1Cwg,762368
5
+ headson-0.6.2.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- headson-0.6.0.dist-info/METADATA,sha256=AxtHQvHsqv_T5_1sgfNtmmZn8b0a0P6ebd8GHQojjes,9200
2
- headson-0.6.0.dist-info/WHEEL,sha256=4EDp_7DiFfWl1yYv5M4wSosAn5L_xgD1dyrQxQxfCx8,95
3
- headson-0.6.0.dist-info/licenses/LICENSE,sha256=85XxIce4vPe2JysuORWOYpzGI-ypir_79W6aOF8y534,1093
4
- headson/__init__.py,sha256=8DXFB8ahlywyQXJsscl3w_wgbcQi7sj7zEuV28wR60E,187
5
- headson/headson.pyd,sha256=KD0sgt4VnL5Ed4x6GthplcD-falqdOqatYgtsBSK-oY,459776
6
- headson-0.6.0.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.