Skip to content

Commit

Permalink
Format download_gemgis_data.py
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderJuestel committed Jul 22, 2024
1 parent 423eb17 commit e1b0ab8
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions gemgis/download_gemgis_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
import zipfile


def create_pooch(storage_url: str,
files: List[str],
target: str):
def create_pooch(storage_url: str, files: List[str], target: str):
"""
Create pooch class to fetch files from a website.
Expand All @@ -51,19 +49,22 @@ def create_pooch(storage_url: str,
import pooch
except ModuleNotFoundError:
raise ModuleNotFoundError(
'Pooch package is not installed. Use pip install pooch to install the latest version')
"Pooch package is not installed. Use pip install pooch to install the latest version"
)

# Create new pooch
pc = pooch.create(base_url=storage_url,
path=target,
registry={i: None for i in files})
pc = pooch.create(
base_url=storage_url, path=target, registry={i: None for i in files}
)

return pc


def download_tutorial_data(filename: str,
dirpath: str = '',
storage_url: str = 'https://rwth-aachen.sciebo.de/s/AfXRsZywYDbUF34/download?path=%2F'):
def download_tutorial_data(
filename: str,
dirpath: str = "",
storage_url: str = "https://rwth-aachen.sciebo.de/s/AfXRsZywYDbUF34/download?path=%2F",
):
"""
Download the GemGIS data for each tutorial.
Expand All @@ -83,20 +84,19 @@ def download_tutorial_data(filename: str,
"""
try:
from pooch import HTTPDownloader

download = HTTPDownloader(progressbar=False)
except ModuleNotFoundError:
raise ModuleNotFoundError(
'Pooch package is not installed. Use pip install pooch to install the latest version')
"Pooch package is not installed. Use pip install pooch to install the latest version"
)

# Creating pooch object
pooch_data = create_pooch(storage_url=storage_url,
files=[filename],
target=dirpath)
pooch_data = create_pooch(storage_url=storage_url, files=[filename], target=dirpath)

# Downloading data to the defined folder
pooch_data.fetch(fname=filename,
downloader=download)
pooch_data.fetch(fname=filename, downloader=download)

# Opening zip file and unzip in specified directory
with zipfile.ZipFile(dirpath + filename, 'r') as zip_ref:
with zipfile.ZipFile(dirpath + filename, "r") as zip_ref:
zip_ref.extractall(dirpath)

0 comments on commit e1b0ab8

Please sign in to comment.