diff options
author | Terry Chia <terrycwk1994@gmail.com> | 2016-08-29 20:21:28 +0800 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2016-08-29 08:21:28 -0400 |
commit | 3c35ef1ea77acc45aa71b6ad08ebe032e40e2c22 (patch) | |
tree | 2a8610359f6459e3ba39dc5dcb6efa88a40f6e64 /src | |
parent | a2bf0ea1706f501b44b538b9a14270657a1b92de (diff) | |
download | cryptography-3c35ef1ea77acc45aa71b6ad08ebe032e40e2c22.tar.gz cryptography-3c35ef1ea77acc45aa71b6ad08ebe032e40e2c22.tar.bz2 cryptography-3c35ef1ea77acc45aa71b6ad08ebe032e40e2c22.zip |
Add a register_interface_if decorator. (#3120)
* Add a register_interface_if decorator.
* Add tests.
* PEP 8.
Diffstat (limited to 'src')
-rw-r--r-- | src/cryptography/utils.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/cryptography/utils.py b/src/cryptography/utils.py index d3e845ab..48ed449a 100644 --- a/src/cryptography/utils.py +++ b/src/cryptography/utils.py @@ -31,6 +31,15 @@ def register_interface(iface): return register_decorator +def register_interface_if(predicate, iface): + def register_decorator(klass): + if predicate: + verify_interface(iface, klass) + iface.register(klass) + return klass + return register_decorator + + if hasattr(int, "from_bytes"): int_from_bytes = int.from_bytes else: |