Skip to content

Commit

Permalink
STY: Tiny readability improvement (py-pdf#2989)
Browse files Browse the repository at this point in the history
  • Loading branch information
j-t-1 authored Dec 4, 2024
1 parent 977b7ef commit 3afc3c0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ def get_data_from_url(url: Optional[str] = None, name: Optional[str] = None) ->
return fp.read()
if not cache_path.exists():
ssl._create_default_https_context = ssl._create_unverified_context
cpt = 3
while cpt > 0:
attempts = 0
while attempts < 3:
try:
with urllib.request.urlopen( # noqa: S310
url
) as response, cache_path.open("wb") as out_file:
out_file.write(response.read())
cpt = 0
break
except HTTPError as e:
if cpt > 0:
cpt -= 1
if attempts < 3:
attempts += 1
else:
raise e
with open(cache_path, "rb") as fp:
Expand Down

0 comments on commit 3afc3c0

Please sign in to comment.