Fix or_none() to or_else(None) and catch edge case

Apparently there's no or_none() in pymaybe.

Catch the case when no date is found
This commit is contained in:
Midgard 2022-01-09 20:28:39 +01:00
parent 8e39f7d651
commit 455f26baf9
Signed by untrusted user who does not match committer: midgard
GPG Key ID: 511C112F1331BBB4
2 changed files with 3 additions and 1 deletions

View File

@ -24,7 +24,7 @@ def blog_page_template():
def date_from_filename(filename):
return maybe(
re.search(r"(?:^|/)([0-9]{4}-[0-9]{2}-[0-9]{2})[^/]+$", filename)
).group(1).or_none()
).group(1).or_else(None)
def blog_page_metadata(filename):

2
rss.py
View File

@ -33,6 +33,8 @@ ITEM_TEMPLATE = """
def iso8601_to_rfc822(iso8601):
# pylint: disable=invalid-name
if not iso8601:
return ""
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"