unifi-network-maps 1.4.3__py3-none-any.whl → 1.4.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.
Files changed (34) hide show
  1. unifi_network_maps/__init__.py +1 -1
  2. unifi_network_maps/assets/themes/dark.yaml +2 -2
  3. unifi_network_maps/cli/__init__.py +2 -38
  4. unifi_network_maps/cli/args.py +166 -0
  5. unifi_network_maps/cli/main.py +18 -747
  6. unifi_network_maps/cli/render.py +255 -0
  7. unifi_network_maps/cli/runtime.py +157 -0
  8. unifi_network_maps/io/mkdocs_assets.py +21 -0
  9. unifi_network_maps/io/mock_generate.py +2 -294
  10. unifi_network_maps/model/mock.py +307 -0
  11. unifi_network_maps/render/device_ports_md.py +44 -27
  12. unifi_network_maps/render/legend.py +30 -0
  13. unifi_network_maps/render/lldp_md.py +81 -60
  14. unifi_network_maps/render/markdown_tables.py +21 -0
  15. unifi_network_maps/render/mermaid.py +72 -85
  16. unifi_network_maps/render/mkdocs.py +167 -0
  17. unifi_network_maps/render/templates/device_port_block.md.j2 +5 -0
  18. unifi_network_maps/render/templates/legend_compact.html.j2 +14 -0
  19. unifi_network_maps/render/templates/lldp_device_section.md.j2 +15 -0
  20. unifi_network_maps/render/templates/markdown_section.md.j2 +3 -0
  21. unifi_network_maps/render/templates/mermaid_legend.mmd.j2 +30 -0
  22. unifi_network_maps/render/templates/mkdocs_document.md.j2 +23 -0
  23. unifi_network_maps/render/templates/mkdocs_dual_theme_style.html.j2 +8 -0
  24. unifi_network_maps/render/templates/mkdocs_html_block.html.j2 +2 -0
  25. unifi_network_maps/render/templates/mkdocs_legend.css.j2 +29 -0
  26. unifi_network_maps/render/templates/mkdocs_legend.js.j2 +18 -0
  27. unifi_network_maps/render/templates/mkdocs_mermaid_block.md.j2 +4 -0
  28. unifi_network_maps/render/templating.py +19 -0
  29. {unifi_network_maps-1.4.3.dist-info → unifi_network_maps-1.4.5.dist-info}/METADATA +2 -1
  30. {unifi_network_maps-1.4.3.dist-info → unifi_network_maps-1.4.5.dist-info}/RECORD +34 -14
  31. {unifi_network_maps-1.4.3.dist-info → unifi_network_maps-1.4.5.dist-info}/WHEEL +0 -0
  32. {unifi_network_maps-1.4.3.dist-info → unifi_network_maps-1.4.5.dist-info}/entry_points.txt +0 -0
  33. {unifi_network_maps-1.4.3.dist-info → unifi_network_maps-1.4.5.dist-info}/licenses/LICENSE +0 -0
  34. {unifi_network_maps-1.4.3.dist-info → unifi_network_maps-1.4.5.dist-info}/top_level.txt +0 -0
@@ -1 +1 @@
1
- __version__ = "1.4.3"
1
+ __version__ = "1.4.5"
@@ -15,8 +15,8 @@ mermaid:
15
15
  other:
16
16
  fill: "#2a2a2a"
17
17
  stroke: "#9e9e9e"
18
- node_text: "#111111"
19
- edge_label_border: "#111111"
18
+ node_text: "#f5f5f5"
19
+ edge_label_border: "#e6e6e6"
20
20
  edge_label_border_width: 2
21
21
  poe_link: "#64b5f6"
22
22
  poe_link_width: 2
@@ -1,41 +1,5 @@
1
1
  """CLI package facade."""
2
2
 
3
- from .main import (
4
- Config,
5
- SvgOptions,
6
- build_client_edges,
7
- build_device_index,
8
- build_node_type_map,
9
- build_topology,
10
- debug_dump_devices,
11
- fetch_clients,
12
- fetch_devices,
13
- group_devices_by_type,
14
- main,
15
- normalize_devices,
16
- render_legend,
17
- render_mermaid,
18
- render_svg,
19
- resolve_themes,
20
- write_output,
21
- )
3
+ from .main import main
22
4
 
