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

Function parse_text

tests/loadtest/tools/dashboard_parser.py:147–166  ·  view source on GitHub ↗
(name: str, text: str)

Source from the content-addressed store, hash-verified

145
146
147def parse_text(name: str, text: str) -> dict[str, Any] | None:
148 trimmed = text.strip()
149 if not trimmed:
150 return None
151
152 if looks_like_ndjson(trimmed):
153 return parse_ndjson(name, trimmed)
154
155 if trimmed.startswith("{"):
156 try:
157 obj = json.loads(trimmed)
158 except json.JSONDecodeError:
159 obj = None
160 if isinstance(obj, dict) and "metrics" in obj:
161 return parse_summary(name, obj)
162
163 if looks_like_csv(trimmed):
164 return parse_csv(name, trimmed)
165
166 return None
167
168
169def parse_summary(name: str, payload: dict[str, Any]) -> dict[str, Any]:

Callers 1

parse_fileFunction · 0.85

Calls 5

looks_like_ndjsonFunction · 0.85
parse_ndjsonFunction · 0.85
parse_summaryFunction · 0.85
looks_like_csvFunction · 0.85
parse_csvFunction · 0.85

Tested by

no test coverage detected