Skip to content

Commit

Permalink
Make lzma support optional. Fixes #574.
Browse files Browse the repository at this point in the history
  • Loading branch information
shyuep committed Mar 31, 2024
1 parent fd6b16d commit 09d3692
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions monty/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
import errno
import gzip
import io
import lzma

try:
import lzma
except ImportError:
lzma = None # type: ignore
import mmap
import os
import subprocess
Expand Down Expand Up @@ -40,7 +44,7 @@ def zopen(filename: Union[str, Path], *args, **kwargs) -> IO:
return bz2.open(filename, *args, **kwargs)
if ext in (".GZ", ".Z"):
return gzip.open(filename, *args, **kwargs)
if ext in (".XZ", ".LZMA"):
if (lzma is not None) and (ext in (".XZ", ".LZMA")):
return lzma.open(filename, *args, **kwargs)
return open(filename, *args, **kwargs) # pylint: disable=R1732

Expand Down

0 comments on commit 09d3692

Please sign in to comment.