From 5b720152780b4f80626d930afb6b1198fd0d17ef Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 25 Jun 2023 21:27:34 -0700 Subject: [PATCH] Ignore nonexistent git dates during local testing. --- voussoir.net/writing/generate_site.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/voussoir.net/writing/generate_site.py b/voussoir.net/writing/generate_site.py index ab26fa9..b9b51cb 100644 --- a/voussoir.net/writing/generate_site.py +++ b/voussoir.net/writing/generate_site.py @@ -85,9 +85,12 @@ def git_file_edited_date(path) -> datetime.datetime: path, ] date = check_output(command) - date = dateutil.parser.parse(date) - date = date.astimezone(datetime.timezone.utc) - return date + if date: + date = dateutil.parser.parse(date) + date = date.astimezone(datetime.timezone.utc) + return date + else: + return datetime.datetime.now(datetime.timezone.utc) def git_file_commit_history(path): ''' @@ -134,9 +137,12 @@ def git_file_published_date(path) -> datetime.datetime: path, ] date = check_output(command) - date = dateutil.parser.parse(date) - date = date.astimezone(datetime.timezone.utc) - return date + if date: + date = dateutil.parser.parse(date) + date = date.astimezone(datetime.timezone.utc) + return date + else: + return datetime.datetime.now(datetime.timezone.utc) # SOUP ################################################################################