Commit 1e403e0effe8dd425e78479498ec94a05a93893c

Authored by Christian Herdtweck
1 parent e01d85cd

crypto: raise more specific error if msoffcrypto missing

Showing 1 changed file with 3 additions and 3 deletions
oletools/crypto.py
@@ -90,7 +90,7 @@ from os.path import splitext, isfile @@ -90,7 +90,7 @@ from os.path import splitext, isfile
90 from tempfile import mkstemp 90 from tempfile import mkstemp
91 import zipfile 91 import zipfile
92 from oletools.common.errors import CryptoErrorBase, WrongEncryptionPassword, \ 92 from oletools.common.errors import CryptoErrorBase, WrongEncryptionPassword, \
93 - UnsupportedEncryptionError, MaxCryptoNestingReached 93 + UnsupportedEncryptionError, MaxCryptoNestingReached, CryptoLibNotImported
94 from olefile import OleFileIO 94 from olefile import OleFileIO
95 95
96 try: 96 try:
@@ -203,9 +203,9 @@ WRITE_PROTECT_ENCRYPTION_PASSWORD = 'VelvetSweatshop' @@ -203,9 +203,9 @@ WRITE_PROTECT_ENCRYPTION_PASSWORD = 'VelvetSweatshop'
203 203
204 204
205 def _check_msoffcrypto(): 205 def _check_msoffcrypto():
206 - """raise an :py:class:`ImportError` if :py:data:`msoffcrypto` is `None`.""" 206 + """Raise a :py:class:`CryptoLibNotImported` if msoffcrypto not imported."""
207 if msoffcrypto is None: 207 if msoffcrypto is None:
208 - raise ImportError('msoffcrypto-tools could not be imported') 208 + raise CryptoLibNotImported()
209 209
210 210
211 def decrypt(filename, passwords=None, **temp_file_args): 211 def decrypt(filename, passwords=None, **temp_file_args):