MCPcopy Create free account
hub / github.com/Qinbf/groundmap / Page

Class Page

scripts/k.py:223–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

221
222@dataclass
223class Page:
224 path: str # 相对项目根的 POSIX 路径
225 title: str
226 type: str
227 status: str
228 confidence: str
229 last_modified: str
230 last_modified_by: str
231 tags: list
232 sources: list
233 source_count: int
234 raw_content: str
235
236 @classmethod
237 def from_file(cls, file_path: Path):
238 try:
239 post = frontmatter.load(file_path)
240 except Exception:
241 return None
242
243 meta = post.metadata
244 rel_path = str(file_path.relative_to(PROJECT_ROOT)).replace("\\", "/")
245
246 return cls(
247 path=rel_path,
248 title=str(meta.get("title", file_path.stem) or file_path.stem),
249 type=str(meta.get("type", "unknown") or "unknown"),
250 status=str(meta.get("status", "draft") or "draft"),
251 confidence=str(meta.get("confidence", "medium") or "medium"),
252 last_modified=str(meta.get("last_modified", "") or ""),
253 last_modified_by=str(meta.get("last_modified_by", "unknown") or "unknown"),
254 tags=_as_str_list(meta.get("tags")),
255 sources=_as_str_list(meta.get("sources")),
256 source_count=int(meta.get("source_count") or 0),
257 raw_content=post.content,
258 )
259
260
261# ============================================================

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected