2020-06-16 02:10:26 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import sys
|
|
|
|
from functools import partial as p
|
|
|
|
from ipo import ipo, write, starstarmap
|
|
|
|
|
|
|
|
from page import blog_page_metadata
|
|
|
|
|
|
|
|
|
|
|
|
BASE_URL = "https://www.braindeaddev.com/P5t7oFqPF7oEX"
|
|
|
|
|
|
|
|
DOC_TEMPLATE = """<?xml version="1.0"?>
|
|
|
|
<rss version="2.0">
|
|
|
|
<channel>
|
|
|
|
<title>Midgard's blog</title>
|
|
|
|
<description></description>
|
|
|
|
<lastBuildDate>{last_updated}</lastBuildDate>
|
|
|
|
<author>Midgard</author>
|
|
|
|
<link>{url}</link>{0}
|
|
|
|
</channel>
|
|
|
|
</rss>"""
|
|
|
|
|
|
|
|
ITEM_TEMPLATE = """
|
|
|
|
<item>
|
|
|
|
<title>{title}</title>
|
|
|
|
<guid>{path}</guid>
|
|
|
|
<pubDate>{published_rfc822}</pubDate>
|
|
|
|
<link>{url}</link>
|
|
|
|
<description>{summary}</description>
|
|
|
|
</item>"""
|
|
|
|
# <category>{category}</category>
|
|
|
|
|
|
|
|
|
2022-01-09 12:44:07 +01:00
|
|
|
def iso8601_to_rfc822(iso8601):
|
2020-06-16 02:10:26 +02:00
|
|
|
# pylint: disable=invalid-name
|
|
|
|
y, m, d = map(int, iso8601.split("-"))
|
|
|
|
month = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][m]
|
|
|
|
return f"{d} {month} {y} 00:00:00 UTC"
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
items = (
|
|
|
|
ipo(sys.argv[1:]) |
|
|
|
|
p(map, blog_page_metadata) |
|
|
|
|
p(sorted, key=lambda x: x["published"]) |
|
|
|
|
p(map, lambda x: {
|
|
|
|
**x,
|
2022-01-09 12:44:07 +01:00
|
|
|
"published_rfc822": iso8601_to_rfc822(x["published"]),
|
2020-06-16 14:44:43 +02:00
|
|
|
"url": f"{BASE_URL}/{x['path']}"
|
2020-06-16 02:10:26 +02:00
|
|
|
}) | list
|
|
|
|
)
|
|
|
|
|
|
|
|
last_date = items.data[-1]["published_rfc822"]
|
|
|
|
|
|
|
|
(
|
|
|
|
items |
|
|
|
|
p(starstarmap, ITEM_TEMPLATE.format) |
|
|
|
|
"".join |
|
|
|
|
p(DOC_TEMPLATE.format, url=BASE_URL, last_updated=last_date) |
|
|
|
|
write
|
|
|
|
)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|