Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
squidfunk committed Feb 20, 2025
1 parent 2e837fa commit bdad6ec
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
20 changes: 11 additions & 9 deletions material/plugins/privacy/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def _parse_fragment(self, fragment: str):
# quote, we need to catch this here, as we're using pretty basic
# regular expression based extraction
raise PluginError(
f"Could not parse due to possible syntax error in HTML: \n\n"
"Couldn't parse due to possible syntax error in HTML: \n\n"
+ fragment
)

Expand Down Expand Up @@ -413,11 +413,11 @@ def _fetch(self, file: File, config: MkDocsConfig):
try:
res = requests.get(
file.url,
headers={
# Set user agent explicitly, so Google Fonts gives us *.woff2
# files, which according to caniuse.com is the only format we
# need to download as it covers the entire range of browsers
# we're officially supporting.
headers = {
# Set user agent explicitly, so Google Fonts gives us
# *.woff2 files, which according to caniuse.com is the
# only format we need to download as it covers the range
# range of browsers we're officially supporting.
"User-Agent": " ".join(
[
"Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
Expand All @@ -429,9 +429,11 @@ def _fetch(self, file: File, config: MkDocsConfig):
timeout=DEFAULT_TIMEOUT_IN_SECS,
)
res.raise_for_status()
except Exception as error: # this could be a ConnectionError or an HTTPError
log.warning(f"Could not retrieve {file.url}: {error}")
return False

# Intercept errors of type `ConnectionError` and `HTTPError`
except Exception as error:
log.warning(f"Couldn't retrieve {file.url}: {error}")
return

# Compute expected file extension and append if missing
mime = res.headers["content-type"].split(";")[0]
Expand Down
20 changes: 11 additions & 9 deletions src/plugins/privacy/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def _parse_fragment(self, fragment: str):
# quote, we need to catch this here, as we're using pretty basic
# regular expression based extraction
raise PluginError(
f"Could not parse due to possible syntax error in HTML: \n\n"
"Couldn't parse due to possible syntax error in HTML: \n\n"
+ fragment
)

Expand Down Expand Up @@ -413,11 +413,11 @@ def _fetch(self, file: File, config: MkDocsConfig):
try:
res = requests.get(
file.url,
headers={
# Set user agent explicitly, so Google Fonts gives us *.woff2
# files, which according to caniuse.com is the only format we
# need to download as it covers the entire range of browsers
# we're officially supporting.
headers = {
# Set user agent explicitly, so Google Fonts gives us
# *.woff2 files, which according to caniuse.com is the
# only format we need to download as it covers the range
# range of browsers we're officially supporting.
"User-Agent": " ".join(
[
"Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
Expand All @@ -429,9 +429,11 @@ def _fetch(self, file: File, config: MkDocsConfig):
timeout=DEFAULT_TIMEOUT_IN_SECS,
)
res.raise_for_status()
except Exception as error: # this could be a ConnectionError or an HTTPError
log.warning(f"Could not retrieve {file.url}: {error}")
return False

# Intercept errors of type `ConnectionError` and `HTTPError`
except Exception as error:
log.warning(f"Couldn't retrieve {file.url}: {error}")
return

# Compute expected file extension and append if missing
mime = res.headers["content-type"].split(";")[0]
Expand Down

0 comments on commit bdad6ec

Please sign in to comment.