Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions brodata/dino.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,14 +476,18 @@ def __init__(
if is_zipfile:
# BoorgatMetingen are las files that are delivered in a zip-file
with ZipFile(BytesIO(req.content)) as myzip:
files = myzip.namelist()
files = [f for f in files if f.endswith(".las")]
assert len(files) == 1, "Only one file in the zipfile supported"
with myzip.open(files[0]) as myfile:
if to_file is not None:
with open(to_file, "wb") as f:
f.write(myfile.read())
self._read_contents(TextIOWrapper(myfile))
files = [f for f in myzip.namelist() if f.endswith(".las")]
if len(files) == 0:
logger.warning("Zipfile contains no las files.")
self._read_contents(None)
else:
if len(files) > 1:
logger.warning(f"Zipfile contains {len(files)} las files. Only first file will be read.")
with myzip.open(files[0]) as myfile:
if to_file is not None:
with open(to_file, "wb") as f:
f.write(myfile.read())
self._read_contents(TextIOWrapper(myfile))
else:
if to_file is not None:
with open(to_file, "w") as f:
Expand Down