headson 0.5.2__tar.gz → 0.5.3__tar.gz

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.
Files changed (52) hide show
  1. {headson-0.5.2 → headson-0.5.3}/Cargo.lock +1 -1
  2. {headson-0.5.2 → headson-0.5.3}/Cargo.toml +1 -1
  3. {headson-0.5.2 → headson-0.5.3}/PKG-INFO +5 -4
  4. {headson-0.5.2 → headson-0.5.3}/README.md +4 -3
  5. {headson-0.5.2 → headson-0.5.3}/pyproject.toml +1 -1
  6. {headson-0.5.2 → headson-0.5.3}/python/Cargo.lock +2 -2
  7. {headson-0.5.2 → headson-0.5.3}/python/Cargo.toml +1 -1
  8. {headson-0.5.2 → headson-0.5.3}/src/main.rs +16 -9
  9. {headson-0.5.2 → headson-0.5.3}/JSONTestSuite/LICENSE +0 -0
  10. {headson-0.5.2 → headson-0.5.3}/JSONTestSuite/README.md +0 -0
  11. {headson-0.5.2 → headson-0.5.3}/LICENSE +0 -0
  12. {headson-0.5.2 → headson-0.5.3}/docs/assets/algorithm.svg +0 -0
  13. {headson-0.5.2 → headson-0.5.3}/python/README.md +0 -0
  14. {headson-0.5.2 → headson-0.5.3}/python/headson/__init__.py +0 -0
  15. {headson-0.5.2 → headson-0.5.3}/python/src/lib.rs +0 -0
  16. {headson-0.5.2 → headson-0.5.3}/src/json_ingest/builder.rs +0 -0
  17. {headson-0.5.2 → headson-0.5.3}/src/json_ingest/mod.rs +0 -0
  18. {headson-0.5.2 → headson-0.5.3}/src/json_ingest/samplers/default.rs +0 -0
  19. {headson-0.5.2 → headson-0.5.3}/src/json_ingest/samplers/head.rs +0 -0
  20. {headson-0.5.2 → headson-0.5.3}/src/json_ingest/samplers/mod.rs +0 -0
  21. {headson-0.5.2 → headson-0.5.3}/src/json_ingest/samplers/tail.rs +0 -0
  22. {headson-0.5.2 → headson-0.5.3}/src/lib.rs +0 -0
  23. {headson-0.5.2 → headson-0.5.3}/src/order/build.rs +0 -0
  24. {headson-0.5.2 → headson-0.5.3}/src/order/mod.rs +0 -0
  25. {headson-0.5.2 → headson-0.5.3}/src/order/scoring.rs +0 -0
  26. {headson-0.5.2 → headson-0.5.3}/src/order/snapshots/headson__order__build__tests__order_empty_array_order.snap +0 -0
  27. {headson-0.5.2 → headson-0.5.3}/src/order/snapshots/headson__order__build__tests__order_single_string_array_order.snap +0 -0
  28. {headson-0.5.2 → headson-0.5.3}/src/order/types.rs +0 -0
  29. {headson-0.5.2 → headson-0.5.3}/src/serialization/fileset.rs +0 -0
  30. {headson-0.5.2 → headson-0.5.3}/src/serialization/mod.rs +0 -0
  31. {headson-0.5.2 → headson-0.5.3}/src/serialization/snapshots/headson__serialization__tests__arena_render_empty.snap +0 -0
  32. {headson-0.5.2 → headson-0.5.3}/src/serialization/snapshots/headson__serialization__tests__arena_render_single.snap +0 -0
  33. {headson-0.5.2 → headson-0.5.3}/src/serialization/templates/core.rs +0 -0
  34. {headson-0.5.2 → headson-0.5.3}/src/serialization/templates/js.rs +0 -0
  35. {headson-0.5.2 → headson-0.5.3}/src/serialization/templates/json.rs +0 -0
  36. {headson-0.5.2 → headson-0.5.3}/src/serialization/templates/mod.rs +0 -0
  37. {headson-0.5.2 → headson-0.5.3}/src/serialization/templates/pseudo.rs +0 -0
  38. {headson-0.5.2 → headson-0.5.3}/src/serialization/types.rs +0 -0
  39. {headson-0.5.2 → headson-0.5.3}/src/snapshots/headson__order__tests__order_empty_array_order.snap +0 -0
  40. {headson-0.5.2 → headson-0.5.3}/src/snapshots/headson__order__tests__order_single_string_array_order.snap +0 -0
  41. {headson-0.5.2 → headson-0.5.3}/src/snapshots/headson__order__tests__pq_empty_array_queue.snap +0 -0
  42. {headson-0.5.2 → headson-0.5.3}/src/snapshots/headson__order__tests__pq_single_string_array_queue.snap +0 -0
  43. {headson-0.5.2 → headson-0.5.3}/src/snapshots/headson__queue__tests__pq_empty_array_queue.snap +0 -0
  44. {headson-0.5.2 → headson-0.5.3}/src/snapshots/headson__queue__tests__pq_single_string_array_queue.snap +0 -0
  45. {headson-0.5.2 → headson-0.5.3}/src/snapshots/headson__tree__tests__build_tree_empty.snap +0 -0
  46. {headson-0.5.2 → headson-0.5.3}/src/snapshots/headson__tree__tests__build_tree_single.snap +0 -0
  47. {headson-0.5.2 → headson-0.5.3}/src/utils/graph.rs +0 -0
  48. {headson-0.5.2 → headson-0.5.3}/src/utils/json.rs +0 -0
  49. {headson-0.5.2 → headson-0.5.3}/src/utils/mod.rs +0 -0
  50. {headson-0.5.2 → headson-0.5.3}/src/utils/search.rs +0 -0
  51. {headson-0.5.2 → headson-0.5.3}/src/utils/text.rs +0 -0
  52. {headson-0.5.2 → headson-0.5.3}/src/utils/tree_arena.rs +0 -0
