Skip to content

Commit

Permalink
fix(utils): use 'urllib.request' instead of 'requests' (#1177)
Browse files Browse the repository at this point in the history
* chore(actions): add semantic pr validation and only add changelog on new releases (#1168)

* fix(utils): use 'urllib.request' instead of 'requests'

Co-authored-by: Vasco Ramos <[email protected]>
  • Loading branch information
stormbeforesunsetbee and vascoalramos committed Nov 29, 2022
1 parent f8737a1 commit e4d020b
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/pandas_profiling/utils/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import zipfile
from pathlib import Path

import requests
from urllib import request

from pandas_profiling.utils.paths import get_data_path

Expand All @@ -25,8 +25,8 @@ def cache_file(file_name: str, url: str) -> Path:

# If not exists, download and create file
if not file_path.exists():
response = requests.get(url)
file_path.write_bytes(response.content)
response = request.urlopen(url)
file_path.write_bytes(response.read())

return file_path

Expand All @@ -49,12 +49,10 @@ def cache_zipped_file(file_name: str, url: str) -> Path:

# If not exists, download and create file
if not file_path.exists():
response = requests.get(url)
if response.status_code != 200:
raise FileNotFoundError("Could not download resource")
response = request.urlopen(url)

tmp_path = data_path / "tmp.zip"
tmp_path.write_bytes(response.content)
tmp_path.write_bytes(response.read())

with zipfile.ZipFile(tmp_path, "r") as zip_file:
zip_file.extract(file_path.name, data_path)
Expand Down

0 comments on commit e4d020b

Please sign in to comment.