diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-01-11 19:47:46 -0600 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-01-11 19:47:46 -0600 |
commit | b53e5a05f199b48de9f2f52afd29be4b9c876595 (patch) | |
tree | f5932c4a22691ae9eef7a7f1a77ae49b8d78a44a | |
parent | a9e31b35cb1cfd4489294b6f93eb8ea0f07641fb (diff) | |
download | cryptography-b53e5a05f199b48de9f2f52afd29be4b9c876595.tar.gz cryptography-b53e5a05f199b48de9f2f52afd29be4b9c876595.tar.bz2 cryptography-b53e5a05f199b48de9f2f52afd29be4b9c876595.zip |
simpler method of importing CommonCrypto backend into _ALL_BACKENDS
-rw-r--r-- | cryptography/hazmat/backends/__init__.py | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/cryptography/hazmat/backends/__init__.py b/cryptography/hazmat/backends/__init__.py index 54a227b7..cb1fee90 100644 --- a/cryptography/hazmat/backends/__init__.py +++ b/cryptography/hazmat/backends/__init__.py @@ -12,18 +12,15 @@ # limitations under the License. from cryptography.hazmat.backends import openssl +from cryptography.hazmat.bindings.commoncrypto.binding import ( + Binding as CCBinding +) -_POTENTIAL_BACKENDS = ["openssl", "commoncrypto"] +_ALL_BACKENDS = [openssl.backend] -_ALL_BACKENDS = [] - -for b in _POTENTIAL_BACKENDS: - binding = __import__("cryptography.hazmat.bindings.{0}.binding".format(b), - fromlist=["binding"]) - if binding.Binding.is_available(): - backend = __import__("cryptography.hazmat.backends.{0}".format(b), - fromlist=["backend"]) - _ALL_BACKENDS.append(backend.backend) +if CCBinding.is_available(): + from cryptography.hazmat.backends import commoncrypto + _ALL_BACKENDS.append(commoncrypto.backend) def default_backend(): |