blog.ari.lt/scripts/v2-titles.py
Ari Archer f3145db1e0
update @ Thu Dec 26 04:29:22 EET 2024
Signed-off-by: Ari Archer <ari@ari.lt>
2024-12-26 04:29:22 +02:00

36 lines
813 B
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""changes titles to be capitalised"""
import json
from warnings import filterwarnings as filter_warnings
def t(title: str):
if title:
title = title[0].upper() + title[1:]
title = title.replace("Doml #", "DOML #")
return title
def main() -> int:
"""entry / main function"""
with open("blog.json", "r") as fp:
blog = json.load(fp)
for slug in blog["posts"]:
blog["posts"][slug]["title"] = t(blog["posts"][slug]["title"])
with open("blog.json", "w") as fp:
json.dump(blog, fp, indent=4)
return 0
if __name__ == "__main__":
assert main.__annotations__.get("return") is int, "main() should return an integer"
filter_warnings("error", category=Warning)
raise SystemExit(main())