Skip to content

Commit

Permalink
Get the HTML file in the archive command too
Browse files Browse the repository at this point in the history
  • Loading branch information
palewire committed Jan 25, 2023
1 parent b0f38df commit 9d66018
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions newshomepages/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,27 +141,33 @@ def _get_file_dict(data: typing.Dict, input_dir: Path) -> typing.Dict:
hyperlinks_path = input_dir / f"{handle}.hyperlinks.json"
lighthouse_path = input_dir / f"{handle}.lighthouse.json"
wayback_path = input_dir / f"{handle}.wayback.json"
html_path = input_dir / f"{handle}.html"

# Get the local time where the site is based
now_local = utils.get_local_time(data)

# Convert it to ISO format for timestamping our files
now_iso = now_local.isoformat()

# Set an ID that will be the prefix to all files
prefix = f"{handle}-{now_iso}"

# Grab the files that exist and timestamp them
file_dict = {}
if image_path.exists():
file_dict[f"{handle}-{now_iso}.jpg"] = image_path
file_dict[f"{prefix}.jpg"] = image_path
if image_fullpage_path.exists():
file_dict[f"{handle}-{now_iso}.fullpage.jpg"] = image_fullpage_path
file_dict[f"{prefix}.fullpage.jpg"] = image_fullpage_path
if a11y_path.exists():
file_dict[f"{handle}-{now_iso}.accessibility.json"] = a11y_path
file_dict[f"{prefix}.accessibility.json"] = a11y_path
if hyperlinks_path.exists():
file_dict[f"{handle}-{now_iso}.hyperlinks.json"] = hyperlinks_path
file_dict[f"{prefix}.hyperlinks.json"] = hyperlinks_path
if lighthouse_path.exists():
file_dict[f"{handle}-{now_iso}.lighthouse.json"] = lighthouse_path
file_dict[f"{prefix}.lighthouse.json"] = lighthouse_path
if wayback_path.exists():
file_dict[f"{handle}-{now_iso}.wayback.json"] = wayback_path
file_dict[f"{prefix}.wayback.json"] = wayback_path
if html_path.exists():
file_dict[f"{prefix}.html"] = html_path

# Return it
return file_dict
Expand Down

0 comments on commit 9d66018

Please sign in to comment.