@@ -266,7 +266,7 @@ dependencies = [
266
266
 
267
267
  [[package]]
268
268
  name = "headson"
269
- version = "0.5.2"
269
+ version = "0.5.3"
270
270
  dependencies = [
271
271
  "anyhow",
272
272
  "assert_cmd",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "headson"
3
- version = "0.5.2"
3
+ version = "0.5.3"
4
4
  edition = "2024"
5
5
  description = "Budget‑constrained JSON preview renderer"
6
6
  readme = "README.md"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: headson
3
- Version: 0.5.2
3
+ Version: 0.5.3
4
4
  Classifier: Programming Language :: Python
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Classifier: Programming Language :: Rust
@@ -58,8 +58,9 @@ If you’re comfortable with tools like `head` and `tail`, use `headson` when yo
58
58
 
59
59
  Common flags:
60
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`.
61
+ - `-n, --budget <BYTES>`: per‑file output budget. When multiple input files are provided, the default 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).
63
+ - 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.
63
64
  - `-f, --template <json|pseudo|js>`: output style (default: `pseudo`)
64
65
  - `-m, --compact`: no indentation, no spaces, no newlines
65
66
  - `--no-newline`: single line output
@@ -167,7 +168,7 @@ print(
167
168
 
168
169
  # Algorithm
169
170
 
170
- ![Algorithm overview](docs/assets/algorithm.svg)
171
+ ![Algorithm overview](https://raw.githubusercontent.com/kantord/headson/main/docs/assets/algorithm.svg)
171
172
 
172
173
  ## Footnotes
173
174
  - <sup><b>[1]</b></sup> <b>Optimized tree representation</b>: An arena‑style tree stored in flat, contiguous buffers. Each node records its kind and value plus index ranges into shared child and key arrays. Arrays are ingested in a single pass and may be deterministically pre‑sampled: the first element is always kept; additional elements are selected via a fixed per‑index inclusion test; for kept elements, original indices are stored and full lengths are counted. This enables accurate omission info and internal gap markers later, while minimizing pointer chasing.
@@ -43,8 +43,9 @@ If you’re comfortable with tools like `head` and `tail`, use `headson` when yo
43
43
 
44
44
  Common flags:
45
45
 
46
- - `-n, --budget <BYTES>`: per‑file output budget. When multiple input files are provided, the total budget equals `<BYTES> * number_of_inputs`.
47
- - `-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`.
46
+ - `-n, --budget <BYTES>`: per‑file output budget. When multiple input files are provided, the default total budget equals `<BYTES> * number_of_inputs`.
47
+ - `-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).
48
+ - 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.
48
49
  - `-f, --template <json|pseudo|js>`: output style (default: `pseudo`)
49
50
  - `-m, --compact`: no indentation, no spaces, no newlines
50
51
  - `--no-newline`: single line output
@@ -152,7 +153,7 @@ print(
152
153
 
153
154
  # Algorithm
154
155
 
155
- ![Algorithm overview](docs/assets/algorithm.svg)
156
+ ![Algorithm overview](https://raw.githubusercontent.com/kantord/headson/main/docs/assets/algorithm.svg)
156
157
 
157
158
  ## Footnotes
158
159
  - <sup><b>[1]</b></sup> <b>Optimized tree representation</b>: An arena‑style tree stored in flat, contiguous buffers. Each node records its kind and value plus index ranges into shared child and key arrays. Arrays are ingested in a single pass and may be deterministically pre‑sampled: the first element is always kept; additional elements are selected via a fixed per‑index inclusion test; for kept elements, original indices are stored and full lengths are counted. This enables accurate omission info and internal gap markers later, while minimizing pointer chasing.
@@ -4,7 +4,7 @@ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "headson"
7
- version = "0.5.2"
7
+ version = "0.5.3"
8
8
  description = "Budget‑constrained JSON preview renderer (Python bindings)"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -169,7 +169,7 @@ dependencies = [
169
169
 
170
170
  [[package]]
171
171
  name = "headson"
172
- version = "0.5.2"
172
+ version = "0.5.3"
173
173
  dependencies = [
174
174
  "anyhow",
175
175
  "clap",
@@ -182,7 +182,7 @@ dependencies = [
182
182
 
183
183
  [[package]]
184
184
  name = "headson-python"
185
- version = "0.5.2"
185
+ version = "0.5.3"
186
186
  dependencies = [
187
187
  "anyhow",
188
188
  "headson",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "headson-python"
3
- version = "0.5.2"
3
+ version = "0.5.3"
4
4
  edition = "2021"
5
5
  publish = false
6
6
  readme = "README.md"
@@ -17,7 +17,7 @@ type IgnoreNotices = Vec<String>;
17
17
  about = "Get a small but useful preview of a JSON file"
18
18
  )]
19
19
  struct Cli {
20
- #[arg(short = 'n', long = "budget", conflicts_with = "global_budget")]
20
+ #[arg(short = 'n', long = "budget")]
21
21
  budget: Option<usize>,
22
22
  #[arg(short = 'f', long = "template", value_enum, default_value_t = Template::Pseudo)]
23
23
  template: Template,
@@ -49,8 +49,7 @@ struct Cli {
49
49
  short = 'N',
50
50
  long = "global-budget",
51
51
  value_name = "BYTES",
52
- conflicts_with = "budget",
53
- help = "Total output budget across all inputs; useful to keep multiple files within a fixed overall output size (may omit entire files)."
52
+ help = "Total output budget across all inputs. When combined with --budget, the effective global limit is the smaller of the two."
54
53
  )]
55
54
  global_budget: Option<usize>,
56
55
  #[arg(
@@ -101,11 +100,11 @@ fn main() -> Result<()> {
101
100
  }
102
101
 
103
102
  fn compute_effective_budget(cli: &Cli, input_count: usize) -> usize {
104
- if let Some(g) = cli.global_budget {
105
- g
106
- } else {
107
- let per_file = cli.budget.unwrap_or(500);
108
- per_file.saturating_mul(input_count)
103
+ match (cli.global_budget, cli.budget) {
104
+ (Some(g), Some(n)) => g.min(n.saturating_mul(input_count)),
105
+ (Some(g), None) => g,
106
+ (None, Some(n)) => n.saturating_mul(input_count),
107
+ (None, None) => 500usize.saturating_mul(input_count),
109
108
  }
110
109
  }
111
110
 
@@ -114,7 +113,15 @@ fn compute_priority(
114
113
  effective_budget: usize,
115
114
  input_count: usize,
116
115
  ) -> headson::PriorityConfig {
117
- let per_file_for_priority = (effective_budget / input_count.max(1)).max(1);
116
+ let per_file_for_priority =
117
+ if cli.global_budget.is_some() && cli.budget.is_some() {
118
+ // When both limits are provided, base per-file heuristics on the per-file
119
+ // budget but also respect the effective per-file slice of the final global.
120
+ let eff_per_file = (effective_budget / input_count.max(1)).max(1);
121
+ cli.budget.unwrap().min(eff_per_file).max(1)
122
+ } else {
123
+ (effective_budget / input_count.max(1)).max(1)
124
+ };
118
125
  get_priority_config(per_file_for_priority, cli)
119
126
  }
120
127
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes