.. leading zeros are required for `frontmatter` to treat them as dates
rather than strings, apparently per the YAML specification.
This was done by script:
```py
import re
import datetime
import pathlib
import sys
import frontmatter
rx = re.compile(r'^(\s*)date_added:.*$', re.M)
for path_str in sys.argv[1:]:
print(path_str)
path = pathlib.Path(path_str)
post = frontmatter.load(path)
date_added = post.get("date_added", "")
if isinstance(date_added, datetime.date):
continue
if isinstance(date_added, str):
try:
date_added = datetime.datetime.strptime(date_added, "%Y-%m-%d")
except ValueError as exc:
print(f"Failed to parse date {date_added} in {path_str}: {exc}")
continue
date_added = date_added.date()
content = path.read_text("utf-8")
new_content = rx.sub(lambda m: f"{m.group(1)}date_added: {date_added}", content)
assert content != new_content
path.write_text(new_content, "utf-8")
```
825 B
825 B
| layout | board_id | title | name | manufacturer | board_url | board_image | date_added | family | |
|---|---|---|---|---|---|---|---|---|---|
| download | gb_m4 | Python powered GameBoy-compatible cartridge Download | Python powered GameBoy-compatible cartridge | Scott Shawcroft |
|
gb_m4.jpg | 2019-04-05 | atmel-samd |
CircuitPython for Game Boy is a work in progress, check out the weekly "Show and Tell" or “Top Secret” segment on ASK AN ENGINEER or when it's ready, the new product videos on YouTube.
Links and more
- Twitter thread.
- A Python powered GameBoy-compatible cartridge with a SAMD51 - GitHub.
- GBIO branch - GitHub.