Conditions | 5 |
Total Lines | 26 |
Code Lines | 12 |
Lines | 26 |
Ratio | 100 % |
Changes | 0 |
1 | """The central module containing all code dealing with small scale input-data |
||
14 | View Code Duplication | def download(): |
|
|
|||
15 | """ |
||
16 | Download small scale input data from Zenodo |
||
17 | Parameters |
||
18 | ---------- |
||
19 | |||
20 | """ |
||
21 | data_bundle_path = Path(".") / "data_bundle_egon_data" |
||
22 | # Delete folder if it already exists |
||
23 | if data_bundle_path.exists() and data_bundle_path.is_dir(): |
||
24 | shutil.rmtree(data_bundle_path) |
||
25 | # Get parameters from config and set download URL |
||
26 | sources = config.datasets()["data-bundle"]["sources"]["zenodo"] |
||
27 | url = ( |
||
28 | f"https://zenodo.org/record/{sources['deposit_id']}/files/" |
||
29 | "data_bundle_egon_data.zip" |
||
30 | ) |
||
31 | target_file = config.datasets()["data-bundle"]["targets"]["file"] |
||
32 | |||
33 | # check if file exists |
||
34 | if not Path(target_file).exists(): |
||
35 | # Retrieve files |
||
36 | urlretrieve(url, target_file) |
||
37 | |||
38 | with zipfile.ZipFile(target_file, "r") as zip_ref: |
||
39 | zip_ref.extractall(".") |
||
40 | |||
56 |