
"""A shim for accessing cryptographic primitives needed by asyncssh"""

import importlib

from .cipher import register_cipher, lookup_cipher
from .curve25519 import Curve25519DH

from . import chacha

pyca_available = importlib.find_loader('cryptography')
pycrypto_available = importlib.find_loader('Crypto')

if pyca_available:
    from . import pyca

if pycrypto_available:
    from . import pycrypto

if pyca_available:
    from .pyca.dsa import DSAPrivateKey, DSAPublicKey
    from .pyca.rsa import RSAPrivateKey, RSAPublicKey
elif pycrypto_available:
    from .pycrypto.dsa import DSAPrivateKey, DSAPublicKey
    from .pycrypto.rsa import RSAPrivateKey, RSAPublicKey
else:
    raise ImportError('No suitable crypto library found.')


"""A shim for accessing cryptographic primitives needed by asyncssh"""

import importlib

from .cipher import register_cipher, lookup_cipher

try:
    from .curve25519 import Curve25519DH
except ImportError:
    pass

from . import chacha

pyca_available = importlib.find_loader('cryptography')
pycrypto_available = importlib.find_loader('Crypto')

if pyca_available:
    from . import pyca

if pycrypto_available:
    from . import pycrypto

if pyca_available:
    from .pyca.dsa import DSAPrivateKey, DSAPublicKey
    from .pyca.rsa import RSAPrivateKey, RSAPublicKey
elif pycrypto_available:
    from .pycrypto.dsa import DSAPrivateKey, DSAPublicKey
    from .pycrypto.rsa import RSAPrivateKey, RSAPublicKey
else:
    raise ImportError('No suitable crypto library found.')

Allow Curve25519DH import to fail in crypto package
Allow Curve25519DH import to fail in crypto package

With the refactoring to avoid pylint warnings, a problem was introduced
in importing the crypto module when the curve25519 dependencies were
unavailable. This commit fixes that problem.

  
  """A shim for accessing cryptographic primitives needed by asyncssh"""
  
  import importlib
  
  from .cipher import register_cipher, lookup_cipher
+ 
+ try:
- from .curve25519 import Curve25519DH
+     from .curve25519 import Curve25519DH
+ except ImportError:
+     pass
  
  from . import chacha
  
  pyca_available = importlib.find_loader('cryptography')
  pycrypto_available = importlib.find_loader('Crypto')
  
  if pyca_available:
      from . import pyca
  
  if pycrypto_available:
      from . import pycrypto
  
  if pyca_available:
      from .pyca.dsa import DSAPrivateKey, DSAPublicKey
      from .pyca.rsa import RSAPrivateKey, RSAPublicKey
  elif pycrypto_available:
      from .pycrypto.dsa import DSAPrivateKey, DSAPublicKey
      from .pycrypto.rsa import RSAPrivateKey, RSAPublicKey
  else:
      raise ImportError('No suitable crypto library found.')
  
Allow Curve25519DH import to fail in crypto package
## Code Before:

"""A shim for accessing cryptographic primitives needed by asyncssh"""

import importlib

from .cipher import register_cipher, lookup_cipher
from .curve25519 import Curve25519DH

from . import chacha

pyca_available = importlib.find_loader('cryptography')
pycrypto_available = importlib.find_loader('Crypto')

if pyca_available:
    from . import pyca

if pycrypto_available:
    from . import pycrypto

if pyca_available:
    from .pyca.dsa import DSAPrivateKey, DSAPublicKey
    from .pyca.rsa import RSAPrivateKey, RSAPublicKey
elif pycrypto_available:
    from .pycrypto.dsa import DSAPrivateKey, DSAPublicKey
    from .pycrypto.rsa import RSAPrivateKey, RSAPublicKey
else:
    raise ImportError('No suitable crypto library found.')

## Instruction:
Allow Curve25519DH import to fail in crypto package
## Code After:

"""A shim for accessing cryptographic primitives needed by asyncssh"""

import importlib

from .cipher import register_cipher, lookup_cipher

try:
    from .curve25519 import Curve25519DH
except ImportError:
    pass

from . import chacha

pyca_available = importlib.find_loader('cryptography')
pycrypto_available = importlib.find_loader('Crypto')

if pyca_available:
    from . import pyca

if pycrypto_available:
    from . import pycrypto

if pyca_available:
    from .pyca.dsa import DSAPrivateKey, DSAPublicKey
    from .pyca.rsa import RSAPrivateKey, RSAPublicKey
elif pycrypto_available:
    from .pycrypto.dsa import DSAPrivateKey, DSAPublicKey
    from .pycrypto.rsa import RSAPrivateKey, RSAPublicKey
else:
    raise ImportError('No suitable crypto library found.')
