pcf-toolkit 0.2.5__py3-none-any.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.
- pcf_toolkit/__init__.py +6 -0
- pcf_toolkit/cli.py +738 -0
- pcf_toolkit/cli_helpers.py +62 -0
- pcf_toolkit/data/__init__.py +1 -0
- pcf_toolkit/data/manifest.schema.json +1097 -0
- pcf_toolkit/data/schema_snapshot.json +2377 -0
- pcf_toolkit/data/spec_raw.json +2877 -0
- pcf_toolkit/io.py +65 -0
- pcf_toolkit/json_schema.py +30 -0
- pcf_toolkit/models.py +384 -0
- pcf_toolkit/proxy/__init__.py +1 -0
- pcf_toolkit/proxy/addons/__init__.py +1 -0
- pcf_toolkit/proxy/addons/redirect_bundle.py +70 -0
- pcf_toolkit/proxy/browser.py +157 -0
- pcf_toolkit/proxy/cli.py +1570 -0
- pcf_toolkit/proxy/config.py +310 -0
- pcf_toolkit/proxy/doctor.py +279 -0
- pcf_toolkit/proxy/mitm.py +206 -0
- pcf_toolkit/proxy/server.py +50 -0
- pcf_toolkit/py.typed +1 -0
- pcf_toolkit/rich_help.py +173 -0
- pcf_toolkit/schema_snapshot.py +47 -0
- pcf_toolkit/types.py +95 -0
- pcf_toolkit/xml.py +484 -0
- pcf_toolkit/xml_import.py +548 -0
- pcf_toolkit-0.2.5.dist-info/METADATA +494 -0
- pcf_toolkit-0.2.5.dist-info/RECORD +31 -0
- pcf_toolkit-0.2.5.dist-info/WHEEL +5 -0
- pcf_toolkit-0.2.5.dist-info/entry_points.txt +2 -0
- pcf_toolkit-0.2.5.dist-info/licenses/LICENSE.md +183 -0
- pcf_toolkit-0.2.5.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"""Shared CLI utilities for rich output."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from collections.abc import Iterable
|
|
6
|
+
|
|
7
|
+
try:
|
|
8
|
+
from rich.console import Console
|
|
9
|
+
from rich.table import Table
|
|
10
|
+
except Exception: # pragma: no cover - fallback if rich isn't available
|
|
11
|
+
Console = None
|
|
12
|
+
Table = None
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def rich_console(stderr: bool = False):
|
|
16
|
+
"""Returns a Rich console if available, otherwise None.
|
|
17
|
+
|
|
18
|
+
Args:
|
|
19
|
+
stderr: If True, creates a console that writes to stderr.
|
|
20
|
+
|
|
21
|
+
Returns:
|
|
22
|
+
A Rich Console instance if Rich is available, otherwise None.
|
|
23
|
+
"""
|
|
24
|
+
if Console is None:
|
|
25
|
+
return None
|
|
26
|
+
return Console(stderr=stderr)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def render_validation_table(
|
|
30
|
+
errors: Iterable[dict],
|
|
31
|
+
*,
|
|
32
|
+
title: str,
|
|
33
|
+
stderr: bool = True,
|
|
34
|
+
) -> bool:
|
|
35
|
+
"""Renders a validation error table using Rich.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
errors: Iterable of validation error dictionaries.
|
|
39
|
+
title: Title for the error table.
|
|
40
|
+
stderr: If True, writes to stderr instead of stdout.
|
|
41
|
+
|
|
42
|
+
Returns:
|
|
43
|
+
True if the table was rendered successfully, False otherwise.
|
|
44
|
+
"""
|
|
45
|
+
if Table is None:
|
|
46
|
+
return False
|
|
47
|
+
|
|
48
|
+
console = rich_console(stderr=stderr)
|
|
49
|
+
if console is None:
|
|
50
|
+
return False
|
|
51
|
+
|
|
52
|
+
table = Table(title=title, show_lines=False)
|
|
53
|
+
table.add_column("Location", style="bold")
|
|
54
|
+
table.add_column("Message")
|
|
55
|
+
table.add_column("Type", style="dim")
|
|
56
|
+
for error in errors:
|
|
57
|
+
loc = ".".join(str(part) for part in error.get("loc", [])) or "<root>"
|
|
58
|
+
msg = error.get("msg", "Invalid value")
|
|
59
|
+
err_type = error.get("type", "validation_error")
|
|
60
|
+
table.add_row(loc, msg, err_type)
|
|
61
|
+
console.print(table)
|
|
62
|
+
return True
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Package data for schema snapshots."""
|