MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / parse_file

Function parse_file

tests/loadtest/tools/dashboard_parser.py:121–144  ·  view source on GitHub ↗
(path: Path, root: Path)

Source from the content-addressed store, hash-verified

119
120
121def parse_file(path: Path, root: Path) -> dict[str, Any] | None:
122 try:
123 text = path.read_text(encoding="utf-8")
124 except UnicodeDecodeError:
125 return None
126
127 parsed = parse_text(path.name, text)
128 if parsed is None:
129 return None
130
131 stat = path.stat()
132 rel_path = path.relative_to(root).as_posix()
133 parsed.update(
134 {
135 "id": rel_path,
136 "name": parsed.get("name") or path.stem,
137 "source": rel_path,
138 "collectedAt": datetime.fromtimestamp(stat.st_mtime, tz=timezone.utc).isoformat(),
139 "sizeBytes": stat.st_size,
140 }
141 )
142 if "stats" not in parsed:
143 parsed["stats"] = build_stats(parsed.get("overview", {}), parsed.get("series", []))
144 return parsed
145
146
147def parse_text(name: str, text: str) -> dict[str, Any] | None:

Callers 1

discover_runsFunction · 0.85

Calls 2

parse_textFunction · 0.85
build_statsFunction · 0.85

Tested by

no test coverage detected