MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / parse_file

Function parse_file

worked/example/raw/parser.py:12–26  ·  view source on GitHub ↗

Read a file from disk and return a structured document.

(path: str)

Source from the content-addressed store, hash-verified

10
11
12def parse_file(path: str) -> dict:
13 """Read a file from disk and return a structured document."""
14 with open(path, "r") as f:
15 raw = f.read()
16
17 ext = path.rsplit(".", 1)[-1].lower()
18 if ext == "md":
19 doc = parse_markdown(raw)
20 elif ext == "json":
21 doc = parse_json(raw)
22 else:
23 doc = parse_plaintext(raw)
24
25 doc["source"] = path
26 return doc
27
28
29def parse_markdown(text: str) -> dict:

Callers 1

parse_and_saveFunction · 0.85

Calls 4

parse_markdownFunction · 0.85
parse_jsonFunction · 0.85
parse_plaintextFunction · 0.85
readMethod · 0.45

Tested by

no test coverage detected