(raw: str)
| 499 | return hashlib.sha1(str(path.resolve()).encode("utf-8")).hexdigest()[:20] |
| 500 | |
| 501 | |
| 502 | def _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 |
no outgoing calls
no test coverage detected