Skip to content

Commit

Permalink
Allow pre-fetch of css files without attempting download (#2095)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderRichert-NOAA committed Jan 11, 2024
1 parent fa8a2de commit dedd81a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions hatch_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ def _get_css_file(template_name, url, filename):
"""Get a css file and download it to the templates dir"""
directory = osp.join(templates_dir, template_name, "static")
dest = osp.join(directory, filename)
if osp.exists(dest):
print("Already have CSS: %s, moving on." % dest)
return
if not osp.exists(directory):
os.makedirs(directory)
print("Downloading CSS: %s" % url)
Expand All @@ -51,11 +54,8 @@ def _get_css_file(template_name, url, filename):
except Exception as e:
msg = f"Failed to download css from {url}: {e}"
print(msg, file=sys.stderr)
if osp.exists(dest):
print("Already have CSS: %s, moving on." % dest)
else:
msg = "Need CSS to proceed."
raise OSError(msg) from None
msg = "Need CSS to proceed."
raise OSError(msg) from None
return

with open(dest, "wb") as f:
Expand Down

0 comments on commit dedd81a

Please sign in to comment.