MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / parse_post

Function parse_post

scripts/website/syndicate_blog_posts.py:195–210  ·  view source on GitHub ↗
(path: Path)

Source from the content-addressed store, hash-verified

193
194
195def parse_post(path: Path) -> Post | None:
196 text = path.read_text(encoding="utf-8")
197 try:
198 fm, body = parse_front_matter(text)
199 except ValueError:
200 return None
201 date_value = fm.get("date")
202 if not isinstance(date_value, str):
203 return None
204 try:
205 date = dt.date.fromisoformat(date_value[:10])
206 except ValueError:
207 return None
208 slug = fm.get("slug") or path.stem
209 title = fm.get("title") or slug
210 return Post(path=path, slug=slug, title=str(title), date=date, front_matter=fm, body=body)
211
212
213def discover_posts(blog_dir: Path) -> list[Post]:

Callers 1

discover_postsFunction · 0.85

Calls 3

parse_front_matterFunction · 0.85
PostClass · 0.70
getMethod · 0.65

Tested by

no test coverage detected