Commit 12fe7cff authored by Vincent Pelletier's avatar Vincent Pelletier

apachedex: Simplify lzma detection code.

parent e457bb6f
...@@ -80,7 +80,6 @@ def _wrapOpen(func): ...@@ -80,7 +80,6 @@ def _wrapOpen(func):
return srw return srw
return wrapper return wrapper
lzma = None
gzip_open = gzip.open gzip_open = gzip.open
if sys.version_info >= (3, 3): if sys.version_info >= (3, 3):
import lzma import lzma
...@@ -90,16 +89,15 @@ else: ...@@ -90,16 +89,15 @@ else:
gzip_open = _wrapOpen(gzip_open) gzip_open = _wrapOpen(gzip_open)
bz2_open = _wrapOpen(bz2.BZ2File) bz2_open = _wrapOpen(bz2.BZ2File)
_read_mode = 'r' _read_mode = 'r'
try:
from backports import lzma
except ImportError:
lzma = None
FILE_OPENER_LIST = [ FILE_OPENER_LIST = [
(gzip_open, IOError), (gzip_open, IOError),
(bz2_open, IOError), (bz2_open, IOError),
] ]
if lzma is None:
try:
from backports import lzma
except ImportError:
pass
if lzma is not None: if lzma is not None:
FILE_OPENER_LIST.append((lzma.open, lzma.LZMAError)) FILE_OPENER_LIST.append((lzma.open, lzma.LZMAError))
......
Markdown is supported
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