MCPcopy Create free account
hub / github.com/VectifyAI/OpenKB / _load_wiki_pages

Function _load_wiki_pages

openkb/lint.py:464–482  ·  view source on GitHub ↗

Read all wiki .md files once and return a ``{path: text}`` mapping. Applies the same scope as :func:`find_invalid_frontmatter`: walks the whole wiki, skips names in :data:`_EXCLUDED_FILES`, and skips any path whose first relative-to-wiki directory part is ``"reports"`` or ``"sources

(wiki: Path)

Source from the content-addressed store, hash-verified

462
463
464def _load_wiki_pages(wiki: Path) -> dict[Path, str]:
465 """Read all wiki .md files once and return a ``{path: text}`` mapping.
466
467 Applies the same scope as :func:`find_invalid_frontmatter`: walks the
468 whole wiki, skips names in :data:`_EXCLUDED_FILES`, and skips any path
469 whose first relative-to-wiki directory part is ``"reports"`` or
470 ``"sources"``. The result is the superset that both frontmatter checks
471 iterate; :func:`find_missing_okf_fields` additionally filters down to
472 :data:`PAGE_CONTENT_DIRS <openkb.schema.PAGE_CONTENT_DIRS>` paths.
473 """
474 pages: dict[Path, str] = {}
475 for path in wiki.rglob("*.md"):
476 if path.name in _EXCLUDED_FILES:
477 continue
478 rel_parts = path.relative_to(wiki).parts
479 if rel_parts and rel_parts[0] in ("reports", "sources"):
480 continue
481 pages[path] = _read_md(path)
482 return pages
483
484
485def find_invalid_frontmatter(

Calls 1

_read_mdFunction · 0.85