diff options
author | Mike Crute <mike@crute.us> | 2017-10-01 01:48:07 +0000 |
---|---|---|
committer | Mike Crute <mike@crute.us> | 2017-10-01 01:48:07 +0000 |
commit | 3afeff998ca67acc36f3997421b7887fcc748b66 (patch) | |
tree | 6cd9c7363e1861e582475385bd48f83de046209e | |
parent | 37f5aa14e2d43f8b81c6fd6de43be1f67d4c08ee (diff) | |
download | pydora-3afeff998ca67acc36f3997421b7887fcc748b66.tar.bz2 pydora-3afeff998ca67acc36f3997421b7887fcc748b66.tar.xz pydora-3afeff998ca67acc36f3997421b7887fcc748b66.zip |
Fix blowfish PEP8 error
-rw-r--r-- | pandora/transport.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/pandora/transport.py b/pandora/transport.py index f609cee..42aba2a 100644 --- a/pandora/transport.py +++ b/pandora/transport.py | |||
@@ -18,6 +18,11 @@ from requests.adapters import HTTPAdapter | |||
18 | 18 | ||
19 | from .errors import PandoraException | 19 | from .errors import PandoraException |
20 | 20 | ||
21 | try: | ||
22 | import blowfish | ||
23 | except ImportError: | ||
24 | blowfish = None | ||
25 | |||
21 | 26 | ||
22 | DEFAULT_API_HOST = "tuner.pandora.com/services/json/" | 27 | DEFAULT_API_HOST = "tuner.pandora.com/services/json/" |
23 | 28 | ||
@@ -302,7 +307,6 @@ class PurePythonBlowfish(BlowfishCryptor): | |||
302 | """ | 307 | """ |
303 | 308 | ||
304 | def __init__(self, key): | 309 | def __init__(self, key): |
305 | import blowfish | ||
306 | self.cipher = blowfish.Cipher(key.encode("ascii")) | 310 | self.cipher = blowfish.Cipher(key.encode("ascii")) |
307 | 311 | ||
308 | def decrypt(self, data, strip_padding=True): | 312 | def decrypt(self, data, strip_padding=True): |
@@ -314,11 +318,7 @@ class PurePythonBlowfish(BlowfishCryptor): | |||
314 | 318 | ||
315 | 319 | ||
316 | # Python 3 users can use pure-python mode, if possible prefer that as default | 320 | # Python 3 users can use pure-python mode, if possible prefer that as default |
317 | try: | 321 | _default_crypto = PurePythonBlowfish if blowfish else CryptographyBlowfish |
318 | import blowfish | ||
319 | default_crypto_class = PurePythonBlowfish | ||
320 | except ImportError: | ||
321 | default_crypto_class = CryptographyBlowfish | ||
322 | 322 | ||
323 | 323 | ||
324 | class Encryptor(object): | 324 | class Encryptor(object): |
@@ -328,7 +328,7 @@ class Encryptor(object): | |||
328 | API request and response. It handles the formats that the API expects. | 328 | API request and response. It handles the formats that the API expects. |
329 | """ | 329 | """ |
330 | 330 | ||
331 | def __init__(self, in_key, out_key, crypto_class=default_crypto_class): | 331 | def __init__(self, in_key, out_key, crypto_class=_default_crypto): |
332 | self.bf_out = crypto_class(out_key) | 332 | self.bf_out = crypto_class(out_key) |
333 | self.bf_in = crypto_class(in_key) | 333 | self.bf_in = crypto_class(in_key) |
334 | 334 | ||