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

No warning anymore

parent bf1f67cd
......@@ -39,18 +39,25 @@ def parse_metalink(metalink_path: Path, download_dir: Path) -> list[CityGMLWithH
files = []
for file_elem in root.findall("ml:file", ns):
filename = file_elem.get("name")
if filename is None:
raise ValueError(f"Not enough information from {file_elem}")
hash_node = file_elem.find('ml:hash[@type="sha-256"]', ns)
if hash_node is None:
if hash_node is None or hash_node.text is None:
raise ValueError(f"{filename} has no sha256")
urls = [url.text for url in file_elem.findall("ml:url", ns)]
# Randomize URL order to distribute load across servers
random.shuffle(urls)
urls = [url.text for url in file_elem.findall("ml:url", ns) if url.text]
if len(urls) == 0:
raise ValueError(f"No URL for {file_elem}")
else:
# Randomize URL order to distribute load across servers
random.shuffle(urls)
url = urls[0]
files.append(
CityGMLWithHash(
url=urls[0],
url=url,
path=download_dir / filename,
coordinate_reference_system="EPSG:25832",
source="https://geodaten.bayern.de",
......@@ -63,7 +70,7 @@ def parse_metalink(metalink_path: Path, download_dir: Path) -> list[CityGMLWithH
if __name__ == "__main__":
# Download and parse metalink
# Should be from CityGML
download_dir = SCRIPT_DIR / "citygml" / "bayern"
download_dir.mkdir(parents=True, exist_ok=True)
......
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