Skip to content

Commit

Permalink
Fix problem with ZIP paths on Windows.
Browse files Browse the repository at this point in the history
Fixes #181.
  • Loading branch information
Nathan Baker committed Dec 29, 2023
1 parent 5a00d05 commit a757325
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion propka/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ def open_file_for_reading(input_file: _TextIOSource) -> ContextManager[IO[str]]:
if not input_file.is_file():
for p in input_file.parents:
if not zipfile.is_zipfile(p):
print(f"Parent {p} is not ZIP file.")
continue
zf = zipfile.ZipFile(p)
stream = zf.open(str(input_file.relative_to(p)))
path_string = "/".join(input_file.relative_to(p).parts)
stream = zf.open(path_string)
return io.TextIOWrapper(stream)

return contextlib.closing(open(input_file, 'rt'))
Expand Down

0 comments on commit a757325

Please sign in to comment.