Commit 95bce4ed by Craig Heffner

Added check for backports.lzma when importing lzma module

parent c2cec5f6
......@@ -2,11 +2,14 @@
import os
import zlib
import lzma
import struct
import binwalk.core.compat
import binwalk.core.common
from binwalk.core.module import Option, Kwarg, Module
try:
import lzma
except ImportError:
from backports import lzma
class LZMAHeader(object):
def __init__(self, **kwargs):
......
......@@ -12,7 +12,11 @@ class LZMAExtractPlugin(binwalk.core.plugin.Plugin):
# lzma package in Python 2.0 decompress() does not handle multiple
# compressed streams, only first stream is extracted.
# backports.lzma package could be used to keep consistent behaviour.
try:
import lzma
except ImportError:
from backports import lzma
self.decompressor = lzma.decompress
# If the extractor is enabled for the module we're currently loaded
......
......@@ -17,7 +17,10 @@ class LZMAPlugin(binwalk.core.plugin.Plugin):
def init(self):
try:
try:
import lzma
except ImportError:
from backports import lzma
self.decompressor = lzma.decompress
except ImportError as e:
self.decompressor = None
......
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