Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 14, 2025
1 parent 9afdb29 commit 7cc018f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
22 changes: 12 additions & 10 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import os
import requests
import sys

import requests

if sys.version_info >= (3, 11):
import tomllib
else:
Expand Down Expand Up @@ -59,29 +60,30 @@
html_sidebars = {"**": ["globaltoc.html", "relations.html", "searchbox.html"]}
html_static_path = ["_static"]


# -- Fetch image references --------------------------------------------------
# Download all of the image files referenced in images.toml
def download_images_from_toml(toml_file, image_dir):
with open(toml_file, 'r') as f:
with open(toml_file, "r") as f:
data = tomllib.load(f)

if not os.path.exists(image_dir):
os.makedirs(image_dir)


for file_name, url in data.get('images', {}).items():

for file_name, url in data.get("images", {}).items():
if file_name and url:
response = requests.get(url)
if response.status_code == 200:
with open(os.path.join(image_dir, file_name), 'wb') as img_file:
with open(os.path.join(image_dir, file_name), "wb") as img_file:
img_file.write(response.content)
else:
print(f"Failed to download {url}")


# Path to the TOML file
toml_file_path = os.path.join(os.path.dirname(__file__), 'images.toml')
toml_file_path = os.path.join(os.path.dirname(__file__), "images.toml")
# Directory to save the images
image_directory = os.path.join(os.path.dirname(__file__), 'img')
image_directory = os.path.join(os.path.dirname(__file__), "img")

# Download images
download_images_from_toml(toml_file_path, image_directory)
download_images_from_toml(toml_file_path, image_directory)
2 changes: 1 addition & 1 deletion docs/images.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[images]
"surfactant_overview_diagram.svg" = "https://user-images.githubusercontent.com/3969255/281565514-114069a2-1bdc-49c7-9e5b-9ffa5ee0d0ca.svg"
"surfactant_internal_sbom_generate_diagram.svg" = "https://user-images.githubusercontent.com/3969255/281575236-afea8787-db34-4d07-aea4-6c6eea9a6a93.svg"
"surfactant_internal_sbom_generate_diagram.svg" = "https://user-images.githubusercontent.com/3969255/281575236-afea8787-db34-4d07-aea4-6c6eea9a6a93.svg"

0 comments on commit 7cc018f

Please sign in to comment.