(cls, file_path: Path)
| 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 | # ============================================================ |
no test coverage detected