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:
parent
8e39f7d651
commit
455f26baf9
2 changed files with 3 additions and 1 deletions
2
page.py
2
page.py
|
@ -24,7 +24,7 @@ def blog_page_template():
|
||||||
def date_from_filename(filename):
|
def date_from_filename(filename):
|
||||||
return maybe(
|
return maybe(
|
||||||
re.search(r"(?:^|/)([0-9]{4}-[0-9]{2}-[0-9]{2})[^/]+$", filename)
|
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):
|
def blog_page_metadata(filename):
|
||||||
|
|
2
rss.py
2
rss.py
|
@ -33,6 +33,8 @@ ITEM_TEMPLATE = """
|
||||||
|
|
||||||
def iso8601_to_rfc822(iso8601):
|
def iso8601_to_rfc822(iso8601):
|
||||||
# pylint: disable=invalid-name
|
# pylint: disable=invalid-name
|
||||||
|
if not iso8601:
|
||||||
|
return ""
|
||||||
y, m, d = map(int, iso8601.split("-"))
|
y, m, d = map(int, iso8601.split("-"))
|
||||||
month = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][m]
|
month = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][m]
|
||||||
return f"{d} {month} {y} 00:00:00 UTC"
|
return f"{d} {month} {y} 00:00:00 UTC"
|
||||||
|
|
Loading…
Reference in a new issue