23
- __all__ = [
24
- "Config",
25
- "SvgOptions",
26
- "build_client_edges",
27
- "build_device_index",
28
- "build_node_type_map",
29
- "build_topology",
30
- "debug_dump_devices",
31
- "fetch_clients",
32
- "fetch_devices",
33
- "group_devices_by_type",
34
- "main",
35
- "normalize_devices",
36
- "render_legend",
37
- "render_mermaid",
38
- "render_svg",
39
- "resolve_themes",
40
- "write_output",
41
- ]
5
+ __all__ = ["main"]
@@ -0,0 +1,166 @@
1
+ """CLI argument definitions."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+
7
+
8
+ def build_parser() -> argparse.ArgumentParser:
9
+ parser = argparse.ArgumentParser(
10
+ description="Generate network maps from UniFi LLDP data, as mermaid or SVG"
11
+ )
12
+ add_source_args(parser.add_argument_group("Source"))
13
+ add_mock_args(parser.add_argument_group("Mock"))
14
+ add_functional_args(parser.add_argument_group("Functional"))
15
+ add_mermaid_args(parser.add_argument_group("Mermaid"))
16
+ add_svg_args(parser.add_argument_group("SVG"))
17
+ add_general_render_args(parser.add_argument_group("Output"))
18
+ add_debug_args(parser.add_argument_group("Debug"))
19
+ return parser
20
+
21
+
22
+ def add_source_args(parser: argparse._ArgumentGroup) -> None:
23
+ parser.add_argument("--site", default=None, help="UniFi site name (overrides UNIFI_SITE)")
24
+ parser.add_argument(
25
+ "--env-file",
26
+ default=None,
27
+ help="Path to .env file (overrides default .env discovery)",
28
+ )
29
+ parser.add_argument(
30
+ "--mock-data",
31
+ default=None,
32
+ help="Path to mock data JSON (skips UniFi API calls)",
33
+ )
34
+
35
+
36
+ def add_mock_args(parser: argparse._ArgumentGroup) -> None:
37
+ parser.add_argument(
38
+ "--generate-mock",
39
+ default=None,
40
+ help="Write mock data JSON to the given path and exit",
41
+ )
42
+ parser.add_argument("--mock-seed", type=int, default=1337, help="Seed for mock generation")
43
+ parser.add_argument(
44
+ "--mock-switches",
45
+ type=int,
46
+ default=1,
47
+ help="Number of switches to generate (default: 1)",
48
+ )
49
+ parser.add_argument(
50
+ "--mock-aps",
51
+ type=int,
52
+ default=2,
53
+ help="Number of access points to generate (default: 2)",
54
+ )
55
+ parser.add_argument(
56
+ "--mock-wired-clients",
57
+ type=int,
58
+ default=2,
59
+ help="Number of wired clients to generate (default: 2)",
60
+ )
61
+ parser.add_argument(
62
+ "--mock-wireless-clients",
63
+ type=int,
64
+ default=2,
65
+ help="Number of wireless clients to generate (default: 2)",
66
+ )
67
+
68
+
69
+ def add_functional_args(parser: argparse._ArgumentGroup) -> None:
70
+ parser.add_argument("--include-ports", action="store_true", help="Include port labels in edges")
71
+ parser.add_argument(
72
+ "--include-clients",
73
+ action="store_true",
74
+ help="Include active clients as leaf nodes",
75
+ )
76
+ parser.add_argument(
77
+ "--client-scope",
78
+ choices=["wired", "wireless", "all"],
79
+ default="wired",
80
+ help="Client types to include (default: wired)",
81
+ )
82
+ parser.add_argument(
83
+ "--only-unifi", action="store_true", help="Only include neighbors that are UniFi devices"
84
+ )
85
+ parser.add_argument(
86
+ "--no-cache",
87
+ action="store_true",
88
+ help="Disable UniFi API cache reads and writes",
89
+ )
90
+
91
+
92
+ def add_mermaid_args(parser: argparse._ArgumentGroup) -> None:
93
+ parser.add_argument("--direction", default="TB", choices=["LR", "TB"], help="Mermaid direction")
94
+ parser.add_argument(
95
+ "--group-by-type",
96
+ action="store_true",
97
+ help="Group nodes by gateway/switch/ap in Mermaid subgraphs",
98
+ )
99
+ parser.add_argument(
100
+ "--legend-scale",
101
+ type=float,
102
+ default=1.0,
103
+ help="Scale legend font/link sizes for Mermaid output (default: 1.0)",
104
+ )
105
+ parser.add_argument(
106
+ "--legend-style",
107
+ default="auto",
108
+ choices=["auto", "compact", "diagram"],
109
+ help="Legend style (auto uses compact for mkdocs, diagram otherwise)",
110
+ )
111
+ parser.add_argument(
112
+ "--legend-only",
113
+ action="store_true",
114
+ help="Render only the legend as a separate Mermaid graph",
115
+ )
116
+
117
+
118
+ def add_svg_args(parser: argparse._ArgumentGroup) -> None:
119
+ parser.add_argument("--svg-width", type=int, default=None, help="SVG width override")
120
+ parser.add_argument("--svg-height", type=int, default=None, help="SVG height override")
121
+ parser.add_argument("--theme-file", default=None, help="Path to theme YAML file")
122
+
123
+
124
+ def add_general_render_args(parser: argparse._ArgumentGroup) -> None:
125
+ parser.add_argument(
126
+ "--format",
127
+ default="mermaid",
128
+ choices=["mermaid", "svg", "svg-iso", "lldp-md", "mkdocs"],
129
+ help="Output format",
130
+ )
131
+ parser.add_argument(
132
+ "--markdown",
133
+ action="store_true",
134
+ help="Wrap output in a Markdown mermaid code fence for notes tools like Obsidian",
135
+ )
136
+ parser.add_argument("--output", default=None, help="Output file path")
137
+ parser.add_argument("--stdout", action="store_true", help="Write output to stdout")
138
+ parser.add_argument(
139
+ "--mkdocs-sidebar-legend",
140
+ action="store_true",
141
+ help="For mkdocs output, write sidebar legend assets next to the output file",
142
+ )
143
+ parser.add_argument(
144
+ "--mkdocs-dual-theme",
145
+ action="store_true",
146
+ help="Render light/dark Mermaid blocks for MkDocs Material theme switching",
147
+ )
148
+ parser.add_argument(
149
+ "--mkdocs-timestamp-zone",
150
+ default="Europe/Amsterdam",
151
+ help="Timezone for mkdocs generated timestamp (use 'off' to disable)",
152
+ )
153
+
154
+
155
+ def add_debug_args(parser: argparse._ArgumentGroup) -> None:
156
+ parser.add_argument(
157
+ "--debug-dump",
158
+ action="store_true",
159
+ help="Dump gateway and sample device data to stderr for debugging",
160
+ )
161
+ parser.add_argument(
162
+ "--debug-sample",
163
+ type=int,
164
+ default=2,
165
+ help="Number of non-gateway devices to include in debug dump (default: 2)",
166
+ )