MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / _extract_frontmatter

Function _extract_frontmatter

deployments/desktop/shared/agents.py:501–522  ·  view source on GitHub ↗
(raw: str)

Source from the content-addressed store, hash-verified

499 return hashlib.sha1(str(path.resolve()).encode("utf-8")).hexdigest()[:20]
500
501
502def _extract_frontmatter(raw: str) -> Tuple[Dict[str, Any], str]:
503 if not raw.startswith("---"):
504 return {}, raw
505 lines = raw.splitlines()
506 if not lines or lines[0].strip() != "---":
507 return {}, raw
508 end_index = None
509 for index in range(1, len(lines)):
510 if lines[index].strip() == "---":
511 end_index = index
512 break
513 if end_index is None:
514 return {}, raw
515 frontmatter_text = "\n".join(lines[1:end_index]).strip()
516 body = "\n".join(lines[end_index + 1 :]).lstrip()
517 if not frontmatter_text:
518 return {}, body
519 try:
520 parsed = yaml.safe_load(frontmatter_text) or {}
521 except yaml.YAMLError:
522 parsed = {}
523 return parsed if isinstance(parsed, dict) else {}, body
524
525

Callers 2

_report_recordFunction · 0.85
_backfill_docs_to_wikiFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected