7
7
import pathlib
8
8
import sys
9
9
import zipfile
10
- from typing import Union
10
+ from typing import Optional , Union
11
11
12
12
import requests
13
13
import yaml
@@ -174,7 +174,22 @@ def create_crs(dataset_crs: Union[str, int], logger=LOGGER):
174
174
logger .error (f"Encountered problem while trying to format EPSG code from input : [{ dataset_crs } ]" )
175
175
176
176
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
+ """
178
193
response = requests .get (url , timeout = None )
179
194
if isinstance (filename , str ):
180
195
filename = pathlib .Path (filename )
@@ -191,6 +206,18 @@ def download_url(url: str, filename: Union[str, pathlib.Path], logger=LOGGER):
191
206
def unzip_file (
192
207
zip_path : Union [str , pathlib .Path ], extract_to : Union [str , pathlib .Path ], logger : logging .Logger = LOGGER
193
208
):
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
+ """
194
221
if isinstance (zip_path , str ):
195
222
zip_path = pathlib .Path (zip_path )
196
223
if isinstance (extract_to , str ):
0 commit comments