import json from html import escape from pathlib import Path from typing import Dict, List def _safe(value: str) -> str: return escape(str(value or "")) def _folder_tree(rows: List[dict]) -> dict: root = {"name": "ROOT", "path": "", "count": 0, "children": {}} for row in rows: p = row.get("path") or "" parts = [x for x in p.split("/") if x] if not parts: continue # Folder-only tree: for file items exclude last segment. folder_depth = len(parts) if row.get("item_kind") == "FOLDER" else len(parts) - 1 if folder_depth <= 0: continue node = root node["count"] += 1 current = [] for i in range(folder_depth): part = parts[i] current.append(part) key = "/".join(current) if part not in node["children"]: node["children"][part] = { "name": part, "path": key, "count": 0, "children": {}, } node = node["children"][part] node["count"] += 1 return root def _render_tree(node: dict) -> str: if not node["children"]: return "" out = ["
| Path/Name | Type | Owner | Access | # | Risk | Copy |
|---|