Commit c69d76a9 authored by Eric Duminil's avatar Eric Duminil
Browse files

Extracting Zips

parent db1b113d
...@@ -3,6 +3,7 @@ import json ...@@ -3,6 +3,7 @@ import json
from datetime import datetime from datetime import datetime
from pathlib import Path from pathlib import Path
from urllib.parse import quote from urllib.parse import quote
import zipfile
from citygml_download import TMP_DIR, Bundesland, CityGMLWithDate, download_all_files, download_file from citygml_download import TMP_DIR, Bundesland, CityGMLWithDate, download_all_files, download_file
...@@ -24,7 +25,13 @@ class ZipFile(CityGMLWithDate): ...@@ -24,7 +25,13 @@ class ZipFile(CityGMLWithDate):
def download(self, tmp_dir: Path = TMP_DIR, max_retries: int = 3, sleep: int = 0) -> bool: def download(self, tmp_dir: Path = TMP_DIR, max_retries: int = 3, sleep: int = 0) -> bool:
result = super().download(tmp_dir, max_retries, sleep) result = super().download(tmp_dir, max_retries, sleep)
if result: if result:
print("TODO: Extract zip") output_folder = self.download_folder / self.path.stem
with zipfile.ZipFile(self.path, "r") as main_zip:
main_zip.extractall(output_folder)
for inner_zip_path in output_folder.glob('*.zip'):
with zipfile.ZipFile(inner_zip_path, "r") as inner_zip:
inner_zip.extractall(self.bundesland.download_folder)
print(f" Extracted {inner_zip_path}")
return result return result
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment