Skip to content

Commit 8f84f9f

Browse files
committed
Add docstring to utils functions
1 parent a735b5b commit 8f84f9f

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

geospatial_tools/utils.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import pathlib
88
import sys
99
import zipfile
10-
from typing import Union
10+
from typing import Optional, Union
1111

1212
import requests
1313
import yaml
@@ -174,7 +174,22 @@ def create_crs(dataset_crs: Union[str, int], logger=LOGGER):
174174
logger.error(f"Encountered problem while trying to format EPSG code from input : [{dataset_crs}]")
175175

176176

177-
def download_url(url: str, filename: Union[str, pathlib.Path], logger=LOGGER):
177+
def download_url(url: str, filename: Union[str, pathlib.Path], logger=LOGGER) -> Optional[pathlib.Path]:
178+
"""
179+
This function downloads a file from a given URL.
180+
181+
Parameters
182+
----------
183+
url
184+
Url to download
185+
filename
186+
Filename (or full path) to save the downloaded file
187+
logger
188+
Logger instance
189+
190+
Returns
191+
-------
192+
"""
178193
response = requests.get(url, timeout=None)
179194
if isinstance(filename, str):
180195
filename = pathlib.Path(filename)
@@ -191,6 +206,18 @@ def download_url(url: str, filename: Union[str, pathlib.Path], logger=LOGGER):
191206
def unzip_file(
192207
zip_path: Union[str, pathlib.Path], extract_to: Union[str, pathlib.Path], logger: logging.Logger = LOGGER
193208
):
209+
"""
210+
This function unzips an archive to a specific directory.
211+
212+
Parameters
213+
----------
214+
zip_path
215+
Path to zip file
216+
extract_to
217+
Path of directory to extract the zip file
218+
logger
219+
Logger instance
220+
"""
194221
if isinstance(zip_path, str):
195222
zip_path = pathlib.Path(zip_path)
196223
if isinstance(extract_to, str):

0 commit comments

Comments
 (0)