Merge pull request #182 from jensengroup/nathan/181

Fix problem with ZIP paths on Windows.
This commit is contained in:
Nathan Baker
2023-12-30 19:08:33 -08:00
committed by GitHub

View File

@@ -38,9 +38,11 @@ def open_file_for_reading(input_file: _TextIOSource) -> ContextManager[IO[str]]:
if not input_file.is_file(): if not input_file.is_file():
for p in input_file.parents: for p in input_file.parents:
if not zipfile.is_zipfile(p): if not zipfile.is_zipfile(p):
print(f"Parent {p} is not ZIP file.")
continue continue
zf = zipfile.ZipFile(p) zf = zipfile.ZipFile(p)
stream = zf.open(str(input_file.relative_to(p))) path_string = Path.as_posix(input_file.relative_to(p))
stream = zf.open(path_string)
return io.TextIOWrapper(stream) return io.TextIOWrapper(stream)
return contextlib.closing(open(input_file, 'rt')) return contextlib.closing(open(input_file, 'rt